author | Claus Gittinger <cg@exept.de> |
Mon, 23 Feb 2015 12:37:42 +0100 | |
changeset 5279 | 3af2da2c44e6 |
parent 5260 | d062a1aa6b99 |
child 5283 | 9c75aed7c274 |
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 |
||
865 | 141 |
!EditTextView class methodsFor:'documentation'! |
0 | 142 |
|
33 | 143 |
copyright |
144 |
" |
|
145 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 146 |
All Rights Reserved |
33 | 147 |
|
148 |
This software is furnished under a license and may be used |
|
149 |
only in accordance with the terms of that license and with the |
|
150 |
inclusion of the above copyright notice. This software may not |
|
151 |
be provided or otherwise made available to, or used by, any |
|
152 |
other person. No title to or ownership of the software is |
|
153 |
hereby transferred. |
|
154 |
" |
|
155 |
! |
|
156 |
||
0 | 157 |
documentation |
158 |
" |
|
159 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 160 |
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
|
161 |
acceptAction to be performed for accept |
125 | 162 |
|
163 |
If used with a model, this is informed by sending it a changeMsg with |
|
164 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
165 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 166 |
|
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
|
167 |
Please read the historic notice in the ListView class. |
0 | 168 |
|
586 | 169 |
[Instance variables:] |
0 | 170 |
|
4010 | 171 |
cursorLine <Number> line where cursor sits (1..) |
172 |
||
173 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
174 |
||
175 |
cursorCol <Number> col where cursor sits (1..) |
|
176 |
||
177 |
cursorShown <Boolean> true, if cursor is currently shown |
|
178 |
||
179 |
readOnly <Boolean> true, if text may not be edited |
|
180 |
||
181 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
182 |
cleared on accept. |
|
183 |
||
184 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
185 |
||
186 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
187 |
||
188 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
189 |
if it returns true, the modification will be done anyway. |
|
190 |
if it returns anything else, the modification is not done. |
|
191 |
||
192 |
cursorFgColor <Color> color used for cursor drawing |
|
193 |
cursorBgColor <Color> color used for cursor drawing |
|
194 |
||
195 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 196 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 197 |
(vertical bar at insertion point) |
4721 | 198 |
and #caret (caret below insertion-point). |
199 |
see cursorType: for an up-to-date list. |
|
4010 | 200 |
|
201 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
202 |
nil means: hide the cursor. |
|
203 |
||
204 |
undoAction <Block> block which undoes last cut, paste or replace |
|
205 |
(not yet fully implemented) |
|
206 |
||
207 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
208 |
this affects the next keyPress: if #paste it does not |
|
209 |
replace; otherwise it replaces the selection. |
|
210 |
||
211 |
lastCut <String> last cut or replaced string |
|
212 |
||
4053 | 213 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
214 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
215 |
lastReplacement is the string to replace lastStringToReplace |
|
216 |
||
217 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
218 |
(cleared after a new selection) |
|
4010 | 219 |
|
220 |
replacing <Boolean> true if entered characters replace last selection |
|
221 |
||
222 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
223 |
when entering one; this is the default. |
|
224 |
||
225 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
226 |
||
227 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
228 |
argument |
|
229 |
||
230 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
231 |
focus to the next field. For editTextViews, this is false |
|
232 |
by default (i.e. tabs can be entered into the text). |
|
233 |
For some subclasses (inputFields), this may be true. |
|
234 |
||
235 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
236 |
removed when editing. |
|
237 |
Default is true. |
|
238 |
||
239 |
wordWrap <Boolean> Currently not used. |
|
240 |
||
241 |
lockUpdates <Boolean> internal, private |
|
242 |
||
243 |
prevCursorState <Boolean> temporary, private |
|
244 |
||
245 |
cursorMovementWhenUpdating |
|
246 |
<Symbol> defines where the cursor is to be positioned if the |
|
247 |
model changes its value by some outside activity |
|
248 |
(i.e. not by user input into the field). |
|
249 |
Can be one of: |
|
250 |
#keep / nil -> stay where it was |
|
251 |
#endOfText -> cursor to the end |
|
252 |
#endOfLine -> stay in the line, but move to end |
|
253 |
#beginOfText -> cursor to the beginning |
|
254 |
#beginOfLine -> stay in the line, but move to begin |
|
255 |
The default is #beginOfText |
|
256 |
||
257 |
||
258 |
||
259 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 260 |
|
261 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
262 |
userPreference values: |
4010 | 263 |
userPreferences.st80EditMode |
264 |
<Boolean> if true, cursor positioning is |
|
265 |
done as in vi or ST80; i.e. |
|
266 |
wysiwyg mode is somewhat relaxed, |
|
267 |
in that the cursor cannot be |
|
268 |
positioned behind a lines end. |
|
269 |
This is not yet completely implemented. |
|
33 | 270 |
used globals: |
271 |
||
4010 | 272 |
DeleteHistory <Text> last 1000 lines of deleted text |
273 |
(but only if this variable exists already) |
|
586 | 274 |
|
275 |
[styleSheet parameters:] |
|
121 | 276 |
|
4010 | 277 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
278 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
279 |
textCursorNoFocusForegroundColor |
|
280 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
281 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 282 |
|
283 |
[author:] |
|
4010 | 284 |
Claus Gittinger |
586 | 285 |
|
286 |
[see also:] |
|
4010 | 287 |
CodeView Workspace TextView ListView |
288 |
EditField |
|
0 | 289 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
295 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
296 |
basic setup: |
4823 | 297 |
[exBegin] |
298 |
|top textView| |
|
299 |
||
300 |
top := StandardSystemView new. |
|
301 |
top extent:300@200. |
|
302 |
||
303 |
textView := EditTextView new. |
|
304 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
305 |
top addSubView:textView. |
|
306 |
||
307 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
308 |
||
309 |
top open. |
|
310 |
[exEnd] |
|
594 | 311 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
312 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
313 |
with vertical scrollbar: |
4823 | 314 |
[exBegin] |
315 |
|top scrollView textView| |
|
316 |
||
317 |
top := StandardSystemView new. |
|
318 |
top extent:300@200. |
|
319 |
||
320 |
scrollView := ScrollableView for:EditTextView. |
|
321 |
textView := scrollView scrolledView. |
|
322 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
323 |
top addSubView:scrollView. |
|
324 |
||
325 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
326 |
||
327 |
top open. |
|
328 |
[exEnd] |
|
594 | 329 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
330 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
331 |
with horizontal & vertical scrollbars: |
4823 | 332 |
[exBegin] |
333 |
|top scrollView textView| |
|
334 |
||
335 |
top := StandardSystemView new. |
|
336 |
top extent:300@200. |
|
337 |
||
338 |
scrollView := HVScrollableView for:EditTextView. |
|
339 |
textView := scrollView scrolledView. |
|
340 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
341 |
top addSubView:scrollView. |
|
342 |
||
343 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
344 |
||
345 |
top open. |
|
346 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
347 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
348 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
349 |
set the action for accept: |
4823 | 350 |
[exBegin] |
351 |
|top textView| |
|
352 |
||
353 |
top := StandardSystemView new. |
|
354 |
top extent:300@200. |
|
355 |
||
356 |
textView := EditTextView new. |
|
357 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
358 |
top addSubView:textView. |
|
359 |
||
360 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
361 |
textView acceptAction:[:contents | |
|
362 |
Transcript showCR:'will not overwrite the file with:'. |
|
363 |
Transcript showCR:contents asString |
|
364 |
]. |
|
365 |
top open. |
|
366 |
[exEnd] |
|
594 | 367 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
368 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
369 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
370 |
non-string (text) items: |
4823 | 371 |
[exBegin] |
372 |
|top textView list| |
|
373 |
||
374 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
375 |
1 to:list size by:2 do:[:nr | |
|
376 |
list at:nr put:(Text string:(list at:nr) |
|
377 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
378 |
]. |
|
379 |
||
380 |
top := StandardSystemView new. |
|
381 |
top extent:300@200. |
|
382 |
||
383 |
textView := EditTextView new. |
|
384 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
385 |
top addSubView:textView. |
|
386 |
||
387 |
textView contents:list. |
|
388 |
top open. |
|
389 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
390 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
391 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
392 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
393 |
MVC operation: |
594 | 394 |
(the examples model here is a plug simulating a real model; |
395 |
real world applications would not use a plug ..) |
|
4823 | 396 |
[exBegin] |
397 |
|top textView model| |
|
398 |
||
399 |
model := Plug new. |
|
400 |
model respondTo:#accepted: |
|
401 |
with:[:newContents | |
|
402 |
Transcript showCR:'will not overwrite the file with:'. |
|
403 |
Transcript showCR:newContents asString |
|
404 |
]. |
|
405 |
model respondTo:#getList |
|
406 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
407 |
||
408 |
||
409 |
top := StandardSystemView new. |
|
410 |
top extent:300@200. |
|
411 |
||
412 |
textView := EditTextView new. |
|
413 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
414 |
top addSubView:textView. |
|
415 |
||
416 |
textView listMessage:#getList; |
|
417 |
model:model; |
|
418 |
changeMessage:#accepted:; |
|
419 |
aspect:#list. |
|
420 |
top open. |
|
421 |
[exEnd] |
|
594 | 422 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
423 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
424 |
two textViews on the same model: |
4823 | 425 |
[exBegin] |
426 |
|top1 textView1 top2 textView2 model currentContents| |
|
427 |
||
428 |
model := Plug new. |
|
429 |
model respondTo:#accepted: |
|
430 |
with:[:newContents | |
|
431 |
Transcript showCR:'accepted:'. |
|
432 |
Transcript showCR:newContents asString. |
|
433 |
currentContents := newContents. |
|
434 |
model changed:#contents |
|
435 |
]. |
|
436 |
model respondTo:#getList |
|
437 |
with:[Transcript showCR:'query'. |
|
438 |
currentContents]. |
|
439 |
||
440 |
||
441 |
top1 := StandardSystemView new. |
|
442 |
top1 extent:300@200. |
|
443 |
||
444 |
textView1 := EditTextView new. |
|
445 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
446 |
top1 addSubView:textView1. |
|
447 |
||
448 |
textView1 listMessage:#getList; |
|
449 |
model:model; |
|
450 |
aspect:#contents; |
|
451 |
changeMessage:#accepted:. |
|
452 |
top1 open. |
|
453 |
||
454 |
top2 := StandardSystemView new. |
|
455 |
top2 extent:300@200. |
|
456 |
||
457 |
textView2 := EditTextView new. |
|
458 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
459 |
top2 addSubView:textView2. |
|
460 |
||
461 |
textView2 listMessage:#getList; |
|
462 |
model:model; |
|
463 |
aspect:#contents; |
|
464 |
changeMessage:#accepted:. |
|
465 |
top2 open. |
|
466 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
467 |
" |
0 | 468 |
! ! |
469 |
||
865 | 470 |
!EditTextView class methodsFor:'defaults'! |
59 | 471 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
472 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
473 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
474 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
475 |
"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
|
476 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
477 |
|
1419 | 478 |
st80Mode |
479 |
"return true, if the st80 editing mode is turned on. |
|
480 |
This setting affects the behavior of the cursor, when positioned |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
481 |
beyond the end of a line or the end of the text." |
1419 | 482 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
483 |
^ UserPreferences current st80EditMode |
1419 | 484 |
|
485 |
" |
|
486 |
EditTextView st80Mode:true |
|
487 |
EditTextView st80Mode:false |
|
488 |
" |
|
489 |
||
490 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
491 |
! |
|
492 |
||
493 |
st80Mode:aBoolean |
|
494 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 495 |
beyond the end of a line or the last line" |
1419 | 496 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
497 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 498 |
|
499 |
" |
|
500 |
EditTextView st80Mode:true |
|
501 |
EditTextView st80Mode:false |
|
502 |
" |
|
503 |
||
504 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
505 |
! |
|
506 |
||
59 | 507 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
508 |
"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
|
509 |
|
1390 | 510 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 511 |
#'textCursor.noFocusForegroundColor' |
512 |
#'textCursor.type' |
|
513 |
#'textCursor.typeNoFocus' |
|
514 |
#'editText.st80Mode')> |
|
1355 | 515 |
|
516 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
517 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
518 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
519 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
520 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
521 |
|
1419 | 522 |
" |
523 |
self updateStyleCache |
|
524 |
" |
|
525 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
526 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 527 |
! ! |
528 |
||
3431 | 529 |
!EditTextView class methodsFor:'specs'! |
530 |
||
531 |
searchReplaceDialogSpec |
|
532 |
"This resource specification was automatically generated |
|
533 |
by the UIPainter of ST/X." |
|
534 |
||
535 |
"Do not manually edit this!! If it is corrupted, |
|
536 |
the UIPainter may not be able to read the specification." |
|
537 |
||
538 |
" |
|
539 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
540 |
" |
|
541 |
||
542 |
<resource: #canvas> |
|
543 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
544 |
^ |
3431 | 545 |
#(FullSpec |
4823 | 546 |
name: searchReplaceDialogSpec |
547 |
window: |
|
3431 | 548 |
(WindowSpec |
4823 | 549 |
label: 'String Search and Replace' |
550 |
name: 'String Search and Replace' |
|
551 |
min: (Point 283 196) |
|
552 |
max: (Point 283 196) |
|
553 |
bounds: (Rectangle 0 0 279 192) |
|
554 |
) |
|
555 |
component: |
|
3431 | 556 |
(SpecCollection |
4823 | 557 |
collection: ( |
558 |
(LabelSpec |
|
559 |
label: 'Search Pattern:' |
|
560 |
name: 'label' |
|
561 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
562 |
level: 0 |
|
563 |
translateLabel: true |
|
564 |
adjust: left |
|
565 |
) |
|
566 |
(ComboBoxSpec |
|
567 |
name: 'patternComboBox' |
|
568 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
569 |
tabable: true |
|
570 |
model: searchPattern |
|
571 |
immediateAccept: false |
|
572 |
acceptOnLeave: true |
|
573 |
acceptOnReturn: true |
|
574 |
acceptOnTab: true |
|
575 |
acceptOnLostFocus: true |
|
576 |
acceptOnPointerLeave: false |
|
577 |
autoSelectInitialText: true |
|
578 |
comboList: patternList |
|
579 |
) |
|
580 |
(ComboBoxSpec |
|
581 |
name: 'replaceComboBox' |
|
582 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
583 |
tabable: true |
|
584 |
model: replacePattern |
|
585 |
immediateAccept: false |
|
586 |
acceptOnLeave: true |
|
587 |
acceptOnReturn: true |
|
588 |
acceptOnTab: true |
|
589 |
acceptOnLostFocus: true |
|
590 |
acceptOnPointerLeave: false |
|
591 |
autoSelectInitialText: true |
|
592 |
comboList: patternList |
|
593 |
) |
|
594 |
(CheckBoxSpec |
|
595 |
label: 'Ignore Case' |
|
596 |
name: 'ignoreCaseCheckBox' |
|
597 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
598 |
level: 0 |
|
599 |
tabable: true |
|
600 |
model: ignoreCase |
|
601 |
translateLabel: true |
|
602 |
) |
|
603 |
(VariableVerticalPanelSpec |
|
604 |
name: 'VariableVerticalPanel1' |
|
605 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
606 |
component: |
|
607 |
(SpecCollection |
|
608 |
collection: ( |
|
609 |
(HorizontalPanelViewSpec |
|
610 |
name: 'HorizontalPanel1' |
|
611 |
level: 0 |
|
612 |
horizontalLayout: fitSpace |
|
613 |
verticalLayout: center |
|
614 |
horizontalSpace: 3 |
|
615 |
verticalSpace: 3 |
|
616 |
ignoreInvisibleComponents: true |
|
617 |
reverseOrderIfOKAtLeft: true |
|
618 |
component: |
|
619 |
(SpecCollection |
|
620 |
collection: ( |
|
621 |
(ActionButtonSpec |
|
622 |
label: 'Replace' |
|
623 |
name: 'replaceButton' |
|
624 |
level: 2 |
|
625 |
translateLabel: true |
|
626 |
tabable: true |
|
627 |
model: replaceAction |
|
628 |
extent: (Point 134 21) |
|
629 |
) |
|
630 |
(ActionButtonSpec |
|
631 |
label: 'Replace All' |
|
632 |
name: 'replaceAllButton' |
|
633 |
level: 2 |
|
634 |
borderWidth: 1 |
|
635 |
translateLabel: true |
|
636 |
tabable: true |
|
637 |
model: replaceAllAction |
|
638 |
extent: (Point 134 21) |
|
639 |
) |
|
640 |
) |
|
641 |
||
642 |
) |
|
643 |
) |
|
644 |
(HorizontalPanelViewSpec |
|
645 |
name: 'horizontalPanelView' |
|
646 |
level: 0 |
|
647 |
horizontalLayout: fitSpace |
|
648 |
verticalLayout: center |
|
649 |
horizontalSpace: 3 |
|
650 |
verticalSpace: 3 |
|
651 |
ignoreInvisibleComponents: true |
|
652 |
reverseOrderIfOKAtLeft: true |
|
653 |
component: |
|
654 |
(SpecCollection |
|
655 |
collection: ( |
|
656 |
(ActionButtonSpec |
|
657 |
label: 'Cancel' |
|
658 |
name: 'cancelButton' |
|
659 |
level: 2 |
|
660 |
translateLabel: true |
|
661 |
tabable: true |
|
662 |
model: cancel |
|
663 |
extent: (Point 88 21) |
|
664 |
) |
|
665 |
(ActionButtonSpec |
|
666 |
label: 'Prev' |
|
667 |
name: 'prevButton' |
|
668 |
level: 2 |
|
669 |
translateLabel: true |
|
670 |
tabable: true |
|
671 |
model: prevAction |
|
672 |
extent: (Point 89 21) |
|
673 |
) |
|
674 |
(ActionButtonSpec |
|
675 |
label: 'Next' |
|
676 |
name: 'nextButton' |
|
677 |
level: 2 |
|
678 |
borderWidth: 1 |
|
679 |
translateLabel: true |
|
680 |
tabable: true |
|
681 |
model: nextAction |
|
682 |
isDefault: true |
|
683 |
extent: (Point 88 21) |
|
684 |
) |
|
685 |
) |
|
686 |
||
687 |
) |
|
688 |
) |
|
689 |
) |
|
690 |
||
691 |
) |
|
692 |
handles: (Any 0.5 1.0) |
|
693 |
) |
|
694 |
(LabelSpec |
|
695 |
label: 'Replace By:' |
|
696 |
name: 'ReplaceLabel' |
|
697 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
698 |
level: 0 |
|
699 |
translateLabel: true |
|
700 |
adjust: left |
|
701 |
) |
|
702 |
) |
|
703 |
||
704 |
) |
|
3431 | 705 |
) |
706 |
||
707 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
708 |
! ! |
|
709 |
||
2744 | 710 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
711 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
712 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
713 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
714 |
|
2019 | 715 |
"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
|
716 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
717 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
718 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
719 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
720 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
721 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
722 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
723 |
|
1390 | 724 |
cutSelection |
725 |
self cut |
|
726 |
||
727 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
728 |
! |
|
729 |
||
1590 | 730 |
deselect |
731 |
"remove the selection" |
|
732 |
||
733 |
^ self unselect |
|
734 |
||
735 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
736 |
! |
|
737 |
||
2101 | 738 |
enabled:aBoolean |
739 |
||
740 |
self readOnly:aBoolean not |
|
741 |
||
742 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
743 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
744 |
! |
|
745 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
746 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
747 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
748 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
749 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
750 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
751 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
752 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
753 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
754 |
"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
|
755 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
756 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
757 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
758 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
759 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
760 |
col < 1 ifTrue:[ |
4823 | 761 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
762 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
763 |
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
|
764 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
765 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
766 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
767 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
768 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
769 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
770 |
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
|
771 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
772 |
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
|
773 |
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
|
774 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
775 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
776 |
"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
|
777 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
778 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
779 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
780 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
781 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
782 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
783 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
784 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 785 |
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
|
786 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
787 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 788 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
789 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
790 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
791 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
792 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
793 |
v insertAndSelect:'<- hello there' at:5. |
125 | 794 |
" |
1390 | 795 |
! |
796 |
||
797 |
pasteSelection |
|
798 |
self paste |
|
799 |
||
800 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 801 |
! |
802 |
||
803 |
replaceSelectionWith:aString |
|
804 |
^ self replaceSelectionBy:aString |
|
805 |
||
806 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
807 |
! |
|
808 |
||
809 |
selectAt:pos |
|
810 |
"move the cursor before cursorPosition." |
|
811 |
||
812 |
self cursorToCharacterPosition:pos |
|
813 |
||
814 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
815 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
816 |
! |
|
817 |
||
2101 | 818 |
textHasChanged |
819 |
^ self modified |
|
820 |
||
821 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
822 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
823 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
824 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
825 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
826 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
827 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
828 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
829 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
830 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
831 |
|
4585 | 832 |
!EditTextView methodsFor:'accessing'! |
833 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
834 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
835 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
836 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
837 |
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
|
838 |
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
|
839 |
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
|
840 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
841 |
"/ 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
|
842 |
"/ 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
|
843 |
^((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
|
844 |
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
|
845 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
846 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
847 |
"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
|
848 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
849 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
850 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
851 |
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
|
852 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
853 |
"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
|
854 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
855 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
856 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
857 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
858 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
859 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
860 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
861 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
862 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
863 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
864 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
865 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
866 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
867 |
"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
|
868 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
869 |
|
4609 | 870 |
editedClass |
871 |
|cm| |
|
872 |
||
873 |
cm := self editedMethodOrClass. |
|
874 |
cm isBehavior ifTrue:[^ cm]. |
|
875 |
cm isMethod ifTrue:[^ cm mclass]. |
|
876 |
^ nil |
|
877 |
! |
|
878 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
879 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
880 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
881 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
882 |
"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
|
883 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
884 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
885 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
886 |
"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
|
887 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
888 |
"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
|
889 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
890 |
|
4609 | 891 |
editedMethod |
892 |
|cm| |
|
893 |
||
894 |
cm := self editedMethodOrClass. |
|
895 |
cm isMethod ifTrue:[^ cm]. |
|
896 |
cm isBehavior ifTrue:[^ nil]. |
|
897 |
^ nil |
|
898 |
! |
|
899 |
||
900 |
editedMethodOrClass |
|
901 |
^ nil |
|
902 |
! |
|
903 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
904 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
"Sets the edited 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
|
906 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
"Created: / 27-09-2013 / 10: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
|
908 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
909 |
|
4585 | 910 |
hasSelectionOrTextInCursorLine |
911 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
912 |
! |
|
913 |
||
4589 | 914 |
selectionOrTextOfCursorLine |
915 |
^ self selectionOrTextOfCursorLine:true |
|
916 |
! |
|
917 |
||
4585 | 918 |
selectionOrTextOfCursorLine:doSelect |
919 |
|sel lNr line| |
|
920 |
||
921 |
sel := self selectionAsString. |
|
922 |
sel notNil ifTrue:[^ sel]. |
|
923 |
||
924 |
lNr := self cursorLine. |
|
925 |
line := self listAt:lNr. |
|
926 |
line notEmptyOrNil ifTrue:[ |
|
927 |
doSelect ifTrue:[ |
|
928 |
self selectLine:lNr. |
|
929 |
]. |
|
930 |
^ line |
|
931 |
]. |
|
932 |
||
933 |
^ nil |
|
934 |
! ! |
|
935 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
936 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
937 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
938 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
939 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
940 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
941 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
942 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
944 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
945 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
946 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
947 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
948 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
949 |
|
2792 | 950 |
acceptChannel |
951 |
"return the valueHolder holding true if text was accepted. |
|
952 |
By placing a true into this channel, an accept can also be forced." |
|
953 |
||
954 |
^ acceptChannel |
|
955 |
||
956 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
957 |
! |
|
958 |
||
959 |
acceptChannel:aValueHolder |
|
960 |
"set the valueHolder holding true if text was accepted. |
|
961 |
By placing a true into this channel, an accept can also be forced." |
|
962 |
||
963 |
|prev| |
|
964 |
||
965 |
prev := acceptChannel. |
|
966 |
acceptChannel := aValueHolder. |
|
967 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
968 |
||
969 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
970 |
! |
|
971 |
||
1108 | 972 |
acceptEnabled:aBoolean |
973 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
974 |
||
975 |
acceptEnabled := aBoolean |
|
976 |
||
977 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
978 |
! |
|
979 |
||
2792 | 980 |
accepted |
981 |
"return true if text was accepted" |
|
982 |
||
983 |
^ acceptChannel value |
|
984 |
||
985 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
986 |
! |
|
987 |
||
988 |
accepted:aBoolean |
|
989 |
"set/clear the accepted flag. |
|
990 |
This may force my current contents to be placed into my model." |
|
991 |
||
992 |
acceptChannel value:aBoolean. |
|
993 |
||
994 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
995 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
996 |
! |
|
997 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
998 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
999 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1000 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1001 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1002 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1003 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1004 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1005 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1006 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1007 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1008 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1009 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1010 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1011 |
|
2774 | 1012 |
cursorMovementWhenUpdating |
3160 | 1013 |
"return what is be done with the cursor, |
2774 | 1014 |
when I get a new text (via the model or the #contents/#list) |
1015 |
Allowed arguments are: |
|
4823 | 1016 |
#keep / nil -> stay where it was |
1017 |
#endOfText -> position cursor to the end |
|
1018 |
#beginOfText -> position cursor to the beginning |
|
1019 |
#endOfLine -> position cursor to the current lines end |
|
1020 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1021 |
The default is #beginOfText. |
1022 |
This may be useful for fields which get new values assigned from |
|
1023 |
the program (i.e. not from the user)" |
|
1024 |
||
1025 |
^ cursorMovementWhenUpdating |
|
1026 |
||
1027 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1028 |
! |
|
1029 |
||
2133 | 1030 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1031 |
"define what should be done with the cursor, |
2133 | 1032 |
when I get a new text (via the model or the #contents/#list) |
1033 |
Allowed arguments are: |
|
4823 | 1034 |
#keep / nil -> stay where it was |
1035 |
#endOfText -> position cursor to the end |
|
1036 |
#beginOfText -> position cursor to the beginning |
|
1037 |
#endOfLine -> position cursor to the current lines end |
|
1038 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1039 |
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
|
1040 |
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
|
1041 |
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
|
1042 |
|
2133 | 1043 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1044 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1045 |
"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
|
1046 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1047 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1048 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1049 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1050 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1051 |
|
2438 | 1052 |
dontReplaceSelectionOnInput |
4742 | 1053 |
"remember that the current selection was created by a paste operation |
1054 |
(as opposed to an explicit selection by the user). |
|
1055 |
This selection will not be replaced by followup user input, |
|
1056 |
so multiple pastes will be possible." |
|
1057 |
||
2438 | 1058 |
typeOfSelection := #paste |
1059 |
! |
|
1060 |
||
3235 | 1061 |
editModeHolder |
1062 |
^ editMode. |
|
1063 |
! |
|
1064 |
||
1065 |
editModeInsert |
|
1066 |
editMode value:EditMode insertMode |
|
1067 |
! |
|
1068 |
||
1069 |
editModeInsertAndSelect |
|
1070 |
editMode value:EditMode insertAndSelectMode |
|
1071 |
! |
|
1072 |
||
1073 |
editModeOverwrite |
|
1074 |
editMode value:EditMode overwriteMode |
|
1075 |
! |
|
1076 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1077 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1078 |
"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
|
1079 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1080 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1081 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1082 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1083 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1084 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1085 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1086 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1087 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1088 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1089 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1090 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1091 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1092 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1093 |
readOnly == true ifFalse:[ |
4823 | 1094 |
readOnly := true. |
1095 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1096 |
menu disableAll:#(cut paste replace indent) |
|
1097 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1098 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1099 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1100 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1101 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1102 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1103 |
insertMode:aBoolean |
3235 | 1104 |
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
|
1105 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1106 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1107 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1108 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1109 |
insertModeHolder |
3235 | 1110 |
^ BlockValue |
4823 | 1111 |
with:[:m | m isInsertMode] |
1112 |
argument:(editMode). |
|
3465 | 1113 |
|
1114 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1115 |
! |
1116 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1117 |
isInInsertMode |
3235 | 1118 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1119 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1120 |
|
5216 | 1121 |
isNotReadOnly |
1122 |
"return true, if the text is not readonly." |
|
1123 |
||
1124 |
^ self isReadOnly not |
|
1125 |
! |
|
1126 |
||
2792 | 1127 |
isReadOnly |
1128 |
"return true, if the text is readonly." |
|
1129 |
||
1130 |
^ readOnly value |
|
1131 |
||
1132 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1133 |
! |
|
1134 |
||
2796 | 1135 |
modeLabelHolder |
1136 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1137 |
||
3160 | 1138 |
^ BlockValue |
4041 | 1139 |
with:[:e :l | |
1140 |
self isReadOnly ifTrue:[ |
|
1141 |
'' |
|
1142 |
] ifFalse:[ |
|
1143 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1144 |
ifFalse:[ e infoPrintString]]] |
|
1145 |
argument:(self editModeHolder) |
|
1146 |
argument:(self learnModeHolder). |
|
3465 | 1147 |
|
1148 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1149 |
! |
1150 |
||
2792 | 1151 |
modified |
1152 |
"return true if text was modified" |
|
1153 |
||
1154 |
^ modifiedChannel value |
|
1155 |
! |
|
1156 |
||
1157 |
modified:aBoolean |
|
1158 |
"set/clear the modified flag" |
|
1159 |
||
1160 |
modifiedChannel value:aBoolean |
|
1161 |
||
1162 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1163 |
! |
|
1164 |
||
1165 |
modifiedChannel |
|
1166 |
"return the valueHolder holding true if text was modified" |
|
1167 |
||
1168 |
^ modifiedChannel |
|
1169 |
! |
|
1170 |
||
1171 |
modifiedChannel:aValueHolder |
|
1172 |
"set the valueHolder holding true if text was modified" |
|
1173 |
||
1174 |
|prev| |
|
1175 |
||
1176 |
prev := modifiedChannel. |
|
1177 |
modifiedChannel := aValueHolder. |
|
1178 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1179 |
||
1180 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1181 |
! |
|
1182 |
||
1183 |
readOnly |
|
1184 |
"make the text readonly. |
|
4664 | 1185 |
Obsolete because it is obfuscating (looks like a getter) |
1186 |
- use #readOnly:" |
|
2792 | 1187 |
|
1188 |
<resource:#obsolete> |
|
1189 |
||
1190 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1191 |
self readOnly:true. |
2792 | 1192 |
|
4664 | 1193 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1194 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1195 |
! |
1196 |
||
1197 |
readOnly:aBoolean |
|
1198 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1199 |
The argument may also be a valueHolder." |
|
1200 |
||
1201 |
readOnly := aBoolean |
|
1202 |
||
1203 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1204 |
! |
|
1205 |
||
4782 | 1206 |
reallyModifiedChannel |
1207 |
"return the valueHolder holding true if text was really modified. |
|
1208 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1209 |
||
1210 |
^ self modifiedChannel |
|
1211 |
! |
|
1212 |
||
5255 | 1213 |
st80Mode:aBooleanOrNil |
4192 | 1214 |
"set/clear the st80Mode flag. |
1215 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1216 |
if off, we have the Rand-editor behavior (random access) |
1217 |
if nil, the setting follows the current userPref setting." |
|
1218 |
||
1219 |
st80Mode := aBooleanOrNil |
|
4192 | 1220 |
|
1221 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1222 |
! |
|
1223 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1224 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1225 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1226 |
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
|
1227 |
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
|
1228 |
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
|
1229 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1230 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1231 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1232 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1233 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1234 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1235 |
"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
|
1236 |
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
|
1237 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1238 |
|
3160 | 1239 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1240 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1241 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1242 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1243 |
"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
|
1244 |
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
|
1245 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1246 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1247 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1248 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1249 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1250 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1251 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1252 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1253 |
"change a line without change notification" |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1254 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1255 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1256 |
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
|
1257 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1258 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1259 |
|
522 | 1260 |
at:lineNr put:aLine |
1261 |
(self at:lineNr) = aLine ifFalse:[ |
|
4823 | 1262 |
super at:lineNr put:aLine. |
1263 |
self textChanged |
|
522 | 1264 |
]. |
1265 |
! |
|
1266 |
||
4700 | 1267 |
characterAfterCursor |
1268 |
"return the character one after the cursor - space if beyond line." |
|
1269 |
||
1270 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1271 |
! |
|
1272 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1273 |
characterBeforeCursor |
4700 | 1274 |
"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
|
1275 |
|
5142 | 1276 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1277 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1278 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1279 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1280 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1281 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1282 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1283 |
characterUnderCursor |
2707 | 1284 |
"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
|
1285 |
For non-block cursors, this is the character immediately to the right |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1286 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1287 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1288 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1289 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1290 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1291 |
contents |
2213 | 1292 |
"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
|
1293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1294 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1295 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1296 |
^ super contents. |
3313 | 1297 |
|
1298 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1299 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1300 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1301 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1302 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1303 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1304 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1305 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1306 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1307 |
keepUndoHistory ifFalse:[ |
4823 | 1308 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1309 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1310 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1311 |
|
2213 | 1312 |
contentsAsString |
1313 |
"return the contents as a String (i.e. without emphasis)" |
|
1314 |
||
1315 |
list isNil ifTrue:[^ '']. |
|
1316 |
self removeTrailingBlankLines. |
|
1317 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1318 |
ifFalse:[each string] |
1319 |
]) asStringWithCRs |
|
2213 | 1320 |
! |
1321 |
||
5067 | 1322 |
contentsAsStringWithTabs |
1323 |
"return the contents as a String (i.e. without emphasis) |
|
1324 |
and with leading spaces replaced by tab characters |
|
1325 |
(i.e. as would be written to a file)" |
|
1326 |
||
1327 |
list isNil ifTrue:[^ '']. |
|
1328 |
self removeTrailingBlankLines. |
|
1329 |
^ (list collect:[:each | |
|
1330 |
each isNil |
|
1331 |
ifTrue:[''] |
|
1332 |
ifFalse:[each string withTabs] |
|
1333 |
]) asStringWithCRs |
|
1334 |
! |
|
1335 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1336 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1337 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1338 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1339 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1340 |
^ cursorCol |
125 | 1341 |
! |
1342 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1343 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1344 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1345 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1346 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1347 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1348 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1349 |
cursorLine |
3160 | 1350 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1351 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1352 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1353 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1354 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1355 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1356 |
cursorLineHolder |
3160 | 1357 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1358 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1359 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1360 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1361 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1362 |
|
4713 | 1363 |
lineStringBeforeCursor |
1364 |
"return the line's string before the cursor. |
|
1365 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1366 |
||
1367 |
|line| |
|
1368 |
||
1369 |
line := ((self at:cursorLine) ? '') string. |
|
1370 |
line size < (cursorCol-1) ifTrue:[ |
|
1371 |
^ line paddedTo:(cursorCol-1) |
|
1372 |
]. |
|
1373 |
^ line copyTo:(cursorCol-1) |
|
1374 |
! |
|
1375 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1376 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1377 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1378 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1379 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1380 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1381 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1382 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1383 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1384 |
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
|
1385 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1386 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1387 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1388 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1389 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1390 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1391 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1392 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1393 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1394 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1395 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1396 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1397 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1398 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1399 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1400 |
^ 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
|
1401 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1402 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1403 |
"/ 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
|
1404 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1405 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1406 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1407 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1408 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1409 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1410 |
undoSupport resetHistories. |
2955 | 1411 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1412 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1413 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1414 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1415 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1416 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1417 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1418 |
|
4609 | 1419 |
!EditTextView methodsFor:'accessing-dimensions'! |
1420 |
||
1421 |
xOfCursor |
|
4728 | 1422 |
|point| |
1423 |
||
1424 |
cursorVisibleLine isNil ifTrue:[ |
|
1425 |
"/ take the end of the selection, if any |
|
1426 |
(selectionStartLine notNil |
|
1427 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1428 |
ifTrue:[ |
|
1429 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1430 |
]. |
|
1431 |
||
1432 |
"/ point := device |
|
1433 |
"/ translatePoint:(device pointerPosition) |
|
1434 |
"/ fromView:nil |
|
1435 |
"/ toView:self. |
|
1436 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1437 |
"/ ^ point x |
|
1438 |
"/ ]. |
|
1439 |
"/ ^ 0 |
|
1440 |
^ nil |
|
1441 |
]. |
|
4609 | 1442 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1443 |
||
1444 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1445 |
! ! |
|
4590 | 1446 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1447 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1448 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1449 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1450 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1451 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1452 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1453 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1454 |
wasOn := self hideCursor. |
4940 | 1455 |
cursorFgColor := color1 onDevice:self graphicsDevice. |
1456 |
cursorBgColor := color2 onDevice:self graphicsDevice. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1457 |
wasOn ifTrue:[self showCursor] |
1333 | 1458 |
! |
1459 |
||
1899 | 1460 |
cursorType |
1461 |
"return the style of the text cursor. |
|
4721 | 1462 |
Currently, supported are: #none |
1463 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1464 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1465 |
|
1466 |
^ cursorType |
|
1467 |
||
1468 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1469 |
! |
|
1470 |
||
1333 | 1471 |
cursorType:aCursorTypeSymbol |
1472 |
"set the style of the text cursor. |
|
4721 | 1473 |
Currently, supported are: #none |
1474 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1475 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1476 |
|
1334 | 1477 |
cursorType := aCursorTypeSymbol. |
1333 | 1478 |
|
1479 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1480 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1481 |
! |
1482 |
||
1899 | 1483 |
cursorTypeNoFocus |
1484 |
"return the style of the text cursor when the view has no focus. |
|
1485 |
If left unspecified, this is the same as the regular cursorType." |
|
1486 |
||
1487 |
^ cursorTypeNoFocus |
|
1488 |
||
1489 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1490 |
! |
|
1491 |
||
1334 | 1492 |
cursorTypeNoFocus:aCursorTypeSymbol |
1493 |
"set the style of the text cursor when the view has no focus. |
|
1494 |
If left unspecified, this is the same as the regular cursorType." |
|
1495 |
||
1496 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1497 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1498 |
|
4048 | 1499 |
!EditTextView methodsFor:'accessing-replace'! |
1500 |
||
4746 | 1501 |
lastReplacementInfo |
1502 |
^ lastReplacementInfo |
|
1503 |
! |
|
1504 |
||
4048 | 1505 |
lastStringToReplace: aString |
4818 | 1506 |
! |
1507 |
||
1508 |
previousReplacements |
|
1509 |
"accessor for the code completion" |
|
1510 |
||
1511 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1512 |
! ! |
1513 |
||
2119 | 1514 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1515 |
|
125 | 1516 |
accept |
1517 |
"accept the current contents by executing the accept-action and/or |
|
1518 |
changeMessage." |
|
1519 |
||
1108 | 1520 |
acceptEnabled == false ifTrue:[ |
3945 | 1521 |
self beep. |
1522 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1523 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1524 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1525 |
^ self |
1108 | 1526 |
]. |
1527 |
||
125 | 1528 |
lockUpdates := true. |
1013 | 1529 |
|
1530 |
"/ |
|
1531 |
"/ ST-80 way of doing it |
|
1532 |
"/ |
|
1533 |
model notNil ifTrue:[ |
|
4142 | 1534 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
3945 | 1535 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1536 |
]. |
1537 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1538 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1539 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1540 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1541 |
"/ 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
|
1542 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1543 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1544 |
acceptAction notNil ifTrue:[ |
3945 | 1545 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1546 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1547 |
|
125 | 1548 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1549 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1550 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1551 |
! |
1552 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1553 |
argForChangeMessage |
597 | 1554 |
"return the argument to be passed with the change notification. |
1555 |
Defined as separate method for easier subclassability." |
|
1556 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1557 |
^ self contents |
597 | 1558 |
|
1559 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1560 |
! |
1561 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1562 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1563 |
"get my contents from the model. |
597 | 1564 |
Redefined to ignore updates resulting from my own changes |
1565 |
(i.e. if lockUpdates is true)." |
|
121 | 1566 |
|
1567 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1568 |
ignore updates from my own change |
121 | 1569 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1570 |
lockUpdates ifTrue:[ |
4823 | 1571 |
lockUpdates := false. |
1572 |
^ self |
|
121 | 1573 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1574 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1575 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1576 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1577 |
"/ validate the cursorLine |
3160 | 1578 |
(cursorLine notNil |
2310 | 1579 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1580 |
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
|
1581 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1582 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1583 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1584 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1585 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1586 |
acceptChannel value == true ifTrue:[ |
1587 |
self accept. |
|
1588 |
]. |
|
1589 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1590 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1591 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1592 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1593 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1594 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1595 |
! ! |
1596 |
||
1597 |
!EditTextView methodsFor:'cursor handling'! |
|
1598 |
||
4820 | 1599 |
basicCursorReturn |
1600 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1601 |
||
1602 |
|wasOn| |
|
1603 |
||
1604 |
self checkForExistingLine:(cursorLine + 1). |
|
1605 |
cursorVisibleLine notNil ifTrue:[ |
|
1606 |
nFullLinesShown notNil ifTrue:[ |
|
1607 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1608 |
] |
|
1609 |
]. |
|
1610 |
||
1611 |
wasOn := self hideCursor. |
|
1612 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1613 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1614 |
||
1615 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1616 |
! |
|
1617 |
||
2406 | 1618 |
characterPositionOfCursor |
1619 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1620 |
! |
|
1621 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1622 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1624 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1625 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1626 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1627 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1628 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1629 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1630 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1631 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1632 |
|
2822 | 1633 |
(cursorCol == newCol) ifTrue:[^ self]. |
1634 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1635 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1636 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1637 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1638 |
|
1639 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1640 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1641 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1642 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1643 |
"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
|
1644 |
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
|
1645 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1646 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1647 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1648 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1649 |
|
2707 | 1650 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1651 |
cursorLine > list size ifTrue:[ |
4595 | 1652 |
wasOn := self hideCursor. |
1653 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1654 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1655 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1656 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1657 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1658 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1659 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1660 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1661 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1662 |
"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
|
1663 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1664 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
|
4595 | 1666 |
(nL := cursorLine) isNil ifTrue:[ |
1667 |
nL := firstLineShown |
|
1668 |
]. |
|
1669 |
||
1670 |
self st80EditMode ifTrue:[ |
|
1671 |
nL == list size ifTrue:[ |
|
1672 |
wasOn := self hideCursor. |
|
1673 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1674 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1675 |
self beep. |
|
1676 |
^ self. |
|
1677 |
] |
|
1678 |
]. |
|
1679 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1680 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1681 |
wasOn := self hideCursor. |
1682 |
nv := cursorVisibleLine + n - 1. |
|
1683 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1684 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1685 |
]. |
|
1686 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1687 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1688 |
] ifFalse:[ |
4595 | 1689 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1690 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1691 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1692 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1693 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1694 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1695 |
|
121 | 1696 |
cursorHome |
597 | 1697 |
"scroll to top AND move cursor to first line of text." |
121 | 1698 |
|
674 | 1699 |
self cursorLine:1 col:1 |
1700 |
||
1701 |
"/ |wasOn| |
|
1702 |
"/ |
|
1703 |
"/ wasOn := self hideCursor. |
|
1704 |
"/ self scrollToTop. |
|
1705 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1706 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1707 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1708 |
||
1709 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1710 |
! |
1711 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1712 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1713 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1714 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1715 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1716 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1717 |
] ifFalse:[ |
4823 | 1718 |
cursorLine ~~ 1 ifTrue:[ |
1719 |
self st80EditMode ifTrue:[ |
|
1720 |
self cursorUp. |
|
1721 |
self cursorToEndOfLine. |
|
1722 |
] |
|
1723 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1724 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1725 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1726 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1727 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1728 |
|
4126 | 1729 |
cursorLeft:n |
1730 |
"move cursor to left" |
|
1731 |
||
1732 |
n timesRepeat:[ |
|
1733 |
self cursorLeft |
|
1734 |
]. |
|
1735 |
! |
|
1736 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1737 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1738 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1739 |
|
5056 | 1740 |
self cursorLine:line col:col makeVisible:true |
1741 |
! |
|
1742 |
||
1743 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1744 |
"this positions onto physical - not visible - line" |
|
1745 |
||
676 | 1746 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1747 |
|
2822 | 1748 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1749 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1751 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1752 |
|
672 | 1753 |
(col < 1) ifTrue:[ |
4823 | 1754 |
newCol := 1 |
672 | 1755 |
] ifFalse:[ |
4823 | 1756 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1757 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1758 |
self st80EditMode ifTrue:[ |
4823 | 1759 |
(cursorLine == list size |
1760 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1761 |
newCol := (self listAt:(list size)) size + 1. |
|
1762 |
] |
|
1419 | 1763 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1764 |
self setValidatedCursorCol:newCol. |
5056 | 1765 |
makeVisibleBoolean ifTrue:[ |
1766 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1767 |
] ifFalse:[ |
|
1768 |
wasOn ifTrue:[self showCursor] |
|
1769 |
]. |
|
672 | 1770 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1771 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1772 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1773 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1774 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1775 |
"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
|
1776 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1777 |
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
|
1778 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1779 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1780 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1781 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1782 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1783 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1784 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1785 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1786 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1787 |
"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
|
1788 |
|
4820 | 1789 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1790 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1792 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1793 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1794 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1795 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1796 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1797 |
self st80EditMode ifTrue:[ |
4823 | 1798 |
l := (self listAt:cursorLine). |
1799 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1800 |
cursorLine < list size ifTrue:[ |
|
1801 |
self cursorReturn. |
|
1802 |
]. |
|
1803 |
^ self |
|
1804 |
] |
|
3160 | 1805 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1806 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1807 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1808 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1809 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1810 |
|
4126 | 1811 |
cursorRight:n |
1812 |
"move cursor to right" |
|
1813 |
||
1814 |
n timesRepeat:[ |
|
1815 |
self cursorRight |
|
1816 |
]. |
|
1817 |
! |
|
1818 |
||
1833 | 1819 |
cursorShown:aBoolean |
1820 |
"change cursor visibility |
|
1821 |
return true if cursor was visible before." |
|
1822 |
||
1823 |
|oldState| |
|
1824 |
||
4494 | 1825 |
aBoolean == cursorShown ifTrue:[ |
1826 |
^ cursorShown |
|
1827 |
]. |
|
1833 | 1828 |
oldState := cursorShown. |
1829 |
||
1830 |
aBoolean ifTrue:[ |
|
4494 | 1831 |
self drawCursor. |
1833 | 1832 |
] ifFalse:[ |
4494 | 1833 |
(cursorShown and:[shown]) ifTrue: [ |
1834 |
self undrawCursor. |
|
1835 |
]. |
|
1833 | 1836 |
]. |
1837 |
cursorShown := aBoolean. |
|
1838 |
||
1839 |
^ oldState |
|
1840 |
||
1841 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1842 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1843 |
! |
|
1844 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1846 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1847 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1848 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1850 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1851 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1852 |
"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
|
1853 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1854 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1855 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1856 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1857 |
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
|
1858 |
cursorCol > textStart ifTrue:[ |
4823 | 1859 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1860 |
] ifFalse:[ |
4823 | 1861 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1862 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1863 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1864 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1865 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1866 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1867 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1868 |
"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
|
1869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1870 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1871 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1872 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1873 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1874 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1875 |
(newTop < 1) ifTrue:[ |
4823 | 1876 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1877 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1878 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1879 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1880 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1881 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1882 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1883 |
|
674 | 1884 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1885 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1886 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1887 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1888 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1889 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1890 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1891 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1892 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1893 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1894 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1895 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1896 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1897 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1898 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1899 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1900 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1901 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1902 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1903 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1904 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1905 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1906 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1907 |
cursorLine >= lineNr ifTrue:[ |
4823 | 1908 |
line := self listAt:cursorLine. |
1909 |
(line isEmptyOrNil) ifTrue:[ |
|
1910 |
^ self |
|
1911 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1912 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1913 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1914 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1915 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1916 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1917 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1918 |
(newTop < 1) ifTrue:[ |
4823 | 1919 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1920 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1921 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1922 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1923 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1924 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1925 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1926 |
|
674 | 1927 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1928 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1929 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1930 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1931 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1932 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1933 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1934 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1935 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1936 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1937 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1938 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1939 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1940 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1941 |
cursorToEndOfText |
4288 | 1942 |
"move cursor to the end of the text (behind the last character in last line)" |
1943 |
||
1944 |
|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
|
1945 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1946 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1947 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1948 |
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
|
1949 |
(newTop < 1) ifTrue:[ |
4288 | 1950 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1951 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1952 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1953 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1954 |
self setValidatedCursorLine:list size. |
4288 | 1955 |
lastLineLength := (self listAt:cursorLine) size. |
1956 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
1957 |
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
|
1958 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1959 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 1960 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
1961 |
"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
|
1962 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1963 |
|
3310 | 1964 |
cursorToEndOfWord |
1965 |
"move the cursor to the end of the word" |
|
1966 |
||
1967 |
(cursorLine > list size) ifTrue:[^ self]. |
|
1968 |
||
1969 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 1970 |
:beginLine :beginCol :endLine :endCol :style | |
1971 |
||
1972 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 1973 |
] |
1974 |
||
1975 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
1976 |
! |
|
1977 |
||
131 | 1978 |
cursorToFirstVisibleLine |
1979 |
"place cursor into the first visible line; do not scroll." |
|
1980 |
||
1981 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1982 |
! |
|
1983 |
||
1984 |
cursorToLastVisibleLine |
|
1985 |
"place cursor into the first visible line; do not scroll." |
|
1986 |
||
1987 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1988 |
! |
|
1989 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1990 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1992 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1993 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1996 |
|
3890 | 1997 |
self |
4707 | 1998 |
wordAtLine:cursorLine col:cursorCol |
1999 |
do:[ |
|
3890 | 2000 |
:beginLine :beginCol :endLine :endCol :style | |
2001 |
||
2002 |
line := endLine. |
|
2003 |
col := endCol + 1. |
|
2004 |
searching := true. |
|
4707 | 2005 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2006 |
self wordAtLine:line col:col do:[ |
2007 |
:beginLine :beginCol :endLine :endCol :style | |
|
2008 |
||
2009 |
(line > list size) ifTrue:[ |
|
2010 |
"break out" |
|
2011 |
searching := false |
|
2012 |
] ifFalse:[ |
|
2013 |
line := endLine. |
|
2014 |
col := endCol + 1. |
|
2015 |
] |
|
2016 |
] |
|
2017 |
]. |
|
2018 |
self cursorLine:line col:col |
|
4707 | 2019 |
] |
121 | 2020 |
! |
2021 |
||
499 | 2022 |
cursorToPreviousWord |
2023 |
"move the cursor to the beginning of this or the previous word" |
|
2024 |
||
2025 |
|col line searching l| |
|
2026 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2027 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2028 |
|
2029 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2030 |
:beginLine :beginCol :endLine :endCol :style | |
2031 |
||
2032 |
line := beginLine. |
|
2033 |
col := beginCol. |
|
2034 |
style == #wordLeft ifTrue:[ |
|
2035 |
col := col + 1 |
|
2036 |
]. |
|
2037 |
||
2038 |
(cursorLine == line |
|
2039 |
and:[cursorCol == col]) ifTrue:[ |
|
2040 |
searching := true. |
|
2041 |
||
2042 |
col > 1 ifTrue:[ |
|
2043 |
col := col - 1. |
|
2044 |
]. |
|
2045 |
||
2046 |
[searching] whileTrue:[ |
|
2047 |
(col == 1) ifTrue:[ |
|
2048 |
line == 1 ifTrue:[ |
|
2049 |
searching := false |
|
2050 |
] ifFalse:[ |
|
2051 |
line := line - 1. |
|
2052 |
l := list at:line. |
|
2053 |
col := l size + 1. |
|
2054 |
] |
|
2055 |
] ifFalse:[ |
|
2056 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2057 |
self wordAtLine:line col:col do:[ |
|
2058 |
:beginLine :beginCol :endLine :endCol :style | |
|
2059 |
||
2060 |
line := beginLine. |
|
2061 |
col := beginCol. |
|
2062 |
style == #wordLeft ifTrue:[ |
|
2063 |
col := col + 1 |
|
2064 |
]. |
|
2065 |
searching := false. |
|
2066 |
] |
|
2067 |
] ifTrue:[ |
|
2068 |
col := col - 1 |
|
2069 |
] |
|
2070 |
] |
|
2071 |
] |
|
2072 |
]. |
|
2073 |
self cursorLine:line col:col |
|
499 | 2074 |
] |
2075 |
||
2076 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2077 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2078 |
! |
|
2079 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2080 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2081 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2082 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2083 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2084 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2086 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2089 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2090 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2091 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2092 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2093 |
"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
|
2094 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2095 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2096 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2097 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2098 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2099 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2100 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2101 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2102 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2103 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2104 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2105 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2106 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2107 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2108 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2109 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2110 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2111 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2112 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2113 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
] |
672 | 2115 |
|
674 | 2116 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2117 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2118 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2120 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2121 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2122 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2123 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2124 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2125 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2126 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2127 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2128 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2129 |
|
676 | 2130 |
newCol := colNr. |
2131 |
(newCol < 1) ifTrue:[ |
|
4823 | 2132 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2134 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2135 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2136 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2137 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2138 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2141 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2142 |
"put cursor to position next to x/y coordinate in view" |
121 | 2143 |
|
2144 |
|line col| |
|
2145 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2147 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2148 |
self cursorVisibleLine:line col:col. |
121 | 2149 |
! |
2150 |
||
2151 |
drawCursor |
|
2152 |
"draw the cursor if shown and cursor is visible. |
|
2153 |
(but not, if there is a selection - to avoid confusion)" |
|
2154 |
||
2155 |
shown ifTrue:[ |
|
4823 | 2156 |
cursorVisibleLine notNil ifTrue:[ |
2157 |
self hasSelection ifFalse:[ |
|
2158 |
self drawCursorCharacter |
|
2159 |
] |
|
2160 |
] |
|
121 | 2161 |
] |
2162 |
! |
|
2163 |
||
2164 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2165 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2166 |
of cursor should be drawn. |
4721 | 2167 |
Currently, supported are: #none, |
2168 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2169 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2170 |
|
2570 | 2171 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2172 |
|
2173 |
self hasSelection ifTrue:[ |
|
4580 | 2174 |
" |
2175 |
hide cursor, if there is a selection |
|
2176 |
" |
|
2177 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2178 |
]. |
2179 |
||
1334 | 2180 |
cursorType == #none ifTrue:[ |
4580 | 2181 |
^ self |
1334 | 2182 |
]. |
2183 |
||
121 | 2184 |
cursorType == #block ifTrue:[ |
4829 | 2185 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2186 |
^ self |
121 | 2187 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2188 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2189 |
y := self yOfVisibleLine:cursorVisibleLine. |
2190 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2191 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2192 |
cursorType == #frame ifTrue:[ |
4580 | 2193 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2194 |
||
2195 |
char := self characterUnderCursor asString. |
|
4829 | 2196 |
self paint:bgColor. |
4889 | 2197 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2198 |
] ifFalse:[ |
4580 | 2199 |
self paint:bgColor. |
2200 |
cursorType == #ibeam ifTrue:[ |
|
2201 |
x1 := x - 1. |
|
2202 |
y2 := y + fontHeight - lineSpacing. |
|
2203 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2204 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2205 |
^ self |
|
2206 |
]. |
|
2207 |
||
2208 |
cursorType == #Ibeam ifTrue:[ |
|
2209 |
x1 := x - 1. |
|
2210 |
y := y + 1. |
|
2211 |
y2 := y + fontHeight - lineSpacing. |
|
2212 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2213 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2214 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2215 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2216 |
^ self |
|
2217 |
]. |
|
2218 |
||
2219 |
y := y + fontHeight - 3. |
|
2220 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2221 |
w := (fontWidth * 2 // 3) max:4. |
|
2222 |
y2 := y + w + (w//2). |
|
2223 |
] ifFalse:[ |
|
2224 |
w := (fontWidth // 2) max:4. |
|
2225 |
y2 := y + w. |
|
2226 |
]. |
|
2227 |
x1 := x - w. |
|
2228 |
x2 := x + w. |
|
2229 |
||
2230 |
oldClip := self clippingRectangleOrNil. |
|
2231 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2232 |
||
2233 |
cursorType == #caret ifTrue:[ |
|
2234 |
self lineWidth:2. |
|
2235 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2236 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2237 |
] ifFalse:[ |
|
2238 |
"anything else: solidCaret" |
|
2239 |
||
2240 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2241 |
with:(x @ y) |
|
2242 |
with:(x2 @ y2)) |
|
2243 |
]. |
|
2244 |
||
2245 |
self clippingRectangle:oldClip |
|
121 | 2246 |
]. |
133 | 2247 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2248 |
|
2088 | 2249 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2250 |
! |
2251 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2252 |
drawCursorCharacter |
3160 | 2253 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2254 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2256 |
|
3160 | 2257 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2258 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2259 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2260 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
] ifFalse:[ |
4823 | 2262 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2263 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2264 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2265 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2266 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2267 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2268 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2269 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2270 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2271 |
self hasSelection ifTrue:[ |
5260 | 2272 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2273 |
]. |
2274 |
cursorType == #none ifTrue:[ |
|
4823 | 2275 |
^ self undrawCursor |
259
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 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2278 |
|
2279 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
drawNoFocusCursor |
3160 | 2283 |
"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
|
2284 |
|
1334 | 2285 |
|cType| |
2286 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2287 |
self hasSelection ifTrue:[ |
4823 | 2288 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2289 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2290 |
|
1334 | 2291 |
cType := cursorTypeNoFocus ? cursorType. |
2292 |
cType == #none ifTrue:[ |
|
4823 | 2293 |
^ self undrawCursor |
1334 | 2294 |
]. |
2295 |
||
2296 |
cType == #block ifTrue:[ |
|
4823 | 2297 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2299 |
|
1334 | 2300 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2301 |
||
2302 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2304 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2306 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2307 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2308 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2309 |
self makeLineVisible:aLineNumber. |
2951 | 2310 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2311 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2312 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2313 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2314 |
hideCursor |
1833 | 2315 |
"make cursor invisible if currently invisible" |
2316 |
||
2317 |
^ self cursorShown:false |
|
2318 |
||
2319 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2320 |
! |
2321 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2322 |
makeCursorVisible |
3160 | 2323 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2324 |
(i.e. to have cursorLine in visible area)" |
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 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2328 |
cursorLine notNil ifTrue:[ |
4823 | 2329 |
line := cursorLine. |
2330 |
col := cursorCol. |
|
2331 |
" |
|
2332 |
if there is a selection, its better to |
|
2333 |
have its start being visible, instead of the end |
|
2334 |
" |
|
2335 |
(selectionStartLine notNil |
|
2336 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2337 |
expandingTop ~~ false ifTrue:[ |
|
2338 |
line := selectionStartLine. |
|
2339 |
col := selectionStartCol. |
|
2340 |
] ifFalse:[ |
|
2341 |
line := selectionEndLine. |
|
2342 |
col := selectionEndCol |
|
2343 |
] |
|
2344 |
]. |
|
2345 |
self makeLineVisible:line. |
|
2346 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2347 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2348 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2349 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2350 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2351 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2352 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2353 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2354 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2355 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2356 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2357 |
flag ifTrue:[self showCursor] |
121 | 2358 |
! |
2359 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2360 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2361 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2362 |
|
2815 | 2363 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2364 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2365 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2366 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2367 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2368 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2369 |
|
3303 | 2370 |
"/ self assert:(lineNr notNil). |
2371 |
||
2372 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2373 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2374 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2375 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2376 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2377 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2378 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2379 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2380 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2381 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2382 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2383 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2384 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2385 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2386 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2387 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2388 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2389 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2390 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2391 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2392 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2393 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2394 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2395 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2396 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2397 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2398 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2399 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2400 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2401 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2402 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2403 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2404 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2405 |
|
1833 | 2406 |
^ self cursorShown:true |
2407 |
||
2408 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2409 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2410 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2411 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2412 |
"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
|
2413 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2414 |
|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
|
2415 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2416 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2417 |
prevCol := cursorCol - 1. |
2418 |
||
2419 |
"/ if there is any italic stuff in the cursor line, |
|
2420 |
"/ redraw it completely (because characters overlap). |
|
2421 |
cursorCol > 1 ifTrue:[ |
|
2422 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2423 |
line hasChangeOfEmphasis ifTrue:[ |
|
2424 |
line size >= (cursorCol-1) ifTrue:[ |
|
2425 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2426 |
line size >= (cursorCol) ifTrue:[ |
|
2427 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2428 |
line size >= (cursorCol+1) ifTrue:[ |
|
2429 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2430 |
]. |
|
2431 |
]. |
|
2432 |
]. |
|
2433 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2434 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2435 |
] |
|
2436 |
] |
|
2437 |
] |
|
2438 |
]. |
|
2439 |
||
2440 |
((cursorType == #caret) |
|
2441 |
or:[cursorType == #solidCaret |
|
2442 |
or:[cursorType == #bigSolidCaret |
|
2443 |
or:[cursorType == #bigCaret |
|
2444 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2445 |
"caret-cursor touches 4 characters" |
|
2446 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2447 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2448 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2449 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2450 |
] ifFalse:[ |
|
2451 |
"care for left margin" |
|
2452 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2453 |
]. |
|
2454 |
^ self |
|
2455 |
]. |
|
2456 |
||
2457 |
cursorType == #ibeam ifTrue:[ |
|
2458 |
"ibeam-cursor touches 2 characters" |
|
2459 |
cursorCol > 1 ifTrue:[ |
|
2460 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2461 |
] ifFalse:[ |
|
2462 |
"care for left margin" |
|
2463 |
super redrawVisibleLine:cursorVisibleLine. |
|
2464 |
]. |
|
2465 |
^ self |
|
2466 |
]. |
|
2467 |
||
2468 |
"block cursor is simple - just one character under cursor" |
|
2469 |
||
2470 |
"/ however, if italic characters are involved, we must care |
|
2471 |
"/ for the chars before/after the cursor. |
|
2472 |
"/ We redraw the part of the previous character which got |
|
2473 |
"/ detroyed by the block cursor. |
|
2474 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2475 |
||
2476 |
line := self visibleAt:cursorVisibleLine. |
|
2477 |
(line notNil and:[line isText]) ifTrue:[ |
|
2478 |
cursorCol > 1 ifTrue:[ |
|
2479 |
oldClip := self clippingRectangleOrNil. |
|
2480 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2481 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2482 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2483 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2484 |
self clippingRectangle:oldClip. |
|
2485 |
^ self. |
|
2486 |
]. |
|
2487 |
]. |
|
2488 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2489 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2490 |
|
2088 | 2491 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2492 |
! |
2493 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2494 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2495 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2496 |
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
|
2497 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2498 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2499 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2500 |
|
672 | 2501 |
validateCursorCol:col inLine:line |
674 | 2502 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2503 |
Here, no limits are enforced (and col is returned), |
2504 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2505 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2506 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2507 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2508 |
|
1419 | 2509 |
"/ in ST80 mode, |
2707 | 2510 |
"/ the cursor may not be positioned beyond the |
2511 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2512 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2513 |
self st80EditMode ifTrue:[ |
4823 | 2514 |
l := (self listAt:line). |
2515 |
max := l size + 1. |
|
2516 |
col > max ifTrue:[ |
|
2517 |
^ max |
|
2518 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2519 |
]. |
672 | 2520 |
^ col |
2521 |
||
1419 | 2522 |
"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
|
2523 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2524 |
! |
2525 |
||
2526 |
validateCursorLine:line |
|
2527 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2528 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2529 |
redefined in views which dont like the cursor to be positioned |
2530 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2531 |
skip reserved regions" |
|
2532 |
||
1419 | 2533 |
"/ |
2534 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2535 |
"/ beyond the last line |
1419 | 2536 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2537 |
self st80EditMode ifTrue:[ |
4823 | 2538 |
^ (line min:(list size)) max:1 |
1419 | 2539 |
]. |
674 | 2540 |
^ line |
2541 |
||
1419 | 2542 |
"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
|
2543 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2544 |
! |
2545 |
||
121 | 2546 |
withCursorOffDo:aBlock |
2547 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2548 |
||
2549 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2550 |
^ aBlock value |
121 | 2551 |
]. |
2552 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2553 |
aBlock ensure:[ |
4823 | 2554 |
self showCursor |
121 | 2555 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2556 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2557 |
|
2589 | 2558 |
!EditTextView methodsFor:'drag & drop'! |
2559 |
||
2560 |
allowDrop:aBoolean |
|
3236 | 2561 |
"enable/disable drop support" |
2562 |
||
2589 | 2563 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2564 |
dropTarget := nil. |
2589 | 2565 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2566 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2567 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2568 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2569 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2570 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2571 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2572 |
] |
3236 | 2573 |
]. |
2574 |
! |
|
2575 |
||
3412 | 2576 |
canDrop:aDropContext |
2577 |
"public from d&d. |
|
2578 |
I accept textObjects and fileObjects only." |
|
2579 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2580 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2581 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2582 |
^ self canDropObjects:aDropContext dropObjects |
|
2583 |
||
2584 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2585 |
! |
|
2586 |
||
2587 |
canDropObjects:aCollectionOfDropObjects |
|
2588 |
"public from d&d. |
|
2589 |
I accept textObjects and fileObjects only." |
|
2589 | 2590 |
|
2591 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2592 |
||
3412 | 2593 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2594 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2595 |
||
2596 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2597 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2598 |
! |
|
2599 |
||
2600 |
drop:aDropContext |
|
2601 |
"public from d&d. |
|
2602 |
drop objects (new API)" |
|
2603 |
||
2604 |
self dropObjects:(aDropContext dropObjects) |
|
2605 |
||
2606 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2607 |
! |
|
2608 |
||
2609 |
dropFileObject:aDropObject |
|
2589 | 2610 |
"drop objects |
3236 | 2611 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2612 |
||
4136 | 2613 |
|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
|
2614 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2615 |
pasteWhat := #name. |
3412 | 2616 |
|
2617 |
fn := aDropObject asFilename. |
|
2618 |
(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
|
2619 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2620 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2621 |
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
|
2622 |
pasteWhat := enforcedDropMode. |
3886 | 2623 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2624 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2625 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2626 |
pasteWhat := #name. |
3886 | 2627 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2628 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2629 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2630 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2631 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2632 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2633 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2634 |
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
|
2635 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2636 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2637 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2638 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2639 |
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
|
2640 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2641 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2642 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2643 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2644 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2645 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2646 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2647 |
] |
3886 | 2648 |
] |
2649 |
]. |
|
2650 |
]. |
|
2651 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2652 |
pasteWhat == #name ifTrue:[ |
3886 | 2653 |
text := fn pathName |
2654 |
] ifFalse:[ |
|
2655 |
self withWaitCursorDo:[ |
|
5063 | 2656 |
text := fn contentsAsString |
4136 | 2657 |
]. |
2658 |
(app := self application) notNil ifTrue:[ |
|
2659 |
app droppedFile:fn in:self |
|
2660 |
]. |
|
3886 | 2661 |
]. |
2662 |
||
3799 | 2663 |
self |
2664 |
undoablePaste:text |
|
2665 |
info:'Drop File'. |
|
3412 | 2666 |
|
2667 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2668 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2669 |
! |
2670 |
||
2671 |
dropObject:aDropObject |
|
2672 |
"drop objects |
|
2673 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2674 |
||
3415 | 2675 |
|text| |
2676 |
||
3412 | 2677 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2678 |
self dropFileObject:aDropObject |
3412 | 2679 |
] ifFalse:[ |
3799 | 2680 |
aDropObject isTextObject ifTrue:[ |
2681 |
text := aDropObject theObject. |
|
2682 |
text isStringCollection ifTrue:[ |
|
2683 |
text := text asStringWithoutFinalCR |
|
2684 |
]. |
|
2685 |
] ifFalse:[ |
|
2686 |
text := aDropObject theObject asString |
|
2687 |
]. |
|
2688 |
self |
|
2689 |
undoablePaste:text |
|
2690 |
info:'Drop'. |
|
3412 | 2691 |
]. |
2692 |
||
2693 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2694 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2695 |
! |
2696 |
||
2697 |
dropObjects:aCollectionOfDropObjects |
|
2698 |
"public from d&d. |
|
2699 |
drop objects (old API)" |
|
2700 |
||
3868 | 2701 |
aCollectionOfDropObjects do:[:el | |
2702 |
self dropObject:el |
|
3412 | 2703 |
]. |
2704 |
||
2705 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2706 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2707 |
! ! |
2708 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2709 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2710 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2711 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2712 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2713 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2714 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2715 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2716 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2717 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2718 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2719 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2720 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2721 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2722 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2723 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2724 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2725 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2726 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2727 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2728 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2729 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2730 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2731 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2732 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2733 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2734 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2735 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2736 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2737 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2738 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2739 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2740 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2741 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2742 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2743 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2744 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2745 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2746 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2747 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2748 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2749 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2750 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2751 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2752 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2753 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2754 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2755 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2756 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2757 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2758 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2759 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2760 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2761 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2762 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2763 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2764 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2765 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2766 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2767 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2768 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2769 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2770 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2771 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2772 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2773 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2774 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2775 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2776 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2777 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2778 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2779 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2780 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2781 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2782 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2783 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2784 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2785 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2786 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2787 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2788 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2789 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2790 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2791 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2792 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2793 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2794 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2795 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2796 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2797 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2798 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2799 |
line at:col put:ch. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2800 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2801 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2802 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2803 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2804 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2805 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2806 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2807 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2808 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2809 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2810 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2811 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2812 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2813 |
"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
|
2814 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2815 |
selectionStartLine notNil ifTrue:[ |
4823 | 2816 |
self setClipboardText:(self selection). |
2817 |
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
|
2818 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2819 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2820 |
"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
|
2821 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2822 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2823 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2824 |
"delete single character under cursor; does not merge lines" |
121 | 2825 |
|
2826 |
|wasOn| |
|
2827 |
||
2828 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2829 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2830 |
wasOn ifTrue:[self showCursor] |
2831 |
! |
|
2832 |
||
827 | 2833 |
deleteCharAtLine:lineNr col:colNr |
2834 |
"delete a single character at colNr in line lineNr" |
|
2835 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2836 |
self st80EditMode ifTrue:[ |
4823 | 2837 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2838 |
| wasOn | |
|
2839 |
wasOn := self hideCursor. |
|
2840 |
self |
|
2841 |
cursorReturn; |
|
2842 |
cursorCol:1; |
|
2843 |
deleteCharBeforeCursor. |
|
2844 |
wasOn ifTrue:[ self showCursor]. |
|
2845 |
^ self. |
|
2846 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2847 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2848 |
|
827 | 2849 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2850 |
! |
|
2851 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2852 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2853 |
"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
|
2854 |
|
4592 | 2855 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2856 |
|
2857 |
wasOn := self hideCursor. |
|
4814 | 2858 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 2859 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 2860 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 2861 |
ln size < prevTab ifTrue:[ |
2862 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2863 |
]. |
|
2864 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2865 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2866 |
cursorCol > prevTab ifTrue:[ |
|
2867 |
self st80EditMode ifTrue:[ |
|
2868 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2869 |
"/ not allow a cursor position beyond the end of line, |
|
2870 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2871 |
originalLine size < prevTab ifTrue:[ |
|
4771 | 2872 |
self basicListAt:cursorLine put:ln |
4592 | 2873 |
] |
2874 |
]. |
|
2875 |
self cursorLine:cursorLine col:prevTab. |
|
2876 |
wasOn ifTrue:[ self showCursor ]. |
|
2877 |
^ self |
|
2878 |
]. |
|
2879 |
] ifFalse:[ |
|
2880 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2881 |
self cursorLine:cursorLine col:prevTab. |
|
2882 |
wasOn ifTrue:[ self showCursor ]. |
|
2883 |
^ self. |
|
2884 |
] |
|
2885 |
]. |
|
827 | 2886 |
]. |
2887 |
||
2491 | 2888 |
"/ (autoIndent |
2889 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2890 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2891 |
"/ ifTrue:[ |
2892 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2893 |
"/ |
|
2894 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2895 |
"/ ln := list at:cursorLine. |
|
2896 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2897 |
"/ soCol := 1 |
|
2898 |
"/ ] |
|
2899 |
"/ ] |
|
2900 |
"/ ] ifFalse:[ |
|
4592 | 2901 |
soCol := 1. |
2491 | 2902 |
"/ ]. |
2903 |
||
1419 | 2904 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2905 |
" |
2906 |
somewhere in the middle of a line |
|
2907 |
" |
|
2908 |
self cursorLeft. |
|
2909 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2910 |
] ifFalse:[ |
4592 | 2911 |
" |
2912 |
at begin of line - merge with previous line; |
|
2913 |
except for the very first line. |
|
2914 |
" |
|
2915 |
(cursorLine == 1) ifFalse:[ |
|
2916 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2917 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2918 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2919 |
"/ we are beyond the end of the text. |
|
2920 |
"/ move the cursor to the previous line. |
|
2921 |
self cursorLine:lineNrAboveCursor col:1. |
|
2922 |
] ifFalse:[ |
|
2923 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2924 |
] |
|
2925 |
] |
|
2926 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2927 |
]. |
827 | 2928 |
wasOn ifTrue:[ self showCursor ] |
2929 |
||
1419 | 2930 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2931 |
! |
2932 |
||
2933 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2934 |
"delete characters from colNr up to the end in line lineNr" |
|
2935 |
||
2936 |
|line| |
|
2937 |
||
2938 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 2939 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2940 |
] |
2941 |
||
2942 |
! |
|
2943 |
||
4458 | 2944 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2945 |
"delete characters from startCol to endCol in line lineNr" |
|
2946 |
||
2947 |
|deleted| |
|
2948 |
||
2949 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
2950 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
2951 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
2952 |
! |
|
2953 |
||
827 | 2954 |
deleteCharsAtLine:lineNr toCol:colNr |
2955 |
"delete characters from start up to colNr in line lineNr" |
|
2956 |
||
2957 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2958 |
||
2959 |
||
121 | 2960 |
! |
2961 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2962 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2963 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2964 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2965 |
self deleteLine:cursorLine |
121 | 2966 |
! |
2967 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2968 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2969 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2970 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2971 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2972 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2973 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2974 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2975 |
col1 == 0 ifTrue:[ |
4823 | 2976 |
line1 := line1 - 1. |
2977 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2978 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2979 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2980 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2981 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2982 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2983 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2984 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2985 |
|
2954 | 2986 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2987 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2988 |
joining lines if nescessary" |
|
2989 |
||
2990 |
|line newLine lineSize nMore| |
|
2991 |
||
2992 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2993 |
list isNil ifTrue:[^ self]. |
|
2994 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2995 |
||
2996 |
(startLine == endLine) ifTrue:[ |
|
4225 | 2997 |
"/ delete chars within a line |
2998 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2999 |
^ self |
|
2954 | 3000 |
]. |
3001 |
||
3002 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3003 |
"/ delete full lines only |
3004 |
endLine > startLine ifTrue:[ |
|
3005 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3006 |
]. |
|
3007 |
^ self |
|
2954 | 3008 |
]. |
3009 |
||
3010 |
"/ delete right rest of 1st line |
|
4786 | 3011 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3012 |
|
3013 |
"/ delete the inner lines ... |
|
3014 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3015 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3016 |
]. |
3017 |
||
3018 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3019 |
"/ delete the left rest of the last line |
3020 |
||
3021 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3022 |
||
3023 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3024 |
startLine <= list size ifTrue:[ |
|
3025 |
line := list at:startLine. |
|
3026 |
lineSize := line size. |
|
3027 |
(startCol > lineSize) ifTrue:[ |
|
3028 |
newLine := line. |
|
3029 |
line isNil ifTrue:[ |
|
3030 |
newLine := String new:(startCol - 1) |
|
3031 |
] ifFalse:[ |
|
3032 |
nMore := startCol - 1 - lineSize. |
|
3033 |
nMore > 0 ifTrue:[ |
|
3034 |
newLine := line , (line species new:nMore) |
|
3035 |
] |
|
3036 |
]. |
|
3037 |
newLine ~~ line ifTrue:[ |
|
4771 | 3038 |
self basicListAt:startLine put:newLine. |
4225 | 3039 |
]. |
3040 |
"/ TODO: remember old maxwidth of linerange, |
|
3041 |
"/ only clear widthOfWidestLine, if this max |
|
3042 |
"/ length was (one of) the longest. |
|
3043 |
"/ avoids slow delete with huge texts. |
|
3044 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3045 |
self textChanged. |
|
3046 |
] |
|
3047 |
] |
|
2954 | 3048 |
]. |
3049 |
||
3050 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3051 |
self mergeLine:startLine removeBlanks:false |
|
3052 |
||
4225 | 3053 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3054 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3055 |
! |
3056 |
||
4458 | 3057 |
deleteFromLine:startLineNr toLine:endLineNr |
3058 |
"delete some lines" |
|
3059 |
||
3060 |
|deleted| |
|
3061 |
||
3062 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3063 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3064 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3065 |
! |
|
3066 |
||
827 | 3067 |
deleteLine:lineNr |
3068 |
"delete line" |
|
3069 |
||
3070 |
self deleteFromLine:lineNr toLine:lineNr |
|
3071 |
||
3072 |
||
3073 |
! |
|
3074 |
||
4458 | 3075 |
deleteLineWithoutRedraw:lineNr |
3076 |
"delete line - no redraw; |
|
3077 |
return true, if something was really deleted" |
|
3078 |
||
3079 |
|deleted ret| |
|
3080 |
||
3081 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3082 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3083 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3084 |
^ ret. |
|
3085 |
! |
|
3086 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3087 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3088 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3089 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3090 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3091 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3092 |
|
4771 | 3093 |
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
|
3094 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3095 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3096 |
(endLine > list size) ifTrue:[ |
4771 | 3097 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3098 |
] ifFalse:[ |
4771 | 3099 |
lastLine := endLine |
3100 |
]. |
|
3101 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3102 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3103 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3104 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3105 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3106 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3107 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3108 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3109 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3110 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3111 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3112 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3113 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3114 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3116 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3117 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3118 |
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
|
3119 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3120 |
selectionStartLine notNil ifTrue:[ |
4823 | 3121 |
wasOn := self hideCursor. |
3122 |
||
3123 |
startLine := selectionStartLine. |
|
3124 |
startCol := selectionStartCol. |
|
3125 |
endLine := selectionEndLine. |
|
3126 |
endCol := selectionEndCol. |
|
3127 |
self unselectWithoutRedraw. |
|
3128 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3129 |
self setCursorLine:startLine col:startCol. |
|
3130 |
||
3131 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3132 |
] |
121 | 3133 |
! |
3134 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3135 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3136 |
"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
|
3137 |
|
2952 | 3138 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3139 |
|
3799 | 3140 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3141 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3142 |
wasOn := self hideCursor. |
3799 | 3143 |
self |
3144 |
undoableDo:[ |
|
3145 |
endCol := cursorCol-1. |
|
3146 |
endLine := cursorLine. |
|
3147 |
self cursorToPreviousWord. |
|
3148 |
beginCol := cursorCol. |
|
3149 |
beginLine := cursorLine. |
|
3150 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3151 |
] |
|
3152 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3153 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3154 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3155 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3156 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3157 |
|
4458 | 3158 |
insert:aCharacter atLine:lineNr col:colNr |
3159 |
"insert a single character at lineNr/colNr; |
|
3160 |
set emphasis to character at current position" |
|
3161 |
||
3162 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3163 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3164 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3165 |
] |
3166 |
! |
|
3167 |
||
121 | 3168 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3169 |
"insert a single character at cursor-position - advance cursor." |
121 | 3170 |
|
3171 |
|wasOn| |
|
3172 |
||
3173 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3174 |
aCharacter == Character tab ifTrue:[ |
4820 | 3175 |
"/ needs special care to advance cursor correctly |
3176 |
self insertTabAtCursor |
|
121 | 3177 |
] ifFalse:[ |
4820 | 3178 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3179 |
aCharacter == (Character cr) ifTrue:[ |
|
3180 |
self basicCursorReturn |
|
3181 |
] ifFalse:[ |
|
3182 |
self cursorRight. |
|
3183 |
]. |
|
121 | 3184 |
]. |
3185 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3186 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3187 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3188 |
! |
3189 |
||
641 | 3190 |
insertLine:aString before:lineNr |
3191 |
"insert the line aString before line lineNr" |
|
3192 |
||
3193 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3194 |
||
3195 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3196 |
! |
|
3197 |
||
155 | 3198 |
insertLines:aStringCollection before:lineNr |
3199 |
"insert a bunch before line lineNr" |
|
3200 |
||
3201 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3202 |
||
3203 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3204 |
! |
|
3205 |
||
4771 | 3206 |
insertLines:someText from:start to:end before:lineNr |
3207 |
"insert a bunch of lines before line lineNr. |
|
3208 |
The cursor position is left unchanged." |
|
3209 |
||
3210 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3211 |
srcY "{ Class: SmallInteger }" |
|
3212 |
dstY "{ Class: SmallInteger }" | |
|
3213 |
||
3214 |
autoIndent ifTrue:[ |
|
3215 |
indent := self leftIndentForLine:lineNr. |
|
3216 |
||
4812 | 3217 |
text := someText |
3218 |
collect:[:ln||line| |
|
3219 |
ln notNil ifTrue:[ |
|
3220 |
line := ln withoutLeadingSeparators. |
|
3221 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3222 |
line := (String new:indent), line |
|
3223 |
]. |
|
3224 |
line |
|
3225 |
] ifFalse:[ |
|
3226 |
nil |
|
3227 |
] |
|
3228 |
]. |
|
4771 | 3229 |
] ifFalse:[ |
3230 |
text := someText |
|
3231 |
]. |
|
3232 |
||
3233 |
visLine := self listLineToVisibleLine:lineNr. |
|
3234 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3235 |
self withoutRedrawInsertLines:text |
|
3236 |
from:start to:end |
|
3237 |
before:lineNr. |
|
3238 |
] ifFalse:[ |
|
3239 |
nLines := end - start + 1. |
|
3240 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3241 |
self withoutRedrawInsertLines:text |
|
3242 |
from:start to:end |
|
3243 |
before:lineNr. |
|
3244 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3245 |
] ifFalse:[ |
|
3246 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3247 |
and:(firstLineShown + nLines + nLinesShown). |
|
3248 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3249 |
dstY := srcY + (nLines * fontHeight). |
|
3250 |
||
3251 |
"/ |
|
3252 |
"/ scroll ... |
|
3253 |
"/ |
|
3254 |
" |
|
3255 |
stupid: must catchExpose before inserting new |
|
3256 |
stuff - since catchExpose may perform redraws |
|
3257 |
" |
|
3258 |
self catchExpose. |
|
3259 |
self withoutRedrawInsertLines:text |
|
3260 |
from:start to:end |
|
3261 |
before:lineNr. |
|
3262 |
self |
|
3263 |
copyFrom:self |
|
3264 |
x:textStartLeft y:srcY |
|
3265 |
toX:textStartLeft y:dstY |
|
3266 |
width:w |
|
3267 |
height:(height - dstY) |
|
3268 |
async:true. |
|
3269 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3270 |
self waitForExpose |
|
3271 |
]. |
|
3272 |
]. |
|
3273 |
widthOfWidestLine notNil ifTrue:[ |
|
3274 |
text do:[:line | |
|
3275 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3276 |
] |
|
3277 |
]. |
|
3278 |
self textChanged. |
|
3279 |
||
3280 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3281 |
! |
|
3282 |
||
654 | 3283 |
insertLines:lines withCR:withCr |
3160 | 3284 |
"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
|
3285 |
Cursor is moved behind insertion. |
641 | 3286 |
If withCr is true, append cr after last line" |
3287 |
||
3288 |
|start end nLines wasOn| |
|
3289 |
||
3290 |
lines notNil ifTrue:[ |
|
4649 | 3291 |
nLines := lines size. |
3292 |
(nLines == 1) ifTrue:[ |
|
3293 |
self insertStringAtCursor:(lines at:1). |
|
3294 |
withCr ifTrue:[ |
|
3295 |
self insertCharAtCursor:(Character cr) |
|
3296 |
] |
|
3297 |
] ifFalse:[ |
|
3298 |
(cursorCol ~~ 1) ifTrue:[ |
|
3299 |
self insertStringAtCursor:(lines at:1). |
|
3300 |
self insertCharAtCursor:(Character cr). |
|
3301 |
start := 2 |
|
3302 |
] ifFalse:[ |
|
3303 |
start := 1 |
|
3304 |
]. |
|
3305 |
withCr ifTrue:[ |
|
3306 |
end := nLines |
|
3307 |
] ifFalse:[ |
|
3308 |
end := nLines - 1 |
|
3309 |
]. |
|
3310 |
(start <= nLines) ifTrue:[ |
|
3311 |
(end >= start) ifTrue:[ |
|
3312 |
wasOn := self hideCursor. |
|
3313 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3314 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3315 |
wasOn ifTrue:[self showCursor]. |
|
3316 |
] |
|
3317 |
]. |
|
3318 |
withCr ifFalse:[ |
|
3319 |
"last line without cr" |
|
3320 |
self insertStringAtCursor:(lines at:nLines) |
|
3321 |
] |
|
3322 |
] |
|
641 | 3323 |
] |
654 | 3324 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3325 |
"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
|
3326 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3327 |
! |
3328 |
||
3329 |
insertLines:lines withCr:withCr |
|
3330 |
"insert a bunch of lines at cursor position. Cursor |
|
3331 |
is moved behind insertion. |
|
3332 |
If withCr is true, append cr after last line" |
|
3333 |
||
2363 | 3334 |
<resource:#obsolete> |
3335 |
||
1292 | 3336 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3337 |
self insertLines:lines withCR:withCr. |
|
3338 |
||
3339 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3340 |
! |
3341 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3342 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3343 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3345 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3346 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3347 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3348 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3349 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3350 |
self selectFromLine:startLine col:startCol |
4823 | 3351 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3352 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3353 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3354 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3355 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3356 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3357 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3358 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3359 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3360 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3361 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3362 |
col == 0 ifTrue:[ |
3363 |
line > 1 ifTrue:[ |
|
3364 |
line := line - 1. |
|
5216 | 3365 |
col := (self listAt:line) size + 1. |
5060 | 3366 |
] ifFalse:[ |
3367 |
col := 1. |
|
3368 |
] |
|
3369 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3370 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3371 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3372 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3373 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3374 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3375 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3376 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3377 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3378 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3379 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3380 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3381 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3383 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3384 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3385 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3386 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3387 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3388 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3389 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3390 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3391 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3392 |
[start <= end] whileTrue:[ |
4823 | 3393 |
stop := aString indexOf:(Character cr) startingAt:start. |
3394 |
stop == 0 ifTrue:[ |
|
3395 |
stop := end + 1 |
|
3396 |
]. |
|
3397 |
subString := aString copyFrom:start to:(stop - 1). |
|
3398 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3399 |
(stop <= end) ifTrue:[ |
|
3400 |
c := c + subString size. |
|
3401 |
self insert:(Character cr) atLine:l col:c. |
|
3402 |
l := l + 1. |
|
3403 |
c := 1 |
|
3404 |
]. |
|
3405 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3406 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3407 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3408 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3409 |
! |
3410 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3411 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3412 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3413 |
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
|
3414 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3415 |
aString isNil ifTrue:[ |
4823 | 3416 |
"new:" |
3417 |
self insertCharAtCursor:(Character cr). |
|
3418 |
^ self |
|
105 | 3419 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3420 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3421 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3422 |
]. |
3423 |
||
654 | 3424 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3425 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3426 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3427 |
! |
3428 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3429 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3430 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3431 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3432 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3433 |
shown ifTrue:[ |
4889 | 3434 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3435 |
self invalidateLine:lineNr. |
3436 |
] ifFalse:[ |
|
3437 |
self redrawLine:lineNr from:colNr |
|
3438 |
] |
|
3439 |
] |
|
3440 |
||
4191 | 3441 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3442 |
! |
3443 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3444 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3445 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3446 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3447 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3448 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3449 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3450 |
aString size > 0 ifTrue:[ |
4823 | 3451 |
wasOn := self hideCursor. |
3452 |
(aString includes:Character tab) ifTrue:[ |
|
3453 |
self checkForExistingLine:cursorLine. |
|
3454 |
oldLen := (list at:cursorLine) size. |
|
3455 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3456 |
newLen := (list at:cursorLine) size. |
|
3457 |
deltaLen := newLen - oldLen. |
|
3458 |
] ifFalse:[ |
|
3459 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3460 |
deltaLen := aString size. |
|
3461 |
]. |
|
3462 |
self setCursorCol:(cursorCol + deltaLen). |
|
3463 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3464 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3465 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3466 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3467 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3468 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3469 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3470 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3471 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3472 |
|wasOn nextTab| |
105 | 3473 |
|
121 | 3474 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3475 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3476 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3477 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3478 |
! |
3479 |
||
3542 | 3480 |
joinLines |
3890 | 3481 |
"join lines (remove line-break)" |
3482 |
||
3583 | 3483 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3484 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3485 |
self |
3890 | 3486 |
undoableDo:[ |
3487 |
|line col lineLen| |
|
3488 |
||
3489 |
line := cursorLine. |
|
3490 |
col := cursorCol. |
|
3491 |
lineLen := (list at:line) size. |
|
3492 |
col > lineLen ifTrue:[ |
|
3493 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3494 |
] ifFalse:[ |
|
3495 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3496 |
]. |
|
3497 |
self mergeLine:line removeBlanks:true. |
|
3498 |
self cursorLine:line col:col. |
|
3499 |
] |
|
3500 |
info:'Join' |
|
3542 | 3501 |
! |
3502 |
||
2952 | 3503 |
mergeLine:lineNr |
3504 |
"merge line lineNr with line lineNr+1" |
|
3505 |
||
3506 |
self mergeLine:lineNr removeBlanks:true |
|
3507 |
||
3508 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3509 |
! |
|
3510 |
||
4458 | 3511 |
mergeLine:lineNr removeBlanks:removeBlanks |
3512 |
"merge line lineNr with line lineNr+1" |
|
3513 |
||
3514 |
|len| |
|
3515 |
||
3516 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3517 |
||
3518 |
len := (self listAt:lineNr) size. |
|
3519 |
self nonUndoableDo:[ |
|
4823 | 3520 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3521 |
]. |
3522 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3523 |
! |
|
3524 |
||
2506 | 3525 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3526 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3527 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3528 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3529 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3530 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3531 |
|
2506 | 3532 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
4823 | 3533 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
3534 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
3535 |
newSelectionEnd := newSelectionEnd-1. |
|
3536 |
]. |
|
3537 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
3538 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3539 |
newSelectionEnd := newSelectionEnd-1. |
|
3540 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3541 |
] ifFalse:[ |
4823 | 3542 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
3543 |
newSelectionEnd := newSelectionEnd+1. |
|
3544 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
3545 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3546 |
newSelectionEnd := newSelectionEnd+1. |
|
3547 |
] |
|
3160 | 3548 |
]. |
3549 |
self |
|
4823 | 3550 |
selectFromLine:selectionStartLine col:selectionStartCol |
3551 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3552 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3553 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3554 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3555 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3556 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3557 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3558 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3559 |
|
5114 | 3560 |
NoModificationError handle:[:ex | |
3561 |
^ self |
|
3562 |
] do:[ |
|
3563 |
lastLine := list size. |
|
3564 |
finished := false. |
|
3565 |
[finished] whileFalse:[ |
|
3566 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3567 |
finished := true |
3568 |
] ifFalse:[ |
|
5114 | 3569 |
line := list at:lastLine. |
3570 |
line notNil ifTrue:[ |
|
3571 |
line isBlank ifTrue:[ |
|
3572 |
self basicListAt:lastLine put:nil. |
|
3573 |
line := nil |
|
3574 |
] |
|
3575 |
]. |
|
3576 |
line notNil ifTrue:[ |
|
3577 |
finished := true |
|
3578 |
] ifFalse:[ |
|
3579 |
lastLine := lastLine - 1 |
|
3580 |
] |
|
4771 | 3581 |
] |
5114 | 3582 |
]. |
3583 |
(lastLine ~~ list size) ifTrue:[ |
|
3584 |
list grow:lastLine. |
|
3585 |
"/ self textChanged |
|
4771 | 3586 |
] |
118 | 3587 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3588 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3589 |
|
4458 | 3590 |
replace:aCharacter atLine:lineNr col:colNr |
3591 |
"replace a single character at lineNr/colNr" |
|
3592 |
||
3593 |
|originalChar| |
|
3594 |
||
3595 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3596 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3597 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3598 |
! |
|
3599 |
||
4713 | 3600 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3601 |
|pattern replacePattern| |
3602 |
||
3603 |
pattern := patternArg string. |
|
3604 |
replacePattern := replacePatternArg string. |
|
4630 | 3605 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3606 |
self rememberSearchPattern:pattern. |
|
3607 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3608 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3609 |
self |
3610 |
undoableDo:[ |
|
3611 |
all ifTrue:[ |
|
3612 |
self |
|
3613 |
replaceString:pattern |
|
3614 |
to:replacePattern |
|
4713 | 3615 |
ignoreCase:ignoreCase |
4630 | 3616 |
] ifFalse:[ |
3617 |
(self selectionAsString notNil |
|
4713 | 3618 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3619 |
ifTrue:[ |
4742 | 3620 |
self replaceSelectionBy:replacePattern. |
4630 | 3621 |
self |
3622 |
search:pattern |
|
4713 | 3623 |
ignoreCase:ignoreCase |
4630 | 3624 |
forward:(lastSearchDirection = #forward). |
3625 |
]. |
|
3626 |
] |
|
3627 |
] |
|
3628 |
info:'Replace' |
|
3430 | 3629 |
] |
3630 |
||
3631 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3632 |
! |
|
3633 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3634 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3635 |
"replace a single character at cursor-position - advance cursor" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3636 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3637 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3638 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3639 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3640 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3641 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3642 |
] ifFalse:[ |
4823 | 3643 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3644 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3645 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3646 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3647 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3648 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3649 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3650 |
|
4458 | 3651 |
replaceContentsWith:newContents |
3652 |
"replace everything" |
|
3653 |
||
3654 |
|originalContents| |
|
3655 |
||
3656 |
originalContents := self contents. |
|
3657 |
self contents:newContents keepUndoHistory:true. |
|
3658 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3659 |
! |
|
3660 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3661 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3662 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3663 |
|
5216 | 3664 |
"/ 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
|
3665 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3666 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3667 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3668 |
|
4458 | 3669 |
replaceLine:lineNr with:newText |
3670 |
"replace a line at lineNr" |
|
3671 |
||
3672 |
|originalLine| |
|
3673 |
||
3674 |
originalLine := self listAt:lineNr. |
|
3675 |
originalLine isNil ifTrue:[ |
|
4823 | 3676 |
self checkForExistingLine:lineNr |
4458 | 3677 |
]. |
3678 |
self list at:lineNr put:newText. |
|
3679 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3680 |
self invalidateLine:lineNr. |
|
3681 |
||
3682 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3683 |
! |
|
3684 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3685 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3686 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3687 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3688 |
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
|
3689 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3690 |
|
1809 | 3691 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3692 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3693 |
lines notNil ifTrue:[ |
4661 | 3694 |
wasOn := self hideCursor. |
3695 |
nLines := lines size. |
|
3696 |
line := cursorLine. |
|
3697 |
col := cursorCol. |
|
3698 |
lines keysAndValuesDo:[:i :l | |
|
3699 |
self replaceString:(l ? '') atLine:line col:col. |
|
3700 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3701 |
line := line + 1. |
|
3702 |
col := 1. |
|
3703 |
] ifFalse:[ |
|
3704 |
col := col + (l size). |
|
3705 |
] |
|
3706 |
]. |
|
3707 |
self cursorLine:line col:col. |
|
3708 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3709 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3710 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3711 |
|
4661 | 3712 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3713 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3714 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3715 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3716 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3717 |
"delete the selection (if any) and insert something, a character or string; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3718 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3719 |
|
4666 | 3720 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3721 |
! |
3722 |
||
3723 |
replaceSelectionBy:something keepCursor:keep |
|
3724 |
"delete the selection (if any) and insert something, a character or string; |
|
3725 |
leave cursor after insertion or leave it, depending on keep" |
|
3726 |
||
4666 | 3727 |
self replaceSelectionBy:something keepCursor:keep select:false |
3728 |
||
3729 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3730 |
! |
|
3731 |
||
3732 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
3733 |
"delete the selection (if any) and insert something, a character or string; |
|
3734 |
leave cursor after insertion or leave it, depending on keep. |
|
3735 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3736 |
||
3737 |
|sel l c selStartLine selStartCol| |
|
105 | 3738 |
|
3739 |
l := cursorLine. |
|
3740 |
c := cursorCol. |
|
3741 |
||
4818 | 3742 |
sel := self selectionAsString. |
4666 | 3743 |
sel isNil ifTrue:[ |
3744 |
selStartLine := l. |
|
3745 |
selStartCol := c. |
|
3746 |
] ifFalse:[ |
|
3747 |
selStartLine := selectionStartLine. |
|
3748 |
selStartCol := selectionStartCol. |
|
3749 |
||
4053 | 3750 |
self setLastStringToReplace: sel. |
3751 |
||
4010 | 3752 |
self deleteSelection. |
3753 |
replacing := true. |
|
4818 | 3754 |
lastReplacementInfo rememberReplacement. |
4048 | 3755 |
lastReplacementInfo lastReplacement: ''. |
4818 | 3756 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 3757 |
undoSupport actionInfo:'replace'. |
3161 | 3758 |
]. |
3759 |
||
3760 |
something isCharacter ifTrue:[ |
|
4051 | 3761 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 3762 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 3763 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 3764 |
]. |
4010 | 3765 |
]. |
3766 |
self isInInsertMode ifTrue:[ |
|
3767 |
self insertCharAtCursor:something |
|
3768 |
] ifFalse:[ |
|
3769 |
self replaceCharAtCursor:something |
|
3770 |
] |
|
105 | 3771 |
] ifFalse:[ |
4010 | 3772 |
something isString ifTrue:[ |
4048 | 3773 |
lastReplacementInfo lastReplacement: something. |
4010 | 3774 |
self isInInsertMode ifTrue:[ |
3775 |
self insertStringAtCursor:something |
|
3776 |
] ifFalse:[ |
|
3777 |
self replaceStringAtCursor:something |
|
3778 |
] |
|
3779 |
] ifFalse:[ |
|
3780 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3781 |
]. |
|
105 | 3782 |
]. |
3783 |
keep ifTrue:[ |
|
4010 | 3784 |
self cursorLine:l col:c |
4666 | 3785 |
]. |
3786 |
selectNewText ifTrue:[ |
|
3787 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3788 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3789 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3790 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3791 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3792 |
|
4458 | 3793 |
replaceString:aString atLine:lineNr col:colNr |
3794 |
"replace multiple characters starting at lineNr/colNr. |
|
3795 |
This is not prepared to encounter special chars (except TAB) in the string." |
|
3796 |
||
3797 |
|originalString| |
|
3798 |
||
3799 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3800 |
||
3801 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3802 |
||
3803 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3804 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3805 |
! |
|
3806 |
||
4713 | 3807 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 3808 |
|continue count| |
3809 |
||
3810 |
self cursorToTop. |
|
3811 |
self selectFromBeginning. |
|
3812 |
count := 0. |
|
3813 |
continue := true. |
|
3814 |
[ continue ] whileTrue:[ |
|
4713 | 3815 |
(self selectionAsString notNil |
3816 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
3817 |
ifTrue:[ |
|
4742 | 3818 |
self replaceSelectionBy:aNewString. |
4713 | 3819 |
count := count + 1. |
3820 |
]. |
|
3821 |
self |
|
3822 |
searchFwd:aString |
|
3823 |
ignoreCase:ignoreCase |
|
3824 |
ifAbsent:[ |
|
3825 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
3826 |
bindWith:aString with:aNewString with:count). |
|
3827 |
continue := false. |
|
3828 |
]. |
|
3549 | 3829 |
]. |
3430 | 3830 |
|
3831 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3832 |
! |
|
3833 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3834 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3835 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3836 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3837 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3838 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3839 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3840 |
(aString includes:Character tab) ifTrue:[ |
4823 | 3841 |
"/ need special care for TAB (to move cursor correctly) |
3842 |
i1 := 1. |
|
3843 |
[i1 ~~ 0] whileTrue:[ |
|
3844 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3845 |
i2 ~~ 0 ifTrue:[ |
|
3846 |
i1 ~~ i2 ifTrue:[ |
|
3847 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3848 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3849 |
]. |
|
3850 |
self replaceTABAtCursor. |
|
3851 |
i2 := i2 + 1. |
|
3852 |
] ifFalse:[ |
|
3853 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3854 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3855 |
]. |
|
3856 |
i1 := i2. |
|
3857 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3858 |
] ifFalse:[ |
4823 | 3859 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3860 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3861 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3862 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3863 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3864 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3865 |
"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
|
3866 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3867 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3868 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3869 |
"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
|
3870 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3871 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3872 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3873 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3874 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3875 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3876 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3877 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3878 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3879 |
! |
3880 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3881 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3882 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3883 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3884 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3885 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3886 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3887 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3888 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3889 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3890 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3891 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3892 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3893 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3894 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3895 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3896 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3897 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3898 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3899 |
|
4458 | 3900 |
splitLine:lineNr before:colNr |
3901 |
"split the line linNr before colNr; the right part (from colNr) |
|
3902 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3903 |
||
3904 |
self basicSplitLine:lineNr before:colNr. |
|
3905 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3906 |
! |
|
3907 |
||
5146 | 3908 |
withAutoIndent:aBoolean do:aBlock |
3909 |
|sav| |
|
3910 |
||
3911 |
sav := autoIndent. |
|
3912 |
autoIndent := aBoolean. |
|
3913 |
aBlock ensure:[ autoIndent := sav ]. |
|
3914 |
! |
|
3915 |
||
4458 | 3916 |
withoutRedrawAt:lineNr put:aString |
3917 |
"replace a line at lineNr" |
|
3918 |
||
3919 |
|originalLine| |
|
3920 |
||
3921 |
originalLine := self listAt:lineNr. |
|
3922 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3923 |
super withoutRedrawAt:lineNr put:aString. |
|
3924 |
! |
|
3925 |
||
3926 |
withoutRedrawInsertLine:aString before:lineNr |
|
3927 |
"insert the argument, aString before line lineNr; the string |
|
3928 |
becomes line lineNr; everything else is moved down; the view |
|
3929 |
is not redrawn" |
|
3930 |
||
4771 | 3931 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 3932 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
3933 |
! |
|
3934 |
||
3935 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
3936 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3937 |
||
3938 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
3939 |
self isReadOnly ifFalse:[ |
|
4823 | 3940 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 3941 |
]. |
3942 |
! |
|
3943 |
||
3944 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3945 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3946 |
||
3947 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
3948 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
3949 |
! |
|
3950 |
||
3890 | 3951 |
wrapLines |
3952 |
"wrap lines (insert line-break)" |
|
3953 |
||
3954 |
|lineLength answerString string| |
|
3955 |
||
3956 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3957 |
||
3958 |
self hasSelection ifFalse:[ |
|
3959 |
self selectLine:cursorLine. |
|
3960 |
]. |
|
3961 |
string := self selectionAsString. |
|
3962 |
string isEmptyOrNil ifTrue:[ |
|
3963 |
Dialog information:(resources string:'Nothing selected.'). |
|
3964 |
^ self. |
|
3965 |
]. |
|
3966 |
||
3967 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
3968 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 3969 |
lineLength isNil ifTrue:[^ self]. |
3890 | 3970 |
lineLength < 1 ifTrue:[ |
3971 |
lineLength := 1. |
|
3972 |
]. |
|
3973 |
||
3974 |
self |
|
3975 |
undoableDo:[ |
|
3976 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
3977 |
||
3978 |
line := selectionStartLine. |
|
3979 |
col := selectionStartCol. |
|
3980 |
||
3981 |
self cutSelection. |
|
3982 |
self cursorLine:line col:col. |
|
3983 |
||
3984 |
lastGoodCol := col. |
|
3985 |
||
3986 |
inStream := string readStream. |
|
3987 |
[ inStream atEnd ] whileFalse:[ |
|
3988 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
3989 |
word := WriteStream on:(String new:10). |
|
3990 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
3991 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
3992 |
self insertCharAtCursor:(Character cr). |
|
3993 |
col := 1. |
|
3994 |
] ifFalse:[ |
|
3995 |
col ~~ 1 ifTrue:[ |
|
3996 |
self insertStringAtCursor:' '. |
|
3997 |
col := col + 1. |
|
3998 |
] |
|
3999 |
]. |
|
4000 |
self insertStringAtCursor:word contents. |
|
4001 |
col := col + word size. |
|
4002 |
]. |
|
4003 |
] |
|
4004 |
info:'Wrap' |
|
4388 | 4005 |
|
4006 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4007 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4008 |
|
2752 | 4009 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4010 |
|
2952 | 4011 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4012 |
"delete characters from startCol to endCol in line lineNr" |
4013 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4014 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4015 |
|
4673 | 4016 |
self unselect. |
4017 |
||
4018 |
cursorLine == lineNr ifTrue:[ |
|
4019 |
cursorCol >= startCol ifTrue:[ |
|
4020 |
cursorCol >= endCol ifTrue:[ |
|
4021 |
cursorCol := startCol. |
|
4022 |
] ifFalse:[ |
|
4023 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4024 |
] |
|
4025 |
]. |
|
4026 |
]. |
|
4027 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4028 |
line := self listAt:lineNr. |
827 | 4029 |
|
4673 | 4030 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4031 |
||
4032 |
lineSize := line size. |
|
4033 |
||
4034 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4035 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4036 |
||
4037 |
stop >= start ifTrue:[ |
|
4038 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4039 |
ifFalse:[ newLine := '' ]. |
|
4040 |
||
4041 |
stop == lineSize ifFalse:[ |
|
4042 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4043 |
newLine := line string species fromString:newLine. |
|
4190 | 4044 |
]. |
4673 | 4045 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4046 |
]. |
|
4047 |
||
4048 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4049 |
newLine := nil |
|
4050 |
]. |
|
4051 |
||
4052 |
prevWidth := self widthOfLine:lineNr. |
|
4053 |
||
4771 | 4054 |
self basicListAt:lineNr put:newLine. |
4673 | 4055 |
|
4056 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4057 |
"/ remember old width of this line, |
|
4058 |
"/ only clear widthOfWidestLine, if this lines |
|
4059 |
"/ length was (one of) the longest. |
|
4060 |
"/ avoids slow delete with huge texts. |
|
4061 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4062 |
||
4063 |
"/ scroll left if reqiured |
|
4064 |
viewOrigin x > 0 ifTrue:[ |
|
4065 |
newWidth := self widthOfLine:lineNr. |
|
4066 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4067 |
self scrollHorizontalTo:(newWidth |
|
4068 |
- width |
|
4069 |
+ margin + margin |
|
4889 | 4070 |
+ (gc font widthOf:' ')) |
4673 | 4071 |
] |
4190 | 4072 |
]. |
4673 | 4073 |
self textChanged. |
4074 |
] ifFalse:[ |
|
4075 |
self textChanged "/ textChangedButNoSizeChange |
|
4076 |
]. |
|
4889 | 4077 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4078 |
self invalidateLine:lineNr. |
4079 |
] ifFalse:[ |
|
4080 |
self redrawLine:lineNr from:start. |
|
4081 |
]. |
|
4082 |
]. |
|
827 | 4083 |
|
4191 | 4084 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4085 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4086 |
|
2952 | 4087 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4088 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4089 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4090 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4091 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4092 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4093 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4094 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4095 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4096 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4097 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4098 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4099 |
startLineNr <= list size ifTrue:[ |
4771 | 4100 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4101 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4102 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4103 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4104 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4105 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4106 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4107 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4108 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4109 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4110 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4111 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4112 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4113 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4114 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4115 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4116 |
|
4226 | 4117 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4118 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4119 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4120 |
|
2952 | 4121 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4122 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4123 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4124 |
|
2952 | 4125 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4126 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4127 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4128 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4129 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4130 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4131 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4132 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4133 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4134 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4135 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4136 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4137 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4138 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4139 |
|
2952 | 4140 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4141 |
"insert a single character at lineNr/colNr; |
827 | 4142 |
set emphasis to character at current position" |
4143 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4144 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4145 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4146 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4147 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4148 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4149 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4150 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4151 |
]. |
827 | 4152 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4153 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4154 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4155 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4156 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4157 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4158 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4159 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4160 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4161 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4162 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4163 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4164 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4165 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4166 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4167 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4168 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4169 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4170 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4171 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4172 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4173 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4174 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4175 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4176 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4177 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4178 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4179 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4180 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4181 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4182 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4183 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4184 |
]. |
827 | 4185 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4186 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4187 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4188 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4189 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4190 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4191 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4192 |
newLine at:colNr put:aCharacter. |
827 | 4193 |
|
4194 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4195 |
newLine emphasisAt:colNr put:attribute. |
827 | 4196 |
]. |
4197 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4198 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4199 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4200 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4201 |
]. |
827 | 4202 |
|
4771 | 4203 |
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
|
4204 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4205 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4206 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4207 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4208 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4209 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4210 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4211 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4212 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4213 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4214 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4215 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4216 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4217 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4218 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4219 |
|
4889 | 4220 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4221 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4222 |
] ifFalse:[ |
4190 | 4223 |
drawCharacterOnly ifTrue:[ |
4889 | 4224 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4225 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4226 |
] ifFalse:[ |
|
4227 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4228 |
self redrawLine:lineNr from:colNr-1 |
|
4229 |
]. |
|
4230 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4231 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4232 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4233 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4234 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4235 |
]. |
4889 | 4236 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4237 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4238 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4239 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4240 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4241 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4242 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4243 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4244 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4245 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4246 |
|
4191 | 4247 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4248 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4249 |
|
4771 | 4250 |
basicListAt:lineNr put:newLine |
4251 |
"redefinable for special subclasses (with virtual list)" |
|
4252 |
||
4253 |
list at:lineNr put:newLine. |
|
4254 |
! |
|
4255 |
||
4256 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4257 |
"redefinable for special subclasses (with virtual list)" |
|
4258 |
||
4259 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4260 |
! |
|
4261 |
||
2952 | 4262 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4263 |
"merge line lineNr with line lineNr+1" |
4264 |
||
827 | 4265 |
|leftPart rightPart bothParts nextLineNr i| |
4266 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4267 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4268 |
"/ empty list or beyond end of text |
4269 |
^ self |
|
827 | 4270 |
]. |
4271 |
leftPart := self listAt:lineNr. |
|
4272 |
||
4273 |
leftPart isNil ifTrue:[ |
|
4771 | 4274 |
leftPart := ''. |
4275 |
autoIndent ifTrue:[ |
|
4276 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4277 |
leftPart := String new:i |
|
4278 |
] |
|
4279 |
] |
|
827 | 4280 |
]. |
4281 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4282 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4283 |
||
4284 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4285 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4286 |
rightPart := '' |
|
4287 |
] ifFalse:[ |
|
4288 |
removeBlanks ifTrue:[ |
|
4289 |
rightPart := rightPart withoutLeadingSeparators. |
|
4290 |
] |
|
4291 |
]. |
|
4292 |
||
4293 |
bothParts := leftPart , rightPart. |
|
4294 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4295 |
self basicListAt:lineNr put:bothParts. |
|
4296 |
self redrawLine:lineNr. |
|
4297 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4298 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4299 |
|
1319 | 4300 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4301 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4302 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4303 |
|
2952 | 4304 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4305 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4306 |
|
5045 | 4307 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4308 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4309 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4310 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4311 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4312 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4313 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4314 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4315 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4316 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4317 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4318 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4319 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4320 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4321 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4322 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4323 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4324 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4325 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4326 |
(lineSize == 0) ifTrue:[ |
4190 | 4327 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4328 |
] ifFalse: [ |
5045 | 4329 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4330 |
newLineSpecies := aCharacter stringSpecies |
|
4331 |
] ifFalse:[ |
|
4332 |
newLineSpecies := line species |
|
4333 |
]. |
|
4334 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4335 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4336 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4337 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4338 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4339 |
newLine := self withTabsExpanded:newLine. |
4340 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4341 |
]. |
4771 | 4342 |
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
|
4343 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4344 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4345 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4346 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4347 |
shown ifTrue:[ |
4889 | 4348 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4349 |
self invalidateLine:lineNr. |
4350 |
] ifFalse:[ |
|
4351 |
drawCharacterOnly ifTrue:[ |
|
4352 |
self redrawLine:lineNr col:colNr |
|
4353 |
] ifFalse:[ |
|
4354 |
self redrawLine:lineNr from:colNr |
|
4355 |
] |
|
4356 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4357 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4358 |
|
4190 | 4359 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4360 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4361 |
! |
4362 |
||
3235 | 4363 |
basicReplaceString:aString atLine:lineNr col:colNr |
4364 |
"replace multiple characters starting at lineNr/colNr. |
|
4365 |
This is not prepared to encounter special chars (except TAB) |
|
4366 |
in the string." |
|
4367 |
||
5045 | 4368 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4369 |
|
4370 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4371 |
||
4372 |
self checkForExistingLine:lineNr. |
|
4373 |
line := list at:lineNr. |
|
4374 |
lineSize := line size. |
|
4375 |
||
4376 |
endCol := colNr + aString size - 1. |
|
4377 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4378 |
newLine := aString species new:endCol. |
3235 | 4379 |
] ifFalse: [ |
5045 | 4380 |
(aString isText or:[aString bitsPerCharacter > line bitsPerCharacter]) ifTrue:[ |
4381 |
newLineSpecies := aString stringSpecies |
|
4382 |
] ifFalse:[ |
|
4383 |
newLineSpecies := line species |
|
4384 |
]. |
|
4385 |
||
4386 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4387 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4388 |
]. |
4389 |
newLine replaceFrom:colNr with:aString. |
|
4390 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4391 |
newLine := self withTabsExpanded:newLine. |
3235 | 4392 |
]. |
4771 | 4393 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4394 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4395 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4396 |
]. |
4397 |
self textChanged. |
|
4398 |
shown ifTrue:[ |
|
4889 | 4399 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4400 |
self invalidateLine:lineNr. |
4401 |
] ifFalse:[ |
|
4402 |
self redrawLine:lineNr from:colNr |
|
4403 |
] |
|
3235 | 4404 |
] |
4405 |
||
4190 | 4406 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4407 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4408 |
! |
4409 |
||
2952 | 4410 |
basicSplitLine:lineNr before:colNr |
4411 |
"split the line linNr before colNr; the right part (from colNr) |
|
4412 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4413 |
||
3160 | 4414 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4415 |
srcY "{ Class: SmallInteger }" | |
4416 |
||
3027 | 4417 |
list isNil ifTrue:[ ^ self ]. |
4418 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4419 |
||
4420 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4421 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4422 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4423 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4424 |
^ self |
3027 | 4425 |
]. |
4426 |
||
4427 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4428 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4429 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4430 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4431 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4432 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4433 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4434 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4435 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4436 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4437 |
] |
3027 | 4438 |
]. |
4439 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4440 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4441 |
]. |
4771 | 4442 |
self basicListAt:lineNr put:leftRest. |
3027 | 4443 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4444 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4445 |
]. |
4446 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4447 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4448 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4449 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4450 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4451 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4452 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4453 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4454 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4455 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4456 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4457 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4458 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4459 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4460 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4461 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4462 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4463 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4464 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4465 |
]. |
4466 |
widthOfWidestLine := nil. "/ unknown |
|
4467 |
self textChanged. |
|
2952 | 4468 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4469 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4470 |
! |
4471 |
||
2954 | 4472 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4473 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4474 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4475 |
because the text might have been pasted from an alien view." |
|
2954 | 4476 |
|
4477 |
|newLine newLines nLines| |
|
4478 |
||
4479 |
nLines := end - start + 1. |
|
4480 |
newLines := Array new:(lines size). |
|
4481 |
start to:end do:[:index | |
|
4328 | 4482 |
newLine := lines at:index. |
4483 |
newLine notNil ifTrue:[ |
|
4484 |
newLine isString ifTrue:[ |
|
4485 |
newLine isBlank ifTrue:[ |
|
4486 |
newLine := nil |
|
4487 |
] ifFalse:[ |
|
4488 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4489 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4490 |
] |
|
4491 |
] |
|
4492 |
] |
|
4493 |
]. |
|
4494 |
newLines at:index put:newLine |
|
2954 | 4495 |
]. |
4496 |
list isNil ifTrue: [ |
|
4328 | 4497 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4498 |
] ifFalse: [ |
4328 | 4499 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4500 |
]. |
4501 |
||
4502 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4503 |
overlapping copy - if it didn't, we had to use:" |
4504 |
" |
|
4505 |
index := list size. |
|
4506 |
[index > lineNr] whileTrue: [ |
|
4328 | 4507 |
pIndex := index - 1. |
4508 |
list at:index put:(list at:pIndex). |
|
4509 |
index := pIndex |
|
2954 | 4510 |
]. |
4511 |
" |
|
4512 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4513 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4514 |
self contentsChanged |
|
4515 |
||
4328 | 4516 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4517 |
! |
4518 |
||
4519 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4520 |
"insert aString (which has no crs) at lineNr/colNr. |
4521 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4522 |
because the text might have been pasted from an alien view." |
|
2954 | 4523 |
|
4360 | 4524 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4525 |
|
4623 | 4526 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4527 |
|
4528 |
strLen := aString size. |
|
4529 |
self checkForExistingLine:lineNr. |
|
4530 |
||
4531 |
stringType := aString string species. |
|
4532 |
isText := aString isText. |
|
4533 |
line := list at:lineNr. |
|
4534 |
||
4535 |
line notNil ifTrue:[ |
|
4328 | 4536 |
lineSize := line size. |
4537 |
line isString ifFalse:[ |
|
4538 |
stringType := line species |
|
4539 |
] ifTrue:[ |
|
4360 | 4540 |
lineCharWidth := line bitsPerCharacter. |
4541 |
stringCharWidth := aString bitsPerCharacter. |
|
4542 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4543 |
stringType := line string species |
4360 | 4544 |
] ifFalse:[ |
4545 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4546 |
stringType := aString string species |
|
4547 |
] |
|
4328 | 4548 |
]. |
4549 |
line isText ifTrue:[ isText := true ] |
|
4550 |
]. |
|
2954 | 4551 |
] ifFalse:[ |
4328 | 4552 |
lineSize := 0 |
2954 | 4553 |
]. |
4554 |
||
4555 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4556 |
newLine := aString |
2954 | 4557 |
] ifFalse:[ |
4328 | 4558 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4559 |
sz := colNr + strLen - 1 |
|
4560 |
] ifFalse:[ |
|
4561 |
sz := lineSize + strLen |
|
4562 |
]. |
|
4563 |
||
4360 | 4564 |
newLine := stringType new:sz. |
4565 |
isText ifTrue:[ |
|
4566 |
newLine := Text string:newLine |
|
4328 | 4567 |
]. |
4568 |
||
4569 |
(lineSize ~~ 0) ifTrue: [ |
|
4570 |
(colNr > lineSize) ifTrue: [ |
|
4571 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4572 |
] ifFalse: [ |
|
4573 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4574 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4575 |
] |
|
4576 |
]. |
|
4577 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4578 |
]. |
4579 |
||
4580 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4581 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4582 |
]. |
4583 |
||
4771 | 4584 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4585 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4586 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4587 |
]. |
4588 |
self textChanged. |
|
4589 |
||
4360 | 4590 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4591 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4592 |
|
2752 | 4593 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4594 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4595 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4596 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4597 |
|
5216 | 4598 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4599 |
dragIsActive := false. |
4600 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4601 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4602 |
"/ 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
|
4603 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4604 |
]. |
4609 | 4605 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4606 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4607 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4608 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4609 |
|
4420 | 4610 |
"On X11, be nice and paste PRIMARY when middle click. |
4611 |
Note, that middle button on X11 is translated to button |
|
4612 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
4940 | 4613 |
(button == #paste and:[self graphicsDevice platformName == #X11]) ifTrue:[ |
4420 | 4614 |
self undoableDo:[ |
4615 |
self paste: (self getClipboardText:#selection). |
|
4616 |
]. |
|
4617 |
^self. |
|
4618 |
]. |
|
4619 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4620 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4621 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4622 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4623 |
"/ 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
|
4624 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4625 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4626 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4627 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4628 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4629 |
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
|
4630 |
|
4420 | 4631 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4632 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4633 |
! |
4634 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4635 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4636 |
"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
|
4637 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4638 |
|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
|
4639 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4640 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4641 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4642 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4643 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4644 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4645 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4646 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4647 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4648 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4649 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4650 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4651 |
cursorType ~~ #block ifTrue:[ |
3790 | 4652 |
clickPos notNil ifTrue:[ |
4653 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4654 |
"/ (i.e. if its an ibeam). |
|
4655 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4656 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4657 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4658 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4659 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4660 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4661 |
]. |
5056 | 4662 |
"/ the following fixes the ugly select behavior when double clicking on |
4663 |
"/ a partially visible last line (where the first click used to |
|
4664 |
"/ scroll the text so that the second click was handled on another |
|
4665 |
"/ line. An alternative (possibly better) solution would be to |
|
4666 |
"/ remember the last click posision and adjust in the double click |
|
4667 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4668 |
"/ Time will show, if this hack works. |
|
5057 | 4669 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4670 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4671 |
Processor |
|
4672 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
4673 |
afterSeconds:0.3. |
|
4674 |
] ifFalse:[ |
|
4675 |
self cursorLine:clickLine col:newCursorCol. |
|
4676 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4677 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4678 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4679 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4680 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4681 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4682 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4683 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4684 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4685 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4686 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4687 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4688 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4689 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4690 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4691 |
] ifFalse:[ |
4048 | 4692 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4693 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4694 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4695 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4696 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4697 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4698 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4699 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4700 |
|
2580 | 4701 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4702 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4703 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4704 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4705 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4706 |
self changeTypeOfSelectionTo:nil. |
2580 | 4707 |
|
4708 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4709 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4710 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4711 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4712 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4713 |
self validateNewSelection. |
4420 | 4714 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4715 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4716 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4717 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4718 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4719 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4720 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4721 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4722 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4723 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4724 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4725 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4726 |
selectionEndCol == 0 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4727 |
selectionEndCol := 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4728 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4729 |
self setCursorCol:selectionEndCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4730 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4731 |
self expandSelectionRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4732 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4733 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4734 |
self unselect; makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4735 |
cursorCol == 1 ifTrue:[^ self]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4736 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4737 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4738 |
self cursorRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4739 |
^ self |
2580 | 4740 |
]. |
4741 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4742 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4743 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4744 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4745 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4746 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4747 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4748 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4749 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4750 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4751 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4752 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4753 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4754 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4755 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4756 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4757 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4758 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4759 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4760 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4761 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4762 |
self setCursorCol:selectionStartCol. |
4590 | 4763 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4764 |
self setCursorCol:1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4765 |
self setCursorLine:(cursorLine - 1). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4766 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4767 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4768 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4769 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4770 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4771 |
clickCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4772 |
self expandSelectionDown. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4773 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4774 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4775 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4776 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4777 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4778 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4779 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4780 |
self cursorDown:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4781 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4782 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4783 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4784 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4785 |
^ self |
2580 | 4786 |
]. |
4787 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4788 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4789 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4790 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4791 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4792 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4793 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4794 |
selectionStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4795 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4796 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4797 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4798 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4799 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4800 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4801 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4802 |
selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4803 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4804 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4805 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4806 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4807 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4808 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4809 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4810 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4811 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4812 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4813 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4814 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4815 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4816 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4817 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4818 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4819 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4820 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4821 |
self setCursorLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4822 |
self setCursorCol:selectionStartCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4823 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4824 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4825 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4826 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4827 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4828 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4829 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4830 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4831 |
self expandSelectionUp. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4832 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4833 |
self expandSelectionLeft. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4834 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4835 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4836 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4837 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4838 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4839 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4840 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4841 |
self cursorLeft. ^self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4842 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4843 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4844 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4845 |
self cursorUp:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4846 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4847 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4848 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4849 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4850 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4851 |
]. |
2580 | 4852 |
]. |
4420 | 4853 |
|
4854 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2580 | 4855 |
! |
4856 |
||
2952 | 4857 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4858 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4859 |
|
4521 | 4860 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4861 |
#Replace #Undo #Redo #Accept |
3780 | 4862 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 4863 |
#DeleteSpaces #Join |
3780 | 4864 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 4865 |
#SelectWord #ExpandSelectionByWord |
3780 | 4866 |
#SelectToEnd #SelectFromBeginning |
4707 | 4867 |
#SelectLine #ExpandSelectionByLine |
3780 | 4868 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
4869 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4870 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
4871 |
#GotoLine #BeginOfText #EndOfText |
|
4872 |
#InsertLine #DeleteLine |
|
4873 |
#SelectLineFromBeginning |
|
4874 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 4875 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 4876 |
#'F*' #'f*')> |
2017 | 4877 |
|
4730 | 4878 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 4879 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 4880 |
|
4881 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4882 |
|
4701 | 4883 |
"/ experimental |
4818 | 4884 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 4885 |
(immediateCompletion |
4818 | 4886 |
or:[currentUserPrefs codeCompletionOnControlKey |
4887 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4888 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4889 |
self initializeCompletionSupport. |
4609 | 4890 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4891 |
]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4892 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4893 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4894 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4895 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4896 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4897 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4898 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4899 |
|
4818 | 4900 |
key isSymbol ifTrue:[ |
4940 | 4901 |
(self graphicsDevice modifierKeys includes:key) ifFalse:[ |
4818 | 4902 |
lastReplacementInfo stillCollectingInput:false. |
4903 |
] |
|
4904 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4905 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 4906 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4907 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4908 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4909 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4910 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 4911 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4912 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4913 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4914 |
]. |
3799 | 4915 |
(key == #Undo) ifTrue:[self undo. ^self]. |
4916 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
4917 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4918 |
self learnMode ifTrue:[ |
4482 | 4919 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4920 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4921 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4922 |
|
4238 | 4923 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
4924 |
"the macro named key exists" |
|
3780 | 4925 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4926 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4927 |
|
4482 | 4928 |
key isSymbol ifFalse:[ |
4929 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
4930 |
self handleNonCommandKey:key. |
|
4931 |
^ self |
|
4932 |
]. |
|
4933 |
||
4934 |
event isNil ifTrue:[ |
|
4935 |
event := WindowGroup lastEventQuerySignal query. |
|
4936 |
]. |
|
4937 |
shiftPressed := event hasShift. |
|
4938 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 4939 |
rawKey := event rawKey. |
4482 | 4940 |
|
5133 | 4941 |
key == #InsertUUID ifTrue:[ |
4942 |
self insertUUID. |
|
4943 |
^ self. |
|
4944 |
]. |
|
4945 |
||
4253 | 4946 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
4947 |
self deleteWordBeforeCursor. |
|
4948 |
^ self. |
|
4949 |
]. |
|
4950 |
||
5119 | 4951 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 4952 |
selectionStartLine notNil ifTrue:[ |
4953 |
((key == #BasicBackspace) |
|
4818 | 4954 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 4955 |
ifTrue:[ |
4956 |
self deleteSelection. |
|
4957 |
] ifFalse: [ |
|
4958 |
self copyAndDeleteSelection. |
|
4959 |
]. |
|
4609 | 4960 |
] ifFalse:[ |
4961 |
self makeCursorVisible. |
|
4962 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
4963 |
"/ self deleteWordBeforeCursor. |
|
4964 |
"/ ] ifFalse:[ |
|
4965 |
self deleteCharBeforeCursor. |
|
4966 |
"/ ]. |
|
3780 | 4967 |
]. |
4738 | 4968 |
true "immediateCompletion" ifTrue:[ |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4969 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:key]. |
4731 | 4970 |
]. |
3780 | 4971 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4972 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4973 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4974 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4975 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4976 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4977 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4978 |
|
3235 | 4979 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4980 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 4981 |
^ self. |
3160 | 4982 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4983 |
|
4162 | 4984 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
4985 |
CharacterSetView notNil ifTrue:[ |
|
4986 |
self specialCharacters. |
|
4987 |
^ self. |
|
4988 |
] |
|
4989 |
]. |
|
4990 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4991 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4992 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4993 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4994 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 4995 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4996 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4997 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4998 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4999 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5000 |
(('[fF][0-9]' match:key) |
5001 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5002 |
shiftPressed ifFalse:[ |
|
4818 | 5003 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5004 |
fKeyMacros notNil ifTrue:[ |
5005 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5006 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5007 |
^ self |
|
5008 |
] |
|
5009 |
] |
|
5010 |
] |
|
5011 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5012 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5013 |
|
2506 | 5014 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5015 |
self parenthizeSelectionWith:$( and:$). |
5016 |
^ self. |
|
2506 | 5017 |
]. |
5018 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5019 |
self parenthizeSelectionWith:$" and:$". |
5020 |
^ self. |
|
2506 | 5021 |
]. |
5022 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5023 |
self parenthizeSelectionWith:$' and:$'. |
5024 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5025 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5026 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5027 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5028 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5029 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5030 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5031 |
(key == #Accept) ifTrue:[^ self accept]. |
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5032 |
|
4521 | 5033 |
((key == #Paste) or:[key == #Insert or:[key == #PasteFromHistory]]) ifTrue:[self pasteOrReplace. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5034 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5035 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5036 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5037 |
|
3542 | 5038 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5039 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5040 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5041 |
self makeCursorVisible. |
|
5042 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5043 |
^ self |
|
5044 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5045 |
(key == #SelectWord) ifTrue:[ |
3780 | 5046 |
self makeCursorVisible. |
5047 |
self selectWordUnderCursor. |
|
5048 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5049 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5050 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5051 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5052 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5053 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5054 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5055 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5056 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5057 |
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
|
5058 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5059 |
(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
|
5060 |
(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
|
5061 |
(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
|
5062 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5063 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5064 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5065 |
(key == #BeginOfLine) ifTrue:[ |
5226 | 5066 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5067 |
"/ some shifted key to selectFromBeginOfLine |
|
5068 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5069 |
"/ see code below. |
|
5070 |
false "shiftPressed" ifTrue: [ |
|
3780 | 5071 |
"/ "Original St/X code - now use Ctrl modifier" |
5072 |
"/ self unselect. |
|
5073 |
"/ self cursorHome. |
|
5074 |
"Jan's modification" |
|
4257 | 5075 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
5076 |
"/ Jan's modification modified by his own request ;-)) |
|
5077 |
self selectFromBeginOfLine. |
|
3780 | 5078 |
] ifFalse: [ |
5079 |
self unselect. |
|
5080 |
ctrlPressed ifTrue:[ |
|
5081 |
self cursorHome. |
|
5082 |
] ifFalse:[ |
|
5083 |
self cursorToBeginOfLine. |
|
5084 |
] |
|
5085 |
]. |
|
5086 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5087 |
]. |
5226 | 5088 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
5089 |
self selectFromBeginOfLine. |
|
5090 |
^ self |
|
5091 |
]. |
|
5092 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5093 |
(key == #EndOfLine) ifTrue:[ |
5226 | 5094 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5095 |
"/ some shifted key to selectFromBeginOfLine |
|
5096 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5097 |
"/ see code below. |
|
5098 |
false "shiftPressed" ifTrue:[ |
|
3780 | 5099 |
"/ "Original St/X code - now use Ctrl modifier" |
5100 |
"/ self unselect. |
|
5101 |
"/ self cursorToBottom |
|
4257 | 5102 |
" Jan's modification" |
5103 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5104 |
"/ Jan's modification modified by his own request ;-)) |
|
5105 |
self selectToEndOfLine. |
|
3780 | 5106 |
] ifFalse:[ |
5107 |
self unselect. |
|
5108 |
ctrlPressed ifTrue:[ |
|
5109 |
self cursorToBottom |
|
5110 |
] ifFalse:[ |
|
5111 |
self cursorToEndOfLine. |
|
5112 |
] |
|
5113 |
]. |
|
5114 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5115 |
]. |
5226 | 5116 |
|
5117 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
5118 |
self selectToEndOfLine. |
|
5119 |
^ self |
|
5120 |
]. |
|
5121 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5123 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5124 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5125 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5126 |
|
5119 | 5127 |
(rawKey == #CursorRight |
5128 |
or:[rawKey == #CursorDown |
|
5129 |
or:[rawKey == #CursorLeft |
|
5130 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5131 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5132 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5133 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5134 |
|
5119 | 5135 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5136 |
self unselect. self cursorReturn. |
5137 |
^ self |
|
3257 | 5138 |
]. |
5139 |
||
5140 |
(key == #Return) ifTrue:[ |
|
3780 | 5141 |
shiftPressed ifTrue:[ |
5142 |
self unselect. self cursorReturn. |
|
5143 |
^ self |
|
5144 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5145 |
|
3780 | 5146 |
self isReadOnly ifTrue:[ |
5147 |
self unselect; makeCursorVisible. |
|
5148 |
self cursorReturn |
|
5149 |
] ifFalse:[ |
|
5150 |
self isInInsertMode ifFalse:[ |
|
5151 |
self cursorReturn. |
|
5152 |
autoIndent == true ifTrue:[ |
|
5153 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5154 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5155 |
self cursorCol:(i+1 max:1) |
5156 |
] |
|
3780 | 5157 |
] |
5158 |
] ifTrue:[ |
|
4826 | 5159 |
|left right oldIndent| |
4812 | 5160 |
|
3780 | 5161 |
"/ old version just unselected ... |
5162 |
"/ self unselect; makeCursorVisible. |
|
5163 |
||
5164 |
"/ new version deletes ... |
|
5165 |
typeOfSelection == #paste ifTrue:[ |
|
5166 |
self unselect; makeCursorVisible. |
|
5167 |
] ifFalse:[ |
|
5168 |
self copyAndDeleteSelection. |
|
5169 |
]. |
|
4816 | 5170 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5171 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5172 |
self insertCharAtCursor:(Character cr). |
5112 | 5173 |
|
3780 | 5174 |
autoIndent == true ifTrue:[ |
4816 | 5175 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5176 |
"/ nothing to do. |
|
4812 | 5177 |
] ifFalse:[ |
5178 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5179 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5180 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5181 |
left := left withoutSeparators. |
5182 |
right := right withoutSeparators. |
|
5183 |
(left endsWith:'[') ifTrue:[ |
|
5184 |
"/ i := i + 4. |
|
4816 | 5185 |
] ifFalse:[ |
4823 | 5186 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5187 |
i := i - 4. |
5188 |
]. |
|
4812 | 5189 |
]. |
4826 | 5190 |
oldIndent := self leftIndentOfLine:cursorLine. |
5191 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5192 |
self st80EditMode ifTrue:[ |
|
5193 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5194 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5195 |
]. |
|
5196 |
]. |
|
4812 | 5197 |
self cursorCol:(i+1 max:1) |
5198 |
]. |
|
5199 |
] |
|
3780 | 5200 |
]. |
5201 |
]. |
|
5202 |
]. |
|
5203 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5204 |
]. |
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
|
5205 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5206 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5207 |
self unselect. self cursorTab. |
5208 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5209 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5210 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5211 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5212 |
||
5213 |
self hasSelection ifTrue:[ |
|
5214 |
selectStyle == #line ifTrue:[ |
|
4238 | 5215 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5216 |
macroName := #IndentBy4. |
|
5217 |
] ifFalse:[ |
|
5218 |
macroName := #UndentBy4. |
|
5219 |
]. |
|
5220 |
macroName notNil ifTrue:[ |
|
5221 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5222 |
]. |
5223 |
] |
|
5224 |
]. |
|
5225 |
||
5226 |
self unselect. |
|
5227 |
(key == #Tab) ifTrue:[ |
|
5228 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5229 |
self cursorTab. |
|
5230 |
^ self |
|
5231 |
]. |
|
5232 |
self insertTabAtCursor. |
|
5233 |
^ self |
|
5234 |
]. |
|
5235 |
self cursorBacktab. |
|
5236 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5237 |
]. |
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
|
5238 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5239 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5240 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5241 |
shiftPressed ifTrue:[ |
5242 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5243 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5244 |
self makeCursorVisible. |
|
5245 |
self deleteCharAtCursor. |
|
5246 |
]. |
|
5247 |
^ self |
|
5248 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5249 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5250 |
|
5119 | 5251 |
(rawKey == #Delete |
870 | 5252 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5253 |
selectionStartLine notNil ifTrue:[ |
4130 | 5254 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5255 |
"/ To remove text repetetively, use Cut instead. |
|
5256 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5257 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5258 |
((key == #BasicDelete) |
4818 | 5259 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5260 |
self deleteSelection. |
5261 |
] ifFalse:[ |
|
5262 |
self copyAndDeleteSelection. |
|
5263 |
]. |
|
5264 |
^ self |
|
5265 |
]. |
|
5266 |
self makeCursorVisible. |
|
5267 |
self deleteCharAtCursor. |
|
5268 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5269 |
]. |
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
|
5270 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5271 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5272 |
self unselect. |
5273 |
cursorVisibleLine == 1 ifTrue:[ |
|
5274 |
self cursorHome. |
|
5275 |
] ifFalse:[ |
|
5276 |
self cursorToFirstVisibleLine |
|
5277 |
]. |
|
5278 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5279 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5280 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5281 |
self unselect. |
5282 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5283 |
self cursorToBottom. |
|
5284 |
] ifFalse:[ |
|
5285 |
self cursorToLastVisibleLine |
|
5286 |
]. |
|
5287 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5288 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5289 |
((key == #Escape) |
3257 | 5290 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5291 |
self makeCursorVisible. |
5292 |
self unselect. self selectCursorLineFromBeginning. |
|
5293 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5294 |
]. |
3257 | 5295 |
(key == #SelectLine) ifTrue:[ |
3780 | 5296 |
self makeCursorVisible. |
5297 |
self unselect. self selectCursorLine. |
|
5298 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5299 |
]. |
3257 | 5300 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5301 |
"/ self makeCursorVisible. |
3780 | 5302 |
self selectExpandCursorLine. |
5303 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5304 |
]. |
3257 | 5305 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5306 |
self makeCursorVisible. |
5307 |
self unselect. self deleteCursorLine. |
|
5308 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5309 |
]. |
3257 | 5310 |
(key == #InsertLine) ifTrue:[ |
3780 | 5311 |
self makeCursorVisible. |
5312 |
self unselect. self insertLine:nil before:cursorLine. |
|
5313 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5314 |
]. |
3781 | 5315 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5316 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5317 |
|
3310 | 5318 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5319 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5320 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5321 |
! |
5322 |
||
2952 | 5323 |
executeKeyboardMacro:cmdMacro |
5324 |
Error handle:[:ex | |
|
4823 | 5325 |
self warn:'Error in keyboard macro: ' , ex description. |
5326 |
ex return. |
|
2952 | 5327 |
] do:[ |
4823 | 5328 |
AbortOperationRequest handle:[:ex | |
5329 |
self warn:'Keyboard macro aborted'. |
|
5330 |
ex return. |
|
5331 |
] do:[ |
|
5332 |
Parser |
|
5333 |
evaluate:cmdMacro asString |
|
5334 |
receiver:self |
|
5335 |
notifying:nil |
|
5336 |
compile:false. |
|
5337 |
]. |
|
2952 | 5338 |
]. |
5339 |
! |
|
5340 |
||
5341 |
handleNonCommandKey:keyArg |
|
4700 | 5342 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5343 |
|
5344 |
self isReadOnly ifTrue:[ |
|
4988 | 5345 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5346 |
^ self. |
2952 | 5347 |
]. |
5348 |
||
5349 |
key := keyArg. |
|
5350 |
||
5351 |
typeOfSelection == #paste ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5352 |
"pasted selection will NOT be replaced by keystroke" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5353 |
self unselect |
2952 | 5354 |
]. |
5355 |
||
4700 | 5356 |
selStartLineBefore := selectionStartLine. |
5357 |
selStartColBefore := self selectionStartCol. |
|
5358 |
selEndLineBefore := selectionEndLine. |
|
5359 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5360 |
|
4940 | 5361 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5362 |
key isCharacter ifTrue:[ |
4940 | 5363 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5364 |
] ifFalse:[ |
4940 | 5365 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5366 |
]. |
2952 | 5367 |
]. |
5368 |
||
5369 |
"replace selection by what is typed in - |
|
3235 | 5370 |
if word was selected with a space, keep it. |
4700 | 5371 |
if there was no selection, the key's character is inserted" |
3235 | 5372 |
|
5373 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5374 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5375 |
]. |
2952 | 5376 |
|
5377 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5378 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5379 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5380 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5381 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5382 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5383 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5384 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5385 |
] |
3160 | 5386 |
]. |
2952 | 5387 |
selectStyle := nil. |
5388 |
||
3235 | 5389 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5390 |
selectionStartLine := selStartLineBefore. |
5391 |
selectionStartCol := selStartColBefore. |
|
5392 |
selectionEndLine := selEndLineBefore. |
|
5393 |
selectionEndCol := selEndColBefore. |
|
3235 | 5394 |
]. |
5395 |
||
2952 | 5396 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5397 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5398 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5399 |
"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
|
5400 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5401 |
" |
2952 | 5402 |
" |
4481 | 5403 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5404 |
" |
4481 | 5405 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5406 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5407 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5408 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5409 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5410 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5411 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5412 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5413 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5414 |
self cursorLine:line col:col. |
4940 | 5415 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5416 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5417 |
"/ 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
|
5418 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5419 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5420 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5421 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5422 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5423 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5424 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5425 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5426 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5427 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5428 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5429 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5430 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5431 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5432 |
] |
2952 | 5433 |
]. |
5434 |
||
5435 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5436 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5437 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5438 |
"/ |
|
5439 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5440 |
"/ self selection. |
|
5441 |
"/ typeOfSelection := #paste. |
|
3160 | 5442 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5443 |
"/ ]. |
3235 | 5444 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5445 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5446 |
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
|
5447 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5448 |
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
|
5449 |
]. |
3235 | 5450 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5451 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5452 |
|
5453 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5454 |
! |
5455 |
||
5456 |
keyPress:key x:x y:y |
|
5457 |
"handle keyboard input" |
|
5458 |
||
4771 | 5459 |
|wasOn| |
5460 |
||
5461 |
wasOn := cursorShown. |
|
5462 |
||
5463 |
NoModificationError handle:[:ex | |
|
4988 | 5464 |
self flashReadOnly. |
4771 | 5465 |
(cursorShown not and:[wasOn]) ifTrue:[ |
5466 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5467 |
]. |
|
5468 |
] do:[ |
|
5469 |
self undoableDo:[ |
|
5470 |
self doKeyPress:key x:x y:y |
|
5471 |
]. |
|
4242 | 5472 |
]. |
5473 |
self repairDamage |
|
5474 |
||
5475 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
2952 | 5476 |
! |
5477 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5478 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5479 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5480 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5481 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5482 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5483 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5484 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5485 |
requestAutoAccept |
5068 | 5486 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5487 |
This forces my value to be accepted into my model. |
|
5488 |
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
|
5489 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5490 |
acceptEnabled == false ifTrue:[ |
4823 | 5491 |
"/ nope - |
5492 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5493 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5494 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5495 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5496 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5497 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5498 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5499 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5500 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5501 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5502 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5503 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5504 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5505 |
cv notNil ifTrue:[ |
4823 | 5506 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5507 |
] |
4967 | 5508 |
! |
5509 |
||
5510 |
unmapped |
|
5511 |
super unmapped. |
|
5512 |
||
5513 |
completionSupport notNil ifTrue:[ |
|
5514 |
completionSupport release. |
|
5515 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5516 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5517 |
|
1807 | 5518 |
!EditTextView methodsFor:'focus handling'! |
5519 |
||
4818 | 5520 |
focusOut |
5521 |
super focusOut. |
|
5522 |
||
5523 |
completionSupport notNil ifTrue:[ |
|
5524 |
completionSupport release. |
|
5525 |
]. |
|
5526 |
! |
|
5527 |
||
1807 | 5528 |
hasKeyboardFocus:aBoolean |
5529 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5530 |
(otherwise, I would not know about this)" |
|
5531 |
||
5532 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5533 |
|
3160 | 5534 |
(cursorShown |
5535 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5536 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5537 |
self drawCursor |
5538 |
]. |
|
5539 |
||
5540 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5541 |
completionSupport notNil ifTrue:[ |
4821 | 5542 |
"/ this is a hack for Windows: |
5543 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5544 |
"/ then an activate is sent to the completion popup. |
|
5545 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5546 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5547 |
"/ before forcing it to be closed... |
|
5216 | 5548 |
Processor addTimedBlock:[completionSupport editViewLostFocus] afterMilliseconds:200. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5549 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5550 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5551 |
|
4821 | 5552 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5553 |
! |
5554 |
||
5555 |
showFocus:explicit |
|
5556 |
"in addition to however my superclass thinks how a focusView is to be |
|
5557 |
displayed, show the cursor when I got the focus" |
|
5558 |
||
5239 | 5559 |
self hasKeyboardFocus:true. |
1807 | 5560 |
self showCursor. |
5561 |
super showFocus:explicit |
|
5562 |
||
5563 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5564 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5565 |
|
4967 | 5566 |
showNoFocus:explicit |
5567 |
"the view lost the keyboard focus |
|
5568 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5569 |
- change any display attributes as req'd." |
|
5570 |
||
5571 |
super showNoFocus:explicit. |
|
5149 | 5572 |
|
5573 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
5574 |
"/ not when the focus is lost normally (because this also happens when |
|
5575 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
5576 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
5577 |
explicit ifTrue:[ |
|
5578 |
completionSupport notNil ifTrue:[ |
|
5579 |
completionSupport release. |
|
5580 |
]. |
|
4818 | 5581 |
]. |
5582 |
! |
|
5583 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5584 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5585 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5586 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5587 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5588 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5589 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5590 |
and:[self enabled |
4781 | 5591 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5592 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5593 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5594 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5595 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5596 |
^ false |
1807 | 5597 |
! ! |
5598 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5599 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5600 |
|
4237 | 5601 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5602 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5603 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5604 |
|
4482 | 5605 |
|cmdMacro| |
5606 |
||
5607 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5608 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5609 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5610 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5611 |
^ true |
4238 | 5612 |
|
5613 |
" |
|
4483 | 5614 |
EditTextView open |
4238 | 5615 |
contents:'bla'; |
5616 |
selectAll; |
|
5617 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5618 |
EditTextView open |
4238 | 5619 |
contents:'bla'; |
5620 |
selectAll; |
|
5621 |
executekeyboardMacroNamed:#blabla. |
|
5622 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5623 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5624 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5625 |
! |
5626 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
indent |
3221 | 5628 |
"indent a line-range - this is done by searching for the |
5629 |
last non-empty line before the selection, and changing the indent |
|
4742 | 5630 |
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
|
5631 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5633 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5635 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5636 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5638 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5639 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5640 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5641 |
self unselect. |
3160 | 5642 |
self |
3786 | 5643 |
undoableDo:[self indentFromLine:start toLine:end] |
5644 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5645 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5646 |
|
4237 | 5647 |
indentBy4 |
5050 | 5648 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
5649 |
||
5650 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5651 |
! |
|
5652 |
||
5653 |
indentBy8 |
|
5654 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 5655 |
|
5656 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5657 |
! |
|
5658 |
||
5050 | 5659 |
indentBy:n |
5660 |
|line1 line2| |
|
5661 |
||
5662 |
line1 := self selectionStartLine. |
|
5663 |
line2 := self selectionEndLine. |
|
5664 |
line1 isNil ifTrue:[ |
|
5665 |
line1 := self cursorLine. |
|
5666 |
line1 notNil ifTrue:[ |
|
5667 |
line2 := line1+1 |
|
5668 |
] |
|
5669 |
]. |
|
5670 |
line1 notNil ifTrue:[ |
|
5671 |
self indentFromLine:line1 toLine:line2 by:n. |
|
5672 |
] |
|
5673 |
! |
|
5674 |
||
5675 |
indentByTab |
|
5676 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
5677 |
! |
|
5678 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5679 |
indentFromLine:start toLine:end |
3221 | 5680 |
"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
|
5681 |
last non-empty line before start, and change the indent |
4742 | 5682 |
of the selected line-range based on that line's indent." |
5683 |
||
4811 | 5684 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5685 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5686 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5687 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5688 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5689 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5690 |
(delta == 0) ifTrue:[^ self]. |
4811 | 5691 |
self indentFromLine:start toLine:end by:delta |
5692 |
! |
|
5693 |
||
5694 |
indentFromLine:start toLine:end by:delta |
|
5695 |
"indent a line-range - this is done by searching for the |
|
5696 |
last non-empty line before start, and change the indent |
|
5697 |
of the selected line-range based on that line's indent." |
|
5698 |
||
5699 |
|d line spaces anyChange| |
|
5700 |
||
5701 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5702 |
(delta > 0) ifTrue:[ |
4742 | 5703 |
spaces := String new:delta |
5704 |
]. |
|
5705 |
||
5706 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5707 |
start to:end do:[:lineNr | |
4742 | 5708 |
line := self listAt:lineNr. |
5709 |
line notNil ifTrue:[ |
|
5710 |
line isBlank ifTrue:[ |
|
4771 | 5711 |
self basicListAt:lineNr put:nil |
4742 | 5712 |
] ifFalse:[ |
5713 |
(delta > 0) ifTrue:[ |
|
5714 |
line := spaces , line. |
|
5715 |
widthOfWidestLine notNil ifTrue:[ |
|
5716 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
5717 |
] |
|
5718 |
] ifFalse:[ |
|
5719 |
"check if deletion is ok" |
|
5720 |
d := delta negated + 1. |
|
5721 |
||
5722 |
line size > d ifTrue:[ |
|
5723 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
5724 |
line := line copyFrom:d |
|
5725 |
] |
|
5726 |
]. |
|
5727 |
widthOfWidestLine := nil |
|
5728 |
]. |
|
5729 |
self replaceLine:lineNr with:line. |
|
5730 |
anyChange := true. |
|
5731 |
] |
|
5732 |
] |
|
5733 |
]. |
|
5734 |
||
5735 |
anyChange ifTrue:[ self textChanged ]. |
|
5736 |
||
3221 | 5737 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5738 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5739 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5740 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5741 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5742 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5743 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5744 |
this is done by searching for the last non-empty line before it |
4823 | 5745 |
and returning its indent. |
5746 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5747 |
|
827 | 5748 |
"SHOULD GO TO ListView" |
5749 |
||
5750 |
|line lnr indent| |
|
5751 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5752 |
lnr := lineNr. |
827 | 5753 |
|
4823 | 5754 |
"/ [lnr ~~ 1] whileTrue:[ |
5755 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 5756 |
lnr := lnr - 1. |
5757 |
line := self listAt:lnr. |
|
5758 |
||
5759 |
line notNil ifTrue:[ |
|
5760 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5761 |
indent ~~ 0 ifTrue:[ |
|
5762 |
(line endsWith:$[) ifTrue:[ |
|
5763 |
^ indent + 4 - 1 |
|
5764 |
]. |
|
5765 |
^ indent - 1 |
|
5766 |
] |
|
5767 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5768 |
]. |
827 | 5769 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5770 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5771 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5772 |
! |
5773 |
||
5774 |
undentBy4 |
|
5050 | 5775 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
5776 |
||
5777 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5778 |
! |
|
5779 |
||
5780 |
undentBy8 |
|
5781 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 5782 |
|
5783 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 5784 |
! |
5785 |
||
5786 |
undentBy:n |
|
5787 |
self indentBy:(n negated) |
|
5788 |
! |
|
5789 |
||
5790 |
undentByTab |
|
5791 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 5792 |
! ! |
5793 |
||
0 | 5794 |
!EditTextView methodsFor:'initialization'! |
5795 |
||
941 | 5796 |
fetchDeviceResources |
5797 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5798 |
||
5799 |
super fetchDeviceResources. |
|
5800 |
||
4940 | 5801 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:self graphicsDevice]. |
5802 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:self graphicsDevice]. |
|
5803 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:self graphicsDevice]. |
|
941 | 5804 |
|
5805 |
"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
|
5806 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5807 |
! |
5808 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5809 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5810 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5811 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5812 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5813 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5814 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5815 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5816 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5817 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5818 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5819 |
super initStyle. |
4576 | 5820 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5821 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5822 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5823 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5824 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5825 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5826 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 5827 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
5828 |
cursorTypeNoFocus isNil ifTrue:[ |
|
5829 |
cursorTypeNoFocus := cursorType. |
|
5830 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
5831 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
5832 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5833 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5834 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5835 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 5836 |
cursorType ~~ #block ifTrue:[ |
5837 |
cursorNoFocusFgColor := cursorBgColor |
|
5838 |
] ifFalse:[ |
|
5839 |
cursorNoFocusFgColor := cursorFgColor |
|
5840 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5841 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5842 |
|
2088 | 5843 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5844 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5845 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5846 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5847 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5848 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5849 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5850 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5851 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5852 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5853 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5854 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5855 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5856 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5857 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5858 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5859 |
cursorCol := 1. |
5251 | 5860 |
cursorLineHolder := ValueHolder with:1. |
5861 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 5862 |
modifiedChannel := ValueHolder with:false. |
5863 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
5864 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5865 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5866 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5867 |
tabMeansNextField := false. |
5106 | 5868 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
5869 |
autoIndent := false. |
|
5251 | 5870 |
editMode := ValueHolder with:EditMode insertMode. |
5871 |
learnMode := ValueHolder with:false. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5872 |
trimBlankLines := self st80EditMode not. |
2131 | 5873 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 5874 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
5875 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5876 |
"/ enable drop by default |
2589 | 5877 |
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
|
5878 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5879 |
undoSupport := UndoSupport for:self. |
5251 | 5880 |
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
|
5881 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5882 |
"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
|
5883 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5884 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5885 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5886 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5887 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5888 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5889 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5890 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5891 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5892 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5893 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5894 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 5895 |
! |
5896 |
||
5897 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5898 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5899 |
completionSupport release |
4771 | 5900 |
]. |
5901 |
super release |
|
0 | 5902 |
! ! |
5903 |
||
2580 | 5904 |
!EditTextView methodsFor:'macros'! |
5905 |
||
5906 |
executeLearnedKeyboardMacro |
|
4673 | 5907 |
"replay the characters as learned previously" |
5908 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5909 |
(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
|
5910 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5911 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5912 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5913 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5914 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5915 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5916 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5917 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5918 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5919 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5920 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5921 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5922 |
]. |
2580 | 5923 |
] ifFalse:[ |
5153 | 5924 |
self flash:'no macro'. |
2580 | 5925 |
]. |
5926 |
! |
|
5927 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5928 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5929 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5930 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5931 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5932 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5933 |
|
2580 | 5934 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5935 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5936 |
|
2580 | 5937 |
|fg bg| |
5938 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5939 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5940 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5941 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5942 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5943 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5944 |
bg := Color black. |
2580 | 5945 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5946 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5947 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 5948 |
]. |
5949 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5950 |
! |
|
5951 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5952 |
learnModeHolder |
4673 | 5953 |
"a holder returning true, if in learn mode" |
5954 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5955 |
learnMode isNil ifTrue:[ |
5251 | 5956 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5957 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5958 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5959 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5960 |
|
4673 | 5961 |
rememberLearnedMacroAs: nameString |
5962 |
Macros isNil ifTrue:[ |
|
5963 |
Macros := Dictionary new. |
|
5964 |
]. |
|
5965 |
Macros at:nameString put:learnedMacro |
|
5966 |
! |
|
5967 |
||
2580 | 5968 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5969 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5970 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5971 |
self learnMode:(self learnMode not). |
2580 | 5972 |
! ! |
5973 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
5974 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 5975 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5976 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5977 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5978 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5979 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5980 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5981 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5982 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5983 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5984 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
5985 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 5986 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
5987 |
] do:[ |
|
5988 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5989 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5990 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5991 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5992 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5993 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5994 |
self unselect. |
3799 | 5995 |
self |
5996 |
undoablePaste:translated |
|
5997 |
info:'Translate' |
|
3495 | 5998 |
|
5999 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6000 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6001 |
|
3517 | 6002 |
compareWithClipboard |
6003 |
"compare the selection against the clipboard contents" |
|
6004 |
||
6005 |
|t1 t2| |
|
6006 |
||
6007 |
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
|
6008 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6009 |
Dialog information:'Clipboard is empty.'. |
6010 |
^ self. |
|
3517 | 6011 |
]. |
6012 |
||
6013 |
self hasSelection ifTrue:[ |
|
4823 | 6014 |
t1 := self selectionAsString. |
3517 | 6015 |
] ifFalse:[ |
4823 | 6016 |
t1 := self contents asString |
3517 | 6017 |
]. |
6018 |
t1 := t1 string. |
|
6019 |
||
6020 |
t1 = t2 ifTrue:[ |
|
4823 | 6021 |
Dialog information:'Strings are equal.'. |
6022 |
^ self. |
|
3517 | 6023 |
]. |
6024 |
DiffTextView |
|
4823 | 6025 |
openOn:t1 label:'Editor' |
6026 |
and:t2 label:'Clipboard' |
|
3517 | 6027 |
! |
6028 |
||
121 | 6029 |
cut |
6030 |
"cut selection into copybuffer" |
|
6031 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6032 |
self deleteCopyToClipboard:true |
121 | 6033 |
! |
6034 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6035 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6036 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6037 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6038 |
cursorLine notNil ifTrue:[ |
4823 | 6039 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6040 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6041 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6042 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6043 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6044 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6045 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6046 |
|
4129 | 6047 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6048 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6049 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6050 |
self flashReadOnly. |
3786 | 6051 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6052 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6053 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6054 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6055 |
sel notNil ifTrue:[ |
4129 | 6056 |
self setLastStringToReplace: sel. |
4053 | 6057 |
|
3786 | 6058 |
line := selectionStartLine. |
6059 |
col := selectionStartCol. |
|
6060 |
||
6061 |
toClipboard ifTrue:[ |
|
6062 |
" |
|
6063 |
remember in CopyBuffer |
|
6064 |
" |
|
6065 |
self setClipboardText:sel. "/ lastString. |
|
6066 |
]. |
|
6067 |
||
6068 |
" |
|
6069 |
append to DeleteHistory (if there is one) |
|
6070 |
" |
|
6071 |
history := Smalltalk at:#DeleteHistory. |
|
6072 |
history notNil ifTrue:[ |
|
6073 |
history addAll:(sel asStringCollection). |
|
6074 |
history size > 1000 ifTrue:[ |
|
6075 |
history := history copyFrom:(history size - 1000) |
|
6076 |
]. |
|
6077 |
]. |
|
6078 |
||
6079 |
" |
|
6080 |
now, delete it |
|
6081 |
" |
|
6082 |
self |
|
6083 |
undoableDo:[self deleteSelection] |
|
6084 |
info:'Delete'. |
|
4048 | 6085 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6086 |
] ifFalse:[ |
3786 | 6087 |
" |
6088 |
a cut without selection will search&cut again |
|
6089 |
" |
|
6090 |
self undoableDo:[ |
|
6091 |
self again |
|
6092 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6093 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6094 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6095 |
"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
|
6096 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6097 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6098 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6099 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6100 |
|
3781 | 6101 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
6102 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 6103 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6104 |
#ToggleAutoIndent #ToggleInsertMode |
6105 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6106 |
<resource: #programMenu> |
1054 | 6107 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6108 |
|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
|
6109 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6110 |
|
2460 | 6111 |
items := #( |
3781 | 6112 |
('Redo' redo Redo ) |
6113 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 6114 |
('-' ) |
6115 |
('Search...' search Find ) |
|
6116 |
('Goto Line...' gotoLine GotoLine ) |
|
6117 |
('-' ) |
|
4940 | 6118 |
('Tools' tools ) |
6119 |
('Insert Unicode...' insertUnicode ) |
|
6120 |
). |
|
4213 | 6121 |
CharacterSetView notNil ifTrue:[ |
6122 |
items := items , |
|
6123 |
#( |
|
6124 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6125 |
). |
|
6126 |
]. |
|
6127 |
items := items , #( |
|
3731 | 6128 |
('-' ) |
6129 |
('Save As...' save SaveAs ) |
|
6130 |
('Print' doPrint Print ) |
|
6131 |
('=' ) |
|
4213 | 6132 |
('Misc' misc ShiftCtrl) ). |
2460 | 6133 |
|
2866 | 6134 |
miscItems := #( |
3781 | 6135 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6136 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 6137 |
('-' ) |
6138 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 6139 |
('Join Lines' joinLines Join ) |
4388 | 6140 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 6141 |
('-' ) |
3781 | 6142 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
6143 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6144 |
('-' ) |
3811 | 6145 |
('Insert File...' insertFile ) |
6146 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6147 |
('Insert new UUID' insertUUID ) |
6148 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6149 |
('-' ) |
6150 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6151 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6152 |
('-' ) |
6153 |
). |
|
4213 | 6154 |
"/ CharacterSetView notNil ifTrue:[ |
6155 |
"/ miscItems := miscItems , |
|
6156 |
"/ #( |
|
6157 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6158 |
"/ ). |
|
6159 |
"/ ]. |
|
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
6160 |
miscItems := miscItems , |
3731 | 6161 |
#( |
6162 |
('Font...' changeFont ) |
|
2870 | 6163 |
"/ ('Encoding...' changeEncoding ) |
3731 | 6164 |
). |
2866 | 6165 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6166 |
translateItems := #( |
3731 | 6167 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6168 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6169 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6170 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6171 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6172 |
('-' ) |
|
6173 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6174 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6175 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6176 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6177 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6178 |
). |
|
3221 | 6179 |
|
6180 |
sortItems := #( |
|
3731 | 6181 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6182 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6183 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6184 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6185 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6186 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6187 |
('-' ) |
|
4373 | 6188 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6189 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6190 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6191 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6192 |
('-' ) |
6193 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6194 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6195 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6196 |
|
2762 | 6197 |
toolItems := #( |
3731 | 6198 |
('Indent' indent ) |
4287 | 6199 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6200 |
('Sort' sort ) |
6201 |
('-' ) |
|
4742 | 6202 |
('Google Spell Check' googleSpellingSuggestion ) |
6203 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6204 |
('Translate' babelFishTranslate ) |
6205 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6206 |
). |
|
2762 | 6207 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6208 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6209 |
toolItems := toolItems , #( |
6210 |
('-' ) |
|
6211 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6212 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6213 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6214 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6215 |
|
2460 | 6216 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6217 |
sub receiver:self. |
2460 | 6218 |
|
2919 | 6219 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6220 |
toolSub receiver:self. |
|
6221 |
sub subMenuAt:#tools put:toolSub. |
|
6222 |
||
3495 | 6223 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6224 |
transSub receiver:self. |
|
6225 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6226 |
||
6227 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6228 |
sortSub receiver:self. |
|
6229 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6230 |
|
2866 | 6231 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6232 |
subSub receiver:self. |
|
2952 | 6233 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6234 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6235 |
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
|
6236 |
|
2866 | 6237 |
sub subMenuAt:#misc put:subSub. |
6238 |
||
3495 | 6239 |
mainItems := #( |
3731 | 6240 |
('Undo' undo Undo ) |
6241 |
('Again' again Again ) |
|
6242 |
('-' ) |
|
6243 |
('Cut' cut Cut ) |
|
6244 |
('Copy' copySelection Copy ) |
|
6245 |
('Paste' pasteOrReplace Paste ) |
|
6246 |
('-' ) |
|
6247 |
('Accept' accept Accept ) |
|
6248 |
('=' ) |
|
6249 |
('More' others Ctrl ) |
|
6250 |
). |
|
3495 | 6251 |
main := PopUpMenu itemList:mainItems resources:resources. |
6252 |
main subMenuAt:#others put:sub. |
|
6253 |
||
6254 |
sensor := self sensor. |
|
6255 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6256 |
sensor shiftDown ifTrue:[ |
|
3731 | 6257 |
m := subSub |
6258 |
] ifFalse:[ |
|
6259 |
m := sub |
|
6260 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6261 |
] ifFalse:[ |
3731 | 6262 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6263 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6264 |
|
4742 | 6265 |
"/ the 'Smalltalk at:' code is here to |
6266 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6267 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6268 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6269 |
m disable:#googleSpellingSuggestion |
|
2676 | 6270 |
]. |
4742 | 6271 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6272 |
m disable:#internalSpellingSuggestion |
|
6273 |
]. |
|
2676 | 6274 |
|
3811 | 6275 |
HTTPInterface isNil ifTrue:[ |
6276 |
m disableAll:#(insertURL) |
|
6277 |
]. |
|
6278 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6279 |
self isReadOnly ifTrue:[ |
4475 | 6280 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6281 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6282 |
cut indent autoIndent: insertMode: |
|
3811 | 6283 |
insertFile insertFileAsStringLiteral insertURL |
6284 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6285 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6286 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
4940 | 6287 |
insertUnicode specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6288 |
]. |
2817 | 6289 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6290 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6291 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6292 |
self hasSelection ifFalse:[ |
3731 | 6293 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt openWorkspaceWithIt sort indent). |
2762 | 6294 |
] ifTrue:[ |
3731 | 6295 |
(Error handle:[:ex | |
6296 |
ex return:false |
|
6297 |
] do:[ |
|
4042 | 6298 |
|fn| |
6299 |
fn := self selectionAsString. |
|
6300 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6301 |
]) ifFalse:[ |
6302 |
m disableAll:#(openFileBrowserOnIt). |
|
6303 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6304 |
]. |
2569 | 6305 |
self hasUndoAction ifFalse:[ |
3731 | 6306 |
m disable:#undo. |
3115 | 6307 |
] ifTrue:[ |
3731 | 6308 |
what := undoSupport undoActionInfo. |
6309 |
what notNil ifTrue:[ |
|
6310 |
undoIdx := m indexOf:#undo. |
|
6311 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6312 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6313 |
]. |
2952 | 6314 |
self hasRedoAction ifFalse:[ |
3731 | 6315 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6316 |
] ifTrue:[ |
3731 | 6317 |
what := undoSupport redoActionInfo. |
6318 |
what notNil ifTrue:[ |
|
6319 |
redoIdx := sub indexOf:#redo. |
|
6320 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6321 |
] |
|
2952 | 6322 |
]. |
5216 | 6323 |
self canAccept ifFalse:[ |
3731 | 6324 |
m disable:#accept |
1108 | 6325 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6326 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6327 |
|
4388 | 6328 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6329 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6330 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6331 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6332 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6333 |
|
4940 | 6334 |
history := self graphicsDevice getCopyBufferHistory copy. |
3160 | 6335 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6336 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6337 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6338 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6339 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6340 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6341 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6342 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6343 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6344 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6345 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6346 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6347 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6348 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6349 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6350 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6351 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6352 |
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
|
6353 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6354 |
box show. |
3160 | 6355 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6356 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6357 |
"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
|
6358 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6359 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6360 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6361 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6362 |
self sensor shiftDown ifTrue:[ |
3855 | 6363 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6364 |
]. |
2724 | 6365 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6366 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6367 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6368 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6369 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6370 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6371 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6372 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6373 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6374 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6375 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6376 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6377 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6378 |
"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
|
6379 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6380 |
|
2676 | 6381 |
googleSpellingSuggestion |
6382 |
"insert the google-spelling suggestion for the selected text. |
|
6383 |
Requires that the SOAP stuff is loaded and working." |
|
6384 |
||
2677 | 6385 |
|text suggestion| |
2676 | 6386 |
|
6387 |
self withWaitCursorDo:[ |
|
3799 | 6388 |
text := self selection asString string withoutSeparators. |
6389 |
text size == 0 ifTrue:[^ self]. |
|
6390 |
||
4742 | 6391 |
"/ the 'Smalltalk at:' code is here to |
6392 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6393 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6394 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6395 |
^ self. |
|
6396 |
] do:[ |
|
4742 | 6397 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6398 |
]. |
6399 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6400 |
self information:('No spelling suggestion from Google for: ' , text). |
6401 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6402 |
^ self. |
6403 |
]. |
|
6404 |
]. |
|
6405 |
self |
|
6406 |
undoablePaste:suggestion |
|
6407 |
info:'Spelling Suggestion'. |
|
3495 | 6408 |
|
6409 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6410 |
! |
6411 |
||
3595 | 6412 |
insertDateAndTime |
6413 |
"insert the curent date and time string" |
|
6414 |
||
6415 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6416 |
self |
3786 | 6417 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6418 |
info:'Paste Date and Time' |
3595 | 6419 |
! |
6420 |
||
2676 | 6421 |
insertFile |
3160 | 6422 |
"insert contents of a file |
2676 | 6423 |
- ask user for filename using a fileSelectionBox." |
6424 |
||
3731 | 6425 |
self insertFileAsStringLiteral:false |
6426 |
! |
|
6427 |
||
6428 |
insertFileAsStringLiteral |
|
6429 |
"insert a file's contents as a string literal. |
|
6430 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6431 |
to make it a legal string literal" |
|
6432 |
||
6433 |
self insertFileAsStringLiteral:true |
|
6434 |
! |
|
6435 |
||
6436 |
insertFileAsStringLiteral:asStringLiteral |
|
6437 |
"insert contents of a file; either as-is or as a string literal. |
|
6438 |
- ask user for filename using a fileSelectionBox." |
|
6439 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6440 |
|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
|
6441 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6442 |
((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
|
6443 |
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
|
6444 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6445 |
ifTrue:[ |
3731 | 6446 |
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
|
6447 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6448 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6449 |
[ |
3731 | 6450 |
|why| |
6451 |
||
6452 |
file := Dialog |
|
6453 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6454 |
default:initial |
|
6455 |
ok:(resources string:'Insert') |
|
6456 |
abort:(resources string:'Cancel') |
|
6457 |
pattern:nil |
|
6458 |
fromDirectory:directoryForFileDialog. |
|
6459 |
file isNil ifTrue:[ |
|
6460 |
"cancel" |
|
6461 |
^ self. |
|
6462 |
]. |
|
6463 |
file := file asFilename. |
|
6464 |
directoryForFileDialog := file. |
|
6465 |
||
6466 |
ok := file isReadable and:[file isDirectory not]. |
|
6467 |
ok ifFalse:[ |
|
6468 |
file isReadable ifFalse:[ |
|
6469 |
why := '%1 is unreadable.\\Please try again.' |
|
6470 |
] ifTrue:[ |
|
6471 |
why := '%1 is a directory.\\Please try again.' |
|
6472 |
]. |
|
6473 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6474 |
]. |
|
2909 | 6475 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6476 |
|
5063 | 6477 |
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
|
6478 |
self |
3786 | 6479 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6480 |
info:'Paste File' |
3495 | 6481 |
|
6482 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6483 |
! |
|
6484 |
||
3811 | 6485 |
insertURL |
6486 |
"insert contents of a URL |
|
6487 |
- ask user for URL using a dialog." |
|
6488 |
||
6489 |
self insertURLAsStringLiteral:false |
|
6490 |
! |
|
6491 |
||
6492 |
insertURLAsStringLiteral:asStringLiteral |
|
6493 |
"insert contents of a file; either as-is or as a string literal. |
|
6494 |
- ask user for filename using a fileSelectionBox." |
|
6495 |
||
6496 |
|sel url text response initial| |
|
6497 |
||
6498 |
(sel := self selectionAsString) notEmptyOrNil |
|
6499 |
ifTrue:[ |
|
6500 |
initial := sel. |
|
6501 |
]. |
|
6502 |
||
6503 |
url := Dialog |
|
6504 |
request:(resources string:'Insert Contents of URL:') |
|
6505 |
initialAnswer:initial |
|
6506 |
okLabel:(resources string:'Insert') |
|
6507 |
title:(resources string:'URL'). |
|
6508 |
url isNil ifTrue:[ |
|
6509 |
"cancel" |
|
6510 |
^ self. |
|
6511 |
]. |
|
6512 |
response := HTTPInterface get:url. |
|
6513 |
response isErrorResponse ifTrue:[ |
|
6514 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6515 |
^ self. |
|
6516 |
]. |
|
6517 |
text := response data asString. |
|
6518 |
||
6519 |
self |
|
6520 |
undoableDo:[ |
|
6521 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6522 |
] |
|
6523 |
info:'Insert Contents of URL' |
|
6524 |
! |
|
6525 |
||
3495 | 6526 |
insertUUID |
6527 |
"insert a new UUID's string" |
|
6528 |
||
6529 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6530 |
self |
3786 | 6531 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6532 |
info:'Paste New UUID' |
3495 | 6533 |
|
6534 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6535 |
! |
6536 |
||
4940 | 6537 |
insertUnicode |
6538 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6539 |
||
6540 |
|unicodePoint unicodeChar unicodeString| |
|
6541 |
||
6542 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6543 |
unicodeString size < 2 ifTrue:[ |
|
6544 |
^ self. |
|
6545 |
]. |
|
6546 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6547 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6548 |
] ifFalse:[ |
|
6549 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6550 |
]. |
|
6551 |
||
6552 |
unicodeChar := Character value:unicodePoint. |
|
6553 |
self keyPress:unicodeChar x:0 y:0. |
|
6554 |
self keyRelease:unicodeChar x:0 y:0. |
|
6555 |
! |
|
6556 |
||
4742 | 6557 |
internalSpellingSuggestion |
6558 |
"insert the internal-spelling suggestion for the selected text. |
|
6559 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6560 |
||
6561 |
|text suggestions best| |
|
6562 |
||
6563 |
self withWaitCursorDo:[ |
|
6564 |
text := self selection asString string withoutSeparators. |
|
6565 |
text size == 0 ifTrue:[^ self]. |
|
6566 |
||
6567 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6568 |
suggestions size == 0 ifTrue:[ |
|
6569 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6570 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6571 |
^ self. |
|
6572 |
]. |
|
6573 |
Transcript showCR:suggestions. |
|
6574 |
best := suggestions first. |
|
6575 |
]. |
|
6576 |
self |
|
6577 |
undoablePaste:best |
|
6578 |
info:'Spelling Suggestion'. |
|
6579 |
! |
|
6580 |
||
4884 | 6581 |
openFileBrowserOnFileNamed:fileNameString |
6582 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 6583 |
|
4630 | 6584 |
|fn| |
2762 | 6585 |
|
4884 | 6586 |
fn := fileNameString asFilename. |
2762 | 6587 |
fn exists ifFalse:[ |
4884 | 6588 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 6589 |
fn exists ifFalse:[ |
5082 | 6590 |
^ self warn:(resources |
6591 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
6592 |
with:fn baseName allBold |
|
6593 |
with:fn directory baseName allBold). |
|
4042 | 6594 |
]. |
2762 | 6595 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6596 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6597 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6598 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6599 |
! |
6600 |
||
4884 | 6601 |
openFileBrowserOnIt |
6602 |
"open a fileBrowser on the selected fileName" |
|
6603 |
||
6604 |
|fileNameString| |
|
6605 |
||
6606 |
fileNameString := self selectionAsString. |
|
6607 |
self openFileBrowserOnFileNamed:fileNameString |
|
6608 |
||
6609 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
6610 |
! |
|
6611 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6612 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6613 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6614 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6615 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6616 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6617 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6618 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6619 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6620 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6621 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6622 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6623 |
paste |
1289 | 6624 |
"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
|
6625 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6626 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6627 |
self checkModificationsAllowed ifTrue:[ |
4823 | 6628 |
self withSelfAndTextForPasteDo:[:me :text | |
6629 |
me unselect. |
|
6630 |
me undoablePaste:text |
|
6631 |
] |
|
2952 | 6632 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6633 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6635 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6636 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6637 |
|
3825 | 6638 |
self paste:someText withCR:false |
6639 |
! |
|
6640 |
||
6641 |
paste:someText withCR:withCR |
|
6642 |
"paste someText at cursor" |
|
6643 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6644 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6645 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6646 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6647 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6648 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6649 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6650 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6651 |
CharacterEncoderError handle:[:ex | |
3825 | 6652 |
|code msg| |
6653 |
||
6654 |
code := ex parameter. |
|
6655 |
codingErrorReported ifFalse:[ |
|
4940 | 6656 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 6657 |
code notNil ifTrue:[ |
6658 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6659 |
]. |
|
6660 |
Dialog warn:(resources stringWithCRs:msg). |
|
6661 |
codingErrorReported := true. |
|
6662 |
]. |
|
6663 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6664 |
] do:[ |
3825 | 6665 |
s isString ifTrue:[ |
4940 | 6666 |
s encoding ~~ gc characterEncoding ifTrue:[ |
6667 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 6668 |
]. |
6669 |
||
6670 |
s := s asStringCollection. |
|
6671 |
(someText endsWith:Character cr) ifTrue:[ |
|
6672 |
"/ s := s copyWith:nil. |
|
6673 |
s := s copyWith:'' "/ an empty line at the end |
|
6674 |
||
6675 |
] |
|
6676 |
] ifFalse:[ |
|
6677 |
s isStringCollection ifTrue:[ |
|
4940 | 6678 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 6679 |
] ifFalse:[ |
6680 |
(self |
|
6681 |
confirm:(resources |
|
6682 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6683 |
with:s class name)) ifFalse:[^ self]. |
|
6684 |
s := StringCollection with:s storeString . |
|
6685 |
"/ ^ self |
|
6686 |
]. |
|
6687 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6688 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6689 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6690 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6691 |
(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
|
6692 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6693 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6694 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6695 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6696 |
startCol := c1 := cursorCol. |
3180 | 6697 |
|
5194 | 6698 |
"do not autoindent here. |
6699 |
It does make things very ugly, in the inspector |
|
6700 |
(try inspecting a multiline string)..." |
|
6701 |
self withAutoIndent:false do:[ |
|
6702 |
"do not expand tabs into spaces here - |
|
6703 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
6704 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6705 |
||
6706 |
self insertLines:s withCR:withCR. |
|
6707 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6708 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6709 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6710 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6711 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6712 |
|
4328 | 6713 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6714 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6715 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6716 |
|
3731 | 6717 |
pasteAsStringLiteral |
6718 |
"insert clipboard string as a string literal. |
|
6719 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6720 |
to make it a legal string literal" |
|
6721 |
||
6722 |
typeOfSelection := nil. |
|
6723 |
self |
|
5107 | 6724 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 6725 |
info:'Paste as String Literal' |
3731 | 6726 |
! |
6727 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6728 |
pasteOrReplace |
1289 | 6729 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6730 |
otherwise paste at cursor position. |
6731 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6732 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6733 |
|
2724 | 6734 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6735 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6736 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6737 |
pasteOrReplace:someText |
1289 | 6738 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6739 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6740 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6741 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6742 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6743 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6744 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6745 |
self undoableDo:[ |
4823 | 6746 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
6747 |
self replace:someText |
|
6748 |
] ifFalse:[ |
|
6749 |
self paste:someText. |
|
6750 |
] |
|
3542 | 6751 |
] info:'Paste/Replace'. |
1289 | 6752 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6753 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6754 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6755 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6756 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6757 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6758 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6759 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6760 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6761 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6762 |
self checkModificationsAllowed ifFalse:[ |
4988 | 6763 |
self flashReadOnly. |
4823 | 6764 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6765 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6766 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6767 |
text notNil ifTrue:[ |
4823 | 6768 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6769 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6770 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6771 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6772 |
replace |
1289 | 6773 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6774 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6775 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6776 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6777 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6778 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 6779 |
me undoableDo:[ me replace:text ] |
6780 |
info:'Replace' |
|
2952 | 6781 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6782 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6783 |
|
121 | 6784 |
replace:someText |
1289 | 6785 |
"replace the selection by someText" |
121 | 6786 |
|
3160 | 6787 |
|selected selectedString |
6788 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 6789 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6790 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6791 |
|
3130 | 6792 |
self undoableDo:[ |
4010 | 6793 |
selected := self selection. |
6794 |
selected isNil ifTrue:[ |
|
6795 |
^ self paste:someText |
|
6796 |
]. |
|
6797 |
||
6798 |
self deleteSelection. |
|
6799 |
||
6800 |
"take care, if we replace a selection without space by a word selected |
|
6801 |
with one - in this case we usually do not want the space. |
|
6802 |
But, if we replace a word-selected selection by something without a |
|
6803 |
space, we DO want the space added." |
|
6804 |
||
6805 |
selected size == 1 ifTrue:[ |
|
6806 |
selectedString := selected at:1. |
|
6807 |
]. |
|
6808 |
||
6809 |
someText size == 1 ifTrue:[ |
|
6810 |
|cutOffSpace addSpace replacement replacementString| |
|
6811 |
||
6812 |
cutOffSpace := false. |
|
6813 |
addSpace := false. |
|
6814 |
replacement := someText copyFrom:1. |
|
6815 |
||
6816 |
selectedString notNil ifTrue:[ |
|
6817 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
6818 |
"selection has no space" |
|
6819 |
||
6820 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
6821 |
cutOffSpace := true |
|
6822 |
] |
|
6823 |
] ifTrue:[ |
|
6824 |
addSpace := true |
|
6825 |
] |
|
6826 |
]. |
|
6827 |
replacementString := replacement at:1. |
|
6828 |
cutOffSpace ifTrue:[ |
|
6829 |
(replacementString startsWith:' ') ifTrue:[ |
|
6830 |
replacementString := replacementString withoutSpaces |
|
6831 |
]. |
|
6832 |
] ifFalse:[ |
|
6833 |
selectStyle == #wordLeft ifTrue:[ |
|
6834 |
"want a space at left" |
|
6835 |
(replacementString startsWith:' ') ifFalse:[ |
|
6836 |
replacementString := replacementString withoutSpaces. |
|
6837 |
replacementString := ' ' , replacementString |
|
6838 |
] |
|
6839 |
]. |
|
6840 |
selectStyle == #wordRight ifTrue:[ |
|
6841 |
"want a space at right" |
|
6842 |
||
6843 |
(replacementString endsWith:' ') ifFalse:[ |
|
6844 |
replacementString := replacementString withoutSpaces. |
|
6845 |
replacementString := replacementString , ' ' |
|
6846 |
] |
|
6847 |
]. |
|
6848 |
]. |
|
6849 |
replacement at:1 put: replacementString. |
|
6850 |
self paste:replacement. |
|
6851 |
] ifFalse:[ |
|
6852 |
self paste:someText |
|
6853 |
]. |
|
4053 | 6854 |
self setLastStringToReplace: selectedString. |
6855 |
||
4048 | 6856 |
lastReplacementInfo lastReplacement: someText. |
4010 | 6857 |
|
6858 |
selStartLine := selectionStartLine. |
|
6859 |
selStartCol := self selectionStartCol. |
|
6860 |
selEndLine := selectionEndLine. |
|
6861 |
selEndCol := self selectionEndCol. |
|
3130 | 6862 |
] |
3542 | 6863 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
6864 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6865 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6866 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 6867 |
! |
6868 |
||
3430 | 6869 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6870 |
"search for a string - show a box to enter searchpattern |
3430 | 6871 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
6872 |
- 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
|
6873 |
|
3430 | 6874 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
6875 |
||
6876 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
6877 |
lastSearchDirection := #forward. |
|
6878 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 6879 |
caseHolder := ValueHolder with:ign. |
6880 |
patternHolder := ValueHolder with:''. |
|
6881 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 6882 |
lastSearchPattern notNil ifTrue:[ |
4823 | 6883 |
initialString := lastSearchPattern |
3430 | 6884 |
]. |
6885 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 6886 |
initialString := self selectionAsString |
3430 | 6887 |
]. |
6888 |
initialString isNil ifTrue:[ |
|
4823 | 6889 |
LastSearchPatterns size > 0 ifTrue:[ |
6890 |
initialString := LastSearchPatterns first |
|
6891 |
] |
|
3430 | 6892 |
]. |
6893 |
initialString notNil ifTrue:[ |
|
4823 | 6894 |
patternHolder value:initialString. |
6895 |
replacePatternHolder value:initialString. |
|
3430 | 6896 |
]. |
6897 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6898 |
search := [:fwd | |
4823 | 6899 |
self |
6900 |
search:patternHolder value |
|
6901 |
ignoreCase:caseHolder value |
|
6902 |
forward:fwd. |
|
6903 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6904 |
replace := [:all | |
4823 | 6905 |
self |
6906 |
replace:patternHolder value |
|
6907 |
by:replacePatternHolder value |
|
6908 |
all:all |
|
6909 |
ignoreCase:caseHolder value |
|
6910 |
]. |
|
3430 | 6911 |
bindings := IdentityDictionary new. |
6912 |
bindings at:#searchPattern put:patternHolder. |
|
6913 |
bindings at:#replacePattern put:replacePatternHolder. |
|
6914 |
modal ifTrue:[ |
|
4823 | 6915 |
bindings at:#nextAction |
6916 |
put:[ |
|
6917 |
flag := true. |
|
6918 |
action := search. |
|
6919 |
searchBox doAccept. |
|
6920 |
]. |
|
6921 |
bindings at:#prevAction |
|
6922 |
put:[ |
|
6923 |
flag := false. |
|
6924 |
action := search. |
|
6925 |
searchBox doAccept. |
|
6926 |
]. |
|
6927 |
bindings at:#replaceAction |
|
6928 |
put:[ |
|
6929 |
flag := false. |
|
6930 |
action := replace. |
|
6931 |
searchBox doAccept. |
|
6932 |
]. |
|
6933 |
bindings at:#replaceAllAction |
|
6934 |
put:[ |
|
6935 |
flag := true. |
|
6936 |
action := replace. |
|
6937 |
searchBox doAccept. |
|
6938 |
]. |
|
3430 | 6939 |
] ifFalse:[ |
4823 | 6940 |
bindings at:#nextAction put:[ search value:true. ]. |
6941 |
bindings at:#prevAction put:[ search value:false. ]. |
|
6942 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
6943 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 6944 |
]. |
6945 |
bindings at:#ignoreCase put:caseHolder. |
|
6946 |
bindings at:#patternList put:LastSearchPatterns. |
|
6947 |
modal ifTrue:[ |
|
4823 | 6948 |
searchBox := SimpleDialog new. |
3430 | 6949 |
] ifFalse:[ |
4823 | 6950 |
searchBox := ApplicationModel new. |
6951 |
searchBox createBuilder. |
|
3430 | 6952 |
]. |
6953 |
searchBox resources:(self resources). |
|
6954 |
bldr := searchBox builder. |
|
6955 |
bldr addBindings:bindings. |
|
6956 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
6957 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
6958 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
6959 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
6960 |
modal ifTrue:[ |
|
4823 | 6961 |
searchBox openDialog. |
6962 |
searchBox accepted ifTrue:[ |
|
6963 |
action value:flag |
|
6964 |
]. |
|
3430 | 6965 |
] ifFalse:[ |
4823 | 6966 |
(bldr componentAt:#nextButton) isReturnButton:false. |
6967 |
(bldr componentAt:#cancelButton) |
|
6968 |
label:(resources string:'Close'); |
|
6969 |
action:[ searchBox closeRequest ]. |
|
6970 |
||
6971 |
"/ searchBox masterApplication:self application. |
|
6972 |
||
6973 |
self topView beMaster. |
|
6974 |
(searchBox window) |
|
6975 |
beSlave; |
|
6976 |
openInGroup:(self windowGroup). |
|
6977 |
||
6978 |
"/ searchBox window open. |
|
6979 |
||
6980 |
searchBox window assignKeyboardFocusToFirstInputField. |
|
3430 | 6981 |
] |
6982 |
||
6983 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6984 |
! |
|
6985 |
||
121 | 6986 |
showDeleted |
6987 |
"open a readonly editor on all deleted text" |
|
6988 |
||
6989 |
|v| |
|
6990 |
||
6991 |
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
|
6992 |
v readOnly:true. |
121 | 6993 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6994 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6995 |
|
3221 | 6996 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 6997 |
"sort/reorder the selected lines. |
6998 |
how: |
|
6999 |
#lines |
|
7000 |
#linesByFirstWord |
|
7001 |
#linesByNthWord |
|
7002 |
#linesByNthNumber |
|
7003 |
#linesByNthHexNumber |
|
7004 |
#words |
|
7005 |
#linesByLength |
|
7006 |
#reverse |
|
7007 |
" |
|
7008 |
||
7009 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7010 |
|
7011 |
lineWise := true. |
|
7012 |
||
4763 | 7013 |
how == #reverse ifTrue:[ |
7014 |
operation := [:lines | lines reverse]. |
|
7015 |
] ifFalse:[ |
|
7016 |
operation := [:linesOrWords | |
|
7017 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7018 |
]. |
|
7019 |
||
7020 |
how == #linesByLength ifTrue:[ |
|
7021 |
fetcher := [:l | l size]. |
|
7022 |
] ifFalse:[ |
|
7023 |
how == #lines ifTrue:[ |
|
7024 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7025 |
] ifFalse:[ |
|
7026 |
how == #linesByFirstWord ifTrue:[ |
|
7027 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7028 |
] ifFalse:[ |
|
7029 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7030 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7031 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7032 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7033 |
LastColumnNumberForSort := n. |
|
7034 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7035 |
how == #linesByNthNumber ifTrue:[ |
|
7036 |
innerExtractor := extractor. |
|
7037 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7038 |
] ifFalse:[ |
|
7039 |
how == #linesByNthHexNumber ifTrue:[ |
|
7040 |
innerExtractor := extractor. |
|
7041 |
extractor := [:l | |
|
7042 |
|s| |
|
7043 |
s := innerExtractor value:l. |
|
7044 |
(s startsWith:'16r') ifTrue:[ |
|
7045 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7046 |
] ifFalse:[ |
|
7047 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7048 |
] |
|
7049 |
] |
|
4753 | 7050 |
] |
4763 | 7051 |
]. |
7052 |
] ifFalse:[ |
|
7053 |
how == #words ifTrue:[ |
|
7054 |
lineWise := false. |
|
7055 |
extractor := [:w | w]. |
|
7056 |
] ifFalse:[ |
|
7057 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7058 |
] |
4373 | 7059 |
] |
7060 |
] |
|
4763 | 7061 |
]. |
7062 |
ignoreCase ifTrue:[ |
|
7063 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7064 |
] ifFalse:[ |
|
7065 |
fetcher := extractor. |
|
7066 |
]. |
|
7067 |
]. |
|
3221 | 7068 |
]. |
7069 |
||
7070 |
lineWise ifTrue:[ |
|
4763 | 7071 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7072 |
start == end ifTrue:[^ self ]. |
7073 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7074 |
lines := operation value:lines. |
4373 | 7075 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7076 |
] ifFalse:[ |
7077 |
"process the whole selection as a string" |
|
7078 |
s := self selectionAsString. |
|
7079 |
words := s asCollectionOfWords. |
|
7080 |
words := operation value:words. |
|
7081 |
s := words asStringCollection asStringWith:Character space. |
|
7082 |
self replace:s. |
|
7083 |
]. |
|
3221 | 7084 |
self textChanged. |
4373 | 7085 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7086 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7087 |
! |
7088 |
||
7089 |
sortSelection:how ignoreCase:ignoreCase |
|
7090 |
"sort the selected lines" |
|
7091 |
||
7092 |
|start end| |
|
7093 |
||
7094 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7095 |
||
7096 |
start := selectionStartLine. |
|
7097 |
end := selectionEndLine. |
|
7098 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7099 |
end := end - 1 |
3221 | 7100 |
]. |
7101 |
||
7102 |
self |
|
4373 | 7103 |
undoableDo:[ |
7104 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7105 |
] |
|
3786 | 7106 |
info:'Sort' |
4373 | 7107 |
|
7108 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7109 |
! |
7110 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7111 |
specialCharacters |
2915 | 7112 |
CharacterSetView |
4823 | 7113 |
openAsInputFor:self |
7114 |
label:'Special Character Input' |
|
7115 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7116 |
! |
7117 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7118 |
undoablePaste:someText |
3495 | 7119 |
self undoablePaste:someText info:nil. |
7120 |
||
7121 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7122 |
! |
|
7123 |
||
7124 |
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
|
7125 |
self |
4823 | 7126 |
undoableDo:[ |
7127 |
self paste:someText. |
|
7128 |
] |
|
7129 |
info:infoOrNil |
|
3495 | 7130 |
|
7131 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7132 |
! |
|
7133 |
||
7134 |
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
|
7135 |
self |
4823 | 7136 |
undoableDo:[ |
7137 |
self pasteOrReplace:someText. |
|
7138 |
] |
|
7139 |
info:infoOrNil |
|
3495 | 7140 |
|
7141 |
"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
|
7142 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7143 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7144 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7145 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7146 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7147 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7148 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7149 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7150 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7151 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7152 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7153 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7154 |
|
2724 | 7155 |
withSelfAndTextForPasteDo:aBlock |
7156 |
"common code for paste/replace of the copybuffer" |
|
7157 |
||
7158 |
|sel| |
|
7159 |
||
7160 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7161 |
self flashReadOnly. |
4823 | 7162 |
^ self |
2724 | 7163 |
]. |
7164 |
||
7165 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7166 |
sel notNil ifTrue:[ |
|
4823 | 7167 |
aBlock value:self value:sel. |
2724 | 7168 |
] |
105 | 7169 |
! ! |
7170 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7171 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7172 |
|
3880 | 7173 |
beep |
5244 | 7174 |
"output an audible beep or bell on my screen device" |
7175 |
||
3880 | 7176 |
UserPreferences current beepInEditor ifTrue:[ |
7177 |
super beep |
|
7178 |
] |
|
7179 |
! |
|
7180 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7181 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7182 |
"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
|
7183 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7184 |
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
|
7185 |
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
|
7186 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7187 |
self isReadOnly ifTrue: [ |
4823 | 7188 |
exceptionBlock isNil ifTrue:[ |
7189 |
^ false |
|
7190 |
]. |
|
7191 |
||
7192 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7193 |
^ false |
|
7194 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7195 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7196 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7197 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7198 |
"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
|
7199 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7200 |
|
2596 | 7201 |
currentSelectionBgColor |
7202 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7203 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7204 |
]. |
5216 | 7205 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7206 |
^ super currentSelectionBgColor |
7207 |
||
7208 |
" |
|
7209 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7210 |
" |
|
7211 |
! |
|
7212 |
||
7213 |
currentSelectionFgColor |
|
7214 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7215 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7216 |
]. |
7217 |
^ super currentSelectionFgColor |
|
7218 |
! |
|
7219 |
||
3996 | 7220 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7221 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7222 |
|
7223 |
super resetVariablesBeforeNewSearch. |
|
7224 |
||
7225 |
"/ new search invalidates remembered string |
|
4048 | 7226 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7227 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7228 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7229 |
! |
7230 |
||
4053 | 7231 |
setLastStringToReplace: aString |
7232 |
||
7233 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7234 |
||
7235 |
|lastReplaceIgnoredCase| |
|
7236 |
||
4064 | 7237 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7238 |
self clearSearchAction. |
|
7239 |
||
4053 | 7240 |
lastReplacementInfo lastStringToReplace: aString. |
7241 |
lastStringFromReplaceForNextSearch := aString. |
|
7242 |
||
7243 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7244 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7245 |
ifTrue: [lastSearchIgnoredCase] |
|
7246 |
ifFalse: [nil]. |
|
4053 | 7247 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7248 |
! |
|
7249 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7250 |
st80EditMode |
5255 | 7251 |
"If on, the cursor wraps at the line end (like in vi or st80); |
7252 |
if off, we have the Rand-editor behavior (random access)" |
|
7253 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7254 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7255 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7256 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7257 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7258 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7259 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7260 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7261 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7262 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7263 |
textChanged |
522 | 7264 |
"my text was modified (internally). |
7265 |
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
|
7266 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7267 |
is used to notify scrollers, other views etc.). |
7268 |
||
7269 |
As some authors of this code have been very sloppy in tha past |
|
7270 |
(not sending contentsChanged, but textChanged), |
|
7271 |
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
|
7272 |
|
641 | 7273 |
self contentsChanged. |
1015 | 7274 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7275 |
contentsWasSaved := false |
641 | 7276 |
|
1015 | 7277 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7278 |
! |
7279 |
||
2617 | 7280 |
textChangedButNoSizeChange |
2207 | 7281 |
"my text was modified (internally). |
7282 |
Sent whenever text has been edited (not to confuse with |
|
7283 |
contentsChanged, which is triggered when the size has changed, and |
|
7284 |
is used to notify scrollers, other views etc.)" |
|
7285 |
||
7286 |
self modified:true. |
|
7287 |
contentsWasSaved := false |
|
7288 |
||
7289 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7290 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7291 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7292 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7293 |
|
5216 | 7294 |
canAccept |
7295 |
"true if text can be accepts. |
|
7296 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7297 |
||
7298 |
^ acceptEnabled ~~ false |
|
7299 |
! |
|
7300 |
||
7301 |
canCut |
|
7302 |
"true if there is a selection possibly to be cut. |
|
7303 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7304 |
||
7305 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7306 |
^ self hasSelection |
|
7307 |
! |
|
7308 |
||
7309 |
canDoAgain |
|
7310 |
"true if there is a possible repeat last edit operation. |
|
7311 |
Used to disable the menu if there is nothing" |
|
7312 |
||
7313 |
|lastStringToReplace| |
|
7314 |
||
7315 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7316 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7317 |
^ lastStringToReplace notNil |
|
7318 |
! |
|
7319 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7320 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7321 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7322 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7323 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7324 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7325 |
"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
|
7326 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7327 |
|
4064 | 7328 |
hasSearchActionSelection |
7329 |
||
7330 |
^ typeOfSelection == #searchAction |
|
7331 |
! |
|
7332 |
||
1878 | 7333 |
isKeyboardConsumer |
7334 |
"return true, if the receiver is a keyboard consumer; |
|
7335 |
Return true here, redefined from SimpleView." |
|
7336 |
||
3476 | 7337 |
^ self isReadOnly not |
1878 | 7338 |
! |
7339 |
||
997 | 7340 |
specClass |
1390 | 7341 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7342 |
||
997 | 7343 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7344 |
^ super specClass |
7345 |
||
1390 | 7346 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7347 |
! |
7348 |
||
324 | 7349 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7350 |
"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
|
7351 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7352 |
"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
|
7353 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7354 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7355 |
|
7356 |
"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
|
7357 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7358 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7359 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7360 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7361 |
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
|
7362 |
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
|
7363 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7364 |
|
697 | 7365 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7366 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7367 |
w := super widthOfContents. |
4889 | 7368 |
(dev := self graphicsDevice ) isNil ifTrue:[ |
7369 |
"/ really don't know ... |
|
4823 | 7370 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7371 |
]. |
4889 | 7372 |
^ w + (gc font widthOn:dev) |
697 | 7373 |
|
7374 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7375 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7376 |
|
1588 | 7377 |
!EditTextView methodsFor:'realization'! |
7378 |
||
7379 |
realize |
|
7380 |
"make the view visible - scroll to make the cursor visible." |
|
7381 |
||
7382 |
super realize. |
|
7383 |
||
7384 |
self makeCursorVisible. |
|
4940 | 7385 |
cursorFgColor := cursorFgColor onDevice:self graphicsDevice. |
7386 |
cursorBgColor := cursorBgColor onDevice:self graphicsDevice. |
|
1588 | 7387 |
|
7388 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7389 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7390 |
! ! |
|
7391 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7392 |
!EditTextView methodsFor:'redrawing'! |
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 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7395 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7396 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7397 |
cursorShown ifTrue:[ |
4823 | 7398 |
cursorVisibleLine notNil ifTrue:[ |
7399 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7400 |
self drawCursorCharacter |
|
7401 |
] |
|
7402 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7403 |
] |
105 | 7404 |
! |
7405 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7406 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7407 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7408 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7409 |
cursorShown ifTrue:[ |
4823 | 7410 |
(visLine == cursorVisibleLine) ifTrue:[ |
7411 |
self drawCursorCharacter |
|
7412 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7413 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7414 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7415 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7416 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7417 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7419 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7420 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7421 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7422 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7423 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7424 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7425 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7426 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7427 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7428 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7429 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7430 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7431 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7432 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7433 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7434 |
cursorShown ifTrue:[ |
4823 | 7435 |
(visLine == cursorVisibleLine) ifTrue:[ |
7436 |
(colNr == cursorCol) ifTrue:[ |
|
7437 |
self drawCursorCharacter. |
|
7438 |
^ self |
|
7439 |
] |
|
7440 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7441 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7442 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7443 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7444 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7445 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7446 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7447 |
"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
|
7448 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7449 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7450 |
cursorShown ifTrue:[ |
7451 |
self redrawCursorIfInVisibleLine:visLine |
|
7452 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7453 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7455 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7456 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7457 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7458 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7459 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7460 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7461 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7462 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7463 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7464 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7465 |
"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
|
7466 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7467 |
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
|
7468 |
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
|
7469 |
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
|
7470 |
|
4889 | 7471 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7472 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7473 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7474 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7475 |
"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
|
7476 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7477 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7478 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7479 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7480 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7481 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7482 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7483 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7484 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7485 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7486 |
"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
|
7487 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7488 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7489 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7490 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7491 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7492 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7493 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7494 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7495 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7496 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7497 |
"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
|
7498 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7499 |
super originChanged:delta. |
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 |
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
|
7502 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7503 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7504 |
prevCursorState ifTrue:[ |
4823 | 7505 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7506 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7507 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7508 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7509 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7511 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7512 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7513 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7514 |
prevCursorState := cursorShown. |
1601 | 7515 |
"/ cursorShown := false. |
1591 | 7516 |
cursorShown ifTrue:[ |
4823 | 7517 |
self hideCursor |
1591 | 7518 |
] |
7519 |
||
1601 | 7520 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7521 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7522 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7523 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7524 |
"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
|
7525 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7526 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7527 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7528 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7529 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7530 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7531 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7532 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7533 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7534 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7535 |
"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
|
7536 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7537 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7538 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7539 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7540 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7541 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7542 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7543 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7544 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7545 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7547 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7548 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7549 |
|
2822 | 7550 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7551 |
! |
7552 |
||
7553 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7554 |
"do a backward search" |
|
7555 |
||
7556 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7557 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7558 |
! |
7559 |
||
7560 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7561 |
"do a backward search" |
|
7562 |
||
7563 |
cursorLine isNil ifTrue:[^ self]. |
|
7564 |
||
3160 | 7565 |
self |
4119 | 7566 |
searchBackwardFor:pattern |
7567 |
ignoreCase:ign |
|
7568 |
startingAtLine:startLine col:startCol |
|
7569 |
ifFound:[:line :col | |
|
7570 |
self cursorMovementAllowed ifTrue:[ |
|
7571 |
self cursorLine:line col:col. |
|
7572 |
]. |
|
7573 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7574 |
"/ self makeLineVisible:cursorLine |
4119 | 7575 |
typeOfSelection := #search] |
7576 |
ifAbsent:aBlock |
|
1339 | 7577 |
|
7578 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7579 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7580 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7581 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7582 |
"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
|
7583 |
|
2554 | 7584 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7585 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7586 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7587 |
searchForMatchingParenthesis |
3160 | 7588 |
"search for a matching parenthesis starting at cursor position. |
7589 |
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
|
7590 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7591 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7592 |
|
2822 | 7593 |
self cursorMovementAllowed ifFalse:[^ self]. |
7594 |
||
3160 | 7595 |
self |
4823 | 7596 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
7597 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7598 |
ifNotFound:[self showNotFound] |
|
7599 |
onError:[self beep] |
|
1339 | 7600 |
|
7601 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7602 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7603 |
|
3967 | 7604 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7605 |
"do a forward search" |
7606 |
||
7607 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7608 |
self |
7609 |
searchForwardFor:pattern |
|
7610 |
ignoreCase:ign |
|
7611 |
match: match |
|
7612 |
startingAtLine:startLine col:startCol |
|
7613 |
ifFound:[:line :col | |
|
7614 |
self cursorMovementAllowed ifTrue:[ |
|
7615 |
self cursorLine:line col:col. |
|
7616 |
]. |
|
4119 | 7617 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7618 |
"/ self makeLineVisible:cursorLine |
3967 | 7619 |
typeOfSelection := #search |
7620 |
] |
|
7621 |
ifAbsent:aBlock |
|
1339 | 7622 |
|
7623 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7624 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7625 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7626 |
|
3967 | 7627 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7628 |
"do a forward search" |
|
7629 |
||
7630 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7631 |
! |
|
7632 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7633 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7634 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7635 |
|
2822 | 7636 |
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
|
7637 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7638 |
|
3982 | 7639 |
searchPatternForSearchBar |
7640 |
||
7641 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7642 |
||
7643 |
|searchPattern| |
|
7644 |
||
4138 | 7645 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7646 |
searchPattern isNil |
7647 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7648 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7649 |
^ searchPattern |
|
7650 |
! |
|
7651 |
||
3578 | 7652 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7653 |
"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
|
7654 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7655 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7656 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7657 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7658 |
"/ |
3967 | 7659 |
"/ 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
|
7660 |
"/ original string (for search after again) |
4121 | 7661 |
"/ 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
|
7662 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7663 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7664 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7665 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7666 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7667 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7668 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7669 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7670 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7671 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7672 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7673 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7674 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7675 |
"/ 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
|
7676 |
"/ if there was a previous search, only take the selection if |
3967 | 7677 |
"/ 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
|
7678 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7679 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7680 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7681 |
sel notNil ifTrue:[ |
3967 | 7682 |
(lastSearchPattern isNil |
4484 | 7683 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7684 |
) ifTrue:[ |
|
3967 | 7685 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7686 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7687 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7688 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7689 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7690 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7691 |
"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
|
7692 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7693 |
|
4484 | 7694 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7695 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7696 |
typeOfSelection := #search. |
|
7697 |
! |
|
7698 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7699 |
startPositionForSearchBackward |
2822 | 7700 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7701 |
! |
|
7702 |
||
7703 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7704 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7705 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7706 |
selectionStartLine notNil ifTrue:[ |
4823 | 7707 |
startLine := selectionStartLine. |
7708 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7709 |
] ifFalse:[ |
4823 | 7710 |
cursorLine isNil ifTrue:[ |
7711 |
startLine := list size. |
|
7712 |
startCol := self listAt:startLine size. |
|
7713 |
] ifFalse:[ |
|
7714 |
startLine := cursorLine min:list size. |
|
7715 |
startCol := cursorCol |
|
7716 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7717 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7718 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7719 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7720 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7721 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7722 |
startPositionForSearchForward |
2822 | 7723 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7724 |
! |
|
7725 |
||
7726 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7727 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7728 |
|
3160 | 7729 |
"/ 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
|
7730 |
"/ 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
|
7731 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7732 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7733 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7734 |
] ifFalse:[ |
4064 | 7735 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7736 |
startCol := 0 |
|
7737 |
]. |
|
7738 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7739 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7740 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7741 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7742 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7743 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7744 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7745 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7746 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7747 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7748 |
addToSelectionAfter:aBlock |
5145 | 7749 |
<resource: #obsolete> |
7750 |
||
7751 |
"evaluate aBlock while unselected. |
|
7752 |
Restore the previous selection afterwards. |
|
7753 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
7754 |
It is therefore temporarily marked as obsolete. Please check |
|
7755 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7756 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7757 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7758 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7759 |
self hasSelection ifTrue: [ |
4823 | 7760 |
startLine := selectionStartLine . |
7761 |
startCol := selectionStartCol . |
|
7762 |
endLine := selectionEndLine . |
|
7763 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7764 |
] ifFalse: [ |
4823 | 7765 |
startLine := endLine := cursorLine . |
7766 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7767 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7768 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7769 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7770 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7771 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7772 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7773 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7774 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
4823 | 7775 |
ifTrue: [ |
7776 |
startCol := cursorCol. |
|
7777 |
] ifFalse: [ |
|
7778 |
endCol := cursorCol - 1. |
|
7779 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7780 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7781 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7782 |
|
1850 | 7783 |
autoMoveCursorToEndOfSelection |
7784 |
"return true, if the cursor should be automatically moved to the |
|
7785 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
7786 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 7787 |
not be affected by selecting" |
7788 |
||
7789 |
^ true |
|
7790 |
! |
|
7791 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7792 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7793 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 7794 |
typeOfSelection := newType. |
7795 |
selectionStartLine notNil ifTrue:[ |
|
7796 |
self |
|
7797 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
7798 |
toLine:selectionEndLine col:selectionEndCol |
|
7799 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7800 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7801 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7802 |
|
4707 | 7803 |
findNextWordAfterSelectionAndAddToSelection |
7804 |
|selStartCol selStartLine selEndCol selEndLine| |
|
7805 |
||
7806 |
selectionStartCol isNil ifTrue:[ |
|
7807 |
self selectWordUnderCursor. |
|
7808 |
^ self |
|
7809 |
]. |
|
7810 |
||
7811 |
selStartCol := selectionStartCol. |
|
7812 |
selEndCol := selectionEndCol. |
|
7813 |
selStartLine := selectionStartLine. |
|
7814 |
selEndLine := selectionEndLine. |
|
7815 |
||
7816 |
self cursorToNextWord. |
|
7817 |
self selectWordUnderCursor. |
|
7818 |
||
7819 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
7820 |
! |
|
7821 |
||
4138 | 7822 |
searchPatternFromUserSelectionOrReplace |
7823 |
||
7824 |
|sel searchPattern| |
|
7825 |
||
7826 |
"/ |
|
7827 |
"/ if the last operation was a replace, set pattern to last |
|
7828 |
"/ original string (for search after again) |
|
7829 |
"/ |
|
7830 |
(lastStringFromReplaceForNextSearch notNil |
|
7831 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
7832 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
7833 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
7834 |
] ifFalse:[ |
|
7835 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
7836 |
]. |
|
7837 |
^ searchPattern |
|
7838 |
]. |
|
7839 |
||
7840 |
"/ |
|
7841 |
"/ if there is a selection: |
|
7842 |
"/ if there was no previous search, take it as search pattern. |
|
7843 |
"/ if there was a previous search, only take the selection if |
|
7844 |
"/ it did not result from a paste. |
|
7845 |
"/ (to allow search-paste to be repeated) |
|
7846 |
"/ |
|
7847 |
sel := self selection. |
|
7848 |
sel notNil ifTrue:[ |
|
7849 |
typeOfSelection ~~ #search ifTrue:[ |
|
7850 |
typeOfSelection ~~ #paste ifTrue:[ |
|
7851 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
7852 |
searchPattern := sel asStringWithoutFinalCR. |
|
7853 |
] |
|
7854 |
]. |
|
7855 |
]. |
|
7856 |
||
7857 |
^ searchPattern |
|
7858 |
! |
|
7859 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7860 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7861 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7862 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7863 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7864 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7865 |
list isNil ifTrue:[ |
4823 | 7866 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7867 |
] ifFalse:[ |
4823 | 7868 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
7869 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7870 |
] |
1082 | 7871 |
|
7872 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7873 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7874 |
|
4117 | 7875 |
selectAllInitially |
7876 |
"select the whole text. This is called only once during the initialization |
|
7877 |
for editFields which are shown in a table or tree. |
|
7878 |
The selectAll is called via this method to allow for easier redefinition and |
|
7879 |
to distinguish auto-select from user-initiated selects." |
|
7880 |
||
7881 |
self selectAll |
|
7882 |
! |
|
7883 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7884 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7885 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7886 |
|
3160 | 7887 |
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
|
7888 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7889 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7890 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7891 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7892 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7893 |
cursorCol > 1 ifTrue:[ |
4823 | 7894 |
self selectFromLine:cursorLine col:1 |
7895 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7896 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7897 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7898 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7899 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7900 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7901 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7902 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7903 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7904 |
selectionStartLine isNil ifTrue:[ |
4823 | 7905 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7906 |
] ifFalse:[ |
4823 | 7907 |
self selectFromLine:selectionStartLine col:selectionStartCol |
7908 |
toLine:cursorLine+1 col:0. |
|
7909 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7910 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7911 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7912 |
|
4257 | 7913 |
selectFromBeginOfLine |
7914 |
"select the text from the beginning of the current line to the current cursor position." |
|
7915 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7916 |
| newCursorCol ln | |
4271 | 7917 |
|
4257 | 7918 |
list isNil ifTrue:[ |
7919 |
self unselect |
|
7920 |
] ifFalse:[ |
|
7921 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7922 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7923 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 7924 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
7925 |
cursorCol := newCursorCol. |
|
4257 | 7926 |
typeOfSelection := nil |
7927 |
] |
|
7928 |
] |
|
7929 |
||
7930 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7931 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7932 |
! |
7933 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7934 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7935 |
"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
|
7936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7937 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7938 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7939 |
list isNil ifTrue:[ |
4823 | 7940 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7941 |
] ifFalse:[ |
4823 | 7942 |
cursorCol == 0 ifTrue:[ |
7943 |
col := 0 |
|
7944 |
] ifFalse:[ |
|
7945 |
col := cursorCol - 1 |
|
7946 |
]. |
|
7947 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
7948 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7949 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7950 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7952 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7953 |
"when a range is selected, position the cursor behind the selection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7954 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7955 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7956 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 7957 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
4823 | 7958 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 7959 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7960 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7961 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7962 |
|
4257 | 7963 |
selectToEndOfLine |
7964 |
"select the text from the current cursor position to the end of the current line" |
|
7965 |
||
4271 | 7966 |
| newCursorCol line | |
7967 |
||
4257 | 7968 |
list isNil ifTrue:[ |
7969 |
self unselect |
|
7970 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7971 |
cursorCol >= 1 ifTrue:[ |
4271 | 7972 |
line := list at: cursorLine. |
7973 |
newCursorCol := line size. |
|
7974 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
7975 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
7976 |
||
7977 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
7978 |
cursorCol := newCursorCol. |
|
4257 | 7979 |
typeOfSelection := nil |
7980 |
] |
|
7981 |
] |
|
7982 |
||
7983 |
"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
|
7984 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7985 |
! |
7986 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7987 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7988 |
"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
|
7989 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7990 |
list isNil ifTrue:[ |
4823 | 7991 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7992 |
] ifFalse:[ |
4823 | 7993 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
7994 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7995 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7996 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7997 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7998 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7999 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8000 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8002 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8003 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8004 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8005 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8007 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8008 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8009 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8010 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8011 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
wasOn ifTrue:[self showCursor] |
105 | 8013 |
! ! |
8014 |
||
8015 |
!EditTextView methodsFor:'undo & again'! |
|
8016 |
||
2952 | 8017 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8018 |
^ undoSupport addUndo:action. |
2952 | 8019 |
! |
8020 |
||
105 | 8021 |
again |
8022 |
"repeat the last action (which was a cut or replace). |
|
8023 |
If current selection is not last string, search forward to |
|
3160 | 8024 |
next occurrence of it before repeating the last operation." |
105 | 8025 |
|
4048 | 8026 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8027 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8028 |
|
8029 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8030 |
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
|
8031 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8032 |
]. |
4048 | 8033 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8034 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8035 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8036 |
self undoableDo:[ |
4010 | 8037 |
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
|
8038 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8039 |
(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
|
8040 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8041 |
|
4053 | 8042 |
"set lastStringToReplace as the next search string |
8043 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8044 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8045 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8046 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8047 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8048 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8049 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8050 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8051 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8052 |
"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
|
8053 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8054 |
(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
|
8055 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8056 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8057 |
self deleteSelection. |
4051 | 8058 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8059 |
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
|
8060 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8061 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8062 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8063 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8064 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8065 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8066 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8067 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8068 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8069 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8070 |
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
|
8071 |
]. |
4048 | 8072 |
self |
8073 |
searchForwardFor:s |
|
8074 |
ignoreCase: lastReplaceIgnoredCase |
|
8075 |
match: lastReplaceWasMatch |
|
8076 |
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
|
8077 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8078 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8079 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8080 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8081 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8082 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8083 |
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
|
8084 |
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
|
8085 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8086 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8087 |
self deleteSelection. |
4051 | 8088 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8089 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8090 |
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
|
8091 |
] ifTrue:[ |
4051 | 8092 |
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
|
8093 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8094 |
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
|
8095 |
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
|
8096 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8097 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8098 |
selectStyle := savedSelectStyle. |
4484 | 8099 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8100 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8101 |
] |
4048 | 8102 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8103 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8104 |
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
|
8105 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8106 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8107 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8108 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8109 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8110 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8111 |
^ true. |
501 | 8112 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8113 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8114 |
! |
8115 |
||
2952 | 8116 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8117 |
^ undoSupport hasRedoAction. |
2952 | 8118 |
! |
8119 |
||
8120 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8121 |
^ undoSupport hasUndoAction. |
2952 | 8122 |
! |
8123 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8124 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8125 |
"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
|
8126 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8127 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8128 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8129 |
|
2952 | 8130 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8131 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8132 |
! |
8133 |
||
8134 |
redo |
|
3780 | 8135 |
"undo the last undo" |
8136 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8137 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8138 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8139 |
] ifTrue:[ |
3780 | 8140 |
undoSupport redo. |
2952 | 8141 |
] |
8142 |
! |
|
8143 |
||
121 | 8144 |
undo |
3780 | 8145 |
"undo the last edit operation" |
8146 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8147 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8148 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8149 |
] ifTrue:[ |
3780 | 8150 |
undoSupport undo. |
121 | 8151 |
] |
2952 | 8152 |
! |
8153 |
||
8154 |
undoableDo:aBlock |
|
3495 | 8155 |
self undoableDo:aBlock info:nil. |
8156 |
||
8157 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8158 |
! |
8159 |
||
8160 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8161 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8162 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8163 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8164 |
] ifTrue:[ |
4823 | 8165 |
undoSupport undoableDo:aBlock info:aString. |
3495 | 8166 |
]. |
8167 |
||
8168 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 8169 |
! ! |
8170 |
||
8171 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8172 |
||
8173 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8174 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8175 |
! |
|
8176 |
||
3115 | 8177 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8178 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8179 |
! |
8180 |
||
2952 | 8181 |
line:arg1 col:arg2 character:arg3 |
8182 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8183 |
! |
|
8184 |
||
3115 | 8185 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8186 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8187 |
! |
8188 |
||
3235 | 8189 |
line:arg1 col:arg2 characters:arg3 info:info |
8190 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8191 |
! |
|
8192 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8193 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8194 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8195 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8196 |
|
2952 | 8197 |
line:arg1 col:arg2 string:arg3 |
8198 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8199 |
! |
8200 |
||
8201 |
line:arg1 col:arg2 string:arg3 info:info |
|
8202 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8203 |
! |
8204 |
||
8205 |
line:arg1 string:arg3 info:info |
|
8206 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8207 |
! |
8208 |
||
8209 |
text:arg info:info |
|
8210 |
^ (self new text:arg) info:info |
|
3115 | 8211 |
! ! |
8212 |
||
8213 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8214 |
||
8215 |
info |
|
8216 |
^ userFriendlyInfo |
|
8217 |
! |
|
8218 |
||
8219 |
info:aString |
|
8220 |
userFriendlyInfo := aString |
|
2952 | 8221 |
! ! |
8222 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8223 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8224 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8225 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8226 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8227 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8228 |
"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
|
8229 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8230 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8231 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8232 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8233 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8234 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8235 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8236 |
|
2952 | 8237 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8238 |
||
3160 | 8239 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8240 |
"set instance variables (automatically generated)" |
8241 |
||
8242 |
self assert:(line1Arg notNil). |
|
8243 |
self assert:(col1Arg notNil). |
|
8244 |
self assert:(line2Arg notNil). |
|
8245 |
self assert:(col2Arg notNil). |
|
8246 |
||
8247 |
line1 := line1Arg. |
|
8248 |
col1 := col1Arg. |
|
8249 |
line2 := line2Arg. |
|
8250 |
col2 := col2Arg. |
|
8251 |
! ! |
|
8252 |
||
8253 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8254 |
||
3160 | 8255 |
executeIn:editor |
2952 | 8256 |
editor unselect. |
3160 | 8257 |
editor |
4823 | 8258 |
deleteFromLine:line1 |
8259 |
col:col1 |
|
8260 |
toLine:line2 |
|
8261 |
col:col2. |
|
2952 | 8262 |
editor cursorLine:line1 col:col1. |
8263 |
! ! |
|
8264 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8265 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8266 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8267 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8268 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8269 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8270 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8271 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8272 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8273 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8274 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8275 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8276 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8277 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8278 |
|
3160 | 8279 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8280 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8281 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8282 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8283 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8284 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8285 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8286 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8287 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8288 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8289 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8290 |
|
3160 | 8291 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8292 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8293 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8294 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8295 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8296 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8297 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8298 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8299 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8300 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8301 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8302 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8303 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8304 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8305 |
|
3160 | 8306 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8307 |
"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
|
8308 |
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
|
8309 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8310 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8311 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8312 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8313 |
^ true |
|
8314 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8315 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8316 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8317 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8318 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8319 |
|
3160 | 8320 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8321 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8322 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8323 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8324 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8325 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8326 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8327 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8328 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8329 |
|
3160 | 8330 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8331 |
editor unselect. |
3160 | 8332 |
editor |
4823 | 8333 |
deleteFromLine:line |
8334 |
col:col1 |
|
8335 |
toLine:line |
|
8336 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8337 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8338 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8339 |
|
3235 | 8340 |
!EditTextView::EditMode class methodsFor:'constants'! |
8341 |
||
8342 |
insertAndSelectMode |
|
8343 |
^ InsertAndSelectMode |
|
8344 |
! |
|
8345 |
||
8346 |
insertMode |
|
8347 |
^ InsertMode |
|
8348 |
! |
|
8349 |
||
8350 |
overwriteMode |
|
8351 |
^ OverwriteMode |
|
8352 |
! ! |
|
8353 |
||
8354 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8355 |
||
8356 |
isInsertAndSelectMode |
|
8357 |
^ false |
|
8358 |
! |
|
8359 |
||
8360 |
isInsertMode |
|
8361 |
^ false |
|
8362 |
! |
|
8363 |
||
8364 |
symbolicName |
|
8365 |
self subclassResponsibility |
|
8366 |
! ! |
|
8367 |
||
8368 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8369 |
||
8370 |
infoPrintString |
|
8371 |
^ 'IS' |
|
8372 |
! ! |
|
8373 |
||
8374 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8375 |
||
8376 |
isInsertAndSelectMode |
|
8377 |
^ true |
|
8378 |
! |
|
8379 |
||
8380 |
isInsertMode |
|
8381 |
^ true |
|
8382 |
! ! |
|
8383 |
||
8384 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8385 |
||
8386 |
infoPrintString |
|
8387 |
^ 'I' |
|
8388 |
! ! |
|
8389 |
||
8390 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8391 |
||
8392 |
isInsertMode |
|
8393 |
^ true |
|
8394 |
! ! |
|
8395 |
||
8396 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8397 |
||
8398 |
infoPrintString |
|
8399 |
^ 'O' |
|
8400 |
! ! |
|
8401 |
||
4048 | 8402 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8403 |
||
8404 |
lastReplaceIgnoredCase |
|
8405 |
^ lastReplaceIgnoredCase ? false |
|
8406 |
! |
|
8407 |
||
8408 |
lastReplaceIgnoredCase:something |
|
8409 |
lastReplaceIgnoredCase := something. |
|
8410 |
! |
|
8411 |
||
8412 |
lastReplaceWasMatch |
|
8413 |
^ lastReplaceWasMatch ? false |
|
8414 |
! |
|
8415 |
||
8416 |
lastReplaceWasMatch:something |
|
8417 |
lastReplaceWasMatch := something. |
|
8418 |
! |
|
8419 |
||
8420 |
lastReplacement |
|
8421 |
^ lastReplacement |
|
8422 |
! |
|
8423 |
||
8424 |
lastReplacement:something |
|
4053 | 8425 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8426 |
lastReplacement := something. |
8427 |
! |
|
8428 |
||
8429 |
lastStringToReplace |
|
8430 |
^ lastStringToReplace |
|
8431 |
! |
|
8432 |
||
8433 |
lastStringToReplace:something |
|
8434 |
lastStringToReplace := something. |
|
4818 | 8435 |
! |
8436 |
||
8437 |
previousReplacements |
|
8438 |
^ previousReplacements ? #() |
|
8439 |
! |
|
8440 |
||
8441 |
stillCollectingInput |
|
8442 |
^ stillCollectingInput |
|
8443 |
! |
|
8444 |
||
8445 |
stillCollectingInput:aBoolean |
|
8446 |
stillCollectingInput := aBoolean. |
|
8447 |
! ! |
|
8448 |
||
8449 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8450 |
||
8451 |
rememberReplacement |
|
8452 |
"remember the previous replacement (called when a new one appears). |
|
8453 |
Mostly for the benefit of the code completion..." |
|
8454 |
||
8455 |
|oldString newString| |
|
8456 |
||
8457 |
oldString := lastStringToReplace. |
|
8458 |
newString := lastReplacement. |
|
8459 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
8460 |
previousReplacements isNil ifTrue:[ |
|
8461 |
previousReplacements := OrderedCollection new. |
|
8462 |
]. |
|
8463 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
8464 |
previousReplacements addFirst:(oldString -> newString). |
|
8465 |
previousReplacements size > 20 ifTrue:[ |
|
8466 |
previousReplacements removeLast. |
|
8467 |
] |
|
8468 |
]. |
|
4048 | 8469 |
! ! |
8470 |
||
2952 | 8471 |
!EditTextView::PasteString methodsFor:'accessing'! |
8472 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8473 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8474 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8475 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8476 |
"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
|
8477 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8478 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8479 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8480 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8481 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8482 |
"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
|
8483 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8484 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8485 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8486 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8487 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8488 |
"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
|
8489 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8490 |
|
3160 | 8491 |
line:lineArg col:colArg string:stringArg |
2952 | 8492 |
self assert:(lineArg notNil). |
8493 |
self assert:(colArg notNil). |
|
8494 |
self assert:(stringArg notNil). |
|
8495 |
||
8496 |
line := lineArg. |
|
8497 |
col := colArg. |
|
8498 |
string := stringArg. |
|
8499 |
! |
|
8500 |
||
8501 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8502 |
self assert:(lineArg notNil). |
|
8503 |
self assert:(colArg notNil). |
|
8504 |
self assert:(stringArg notNil). |
|
8505 |
||
8506 |
line := lineArg. |
|
8507 |
col := colArg. |
|
8508 |
string := stringArg. |
|
8509 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8510 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8511 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8512 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8513 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8514 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8515 |
"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
|
8516 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8517 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8518 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8519 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8520 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8521 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8522 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8523 |
"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
|
8524 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8525 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8526 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8527 |
"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
|
8528 |
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
|
8529 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8530 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8531 |
previousPasteAction line == line ifTrue:[ |
4823 | 8532 |
previousPasteAction col == (self col2+1) ifTrue:[ |
8533 |
^ true |
|
8534 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8535 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8536 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8537 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8538 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8539 |
"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
|
8540 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8541 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8542 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8543 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8544 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8545 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8546 |
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
|
8547 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8548 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8549 |
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
|
8550 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8551 |
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
|
8552 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8553 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8554 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8555 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8556 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8557 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8558 |
! ! |
8559 |
||
8560 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8561 |
||
3160 | 8562 |
executeIn:editor |
2952 | 8563 |
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
|
8564 |
editor paste:string. |
2952 | 8565 |
selected ~~ true ifTrue:[ |
4823 | 8566 |
editor unselect |
2952 | 8567 |
]. |
8568 |
! ! |
|
8569 |
||
8570 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8571 |
||
3235 | 8572 |
col |
8573 |
^ col |
|
8574 |
! |
|
8575 |
||
8576 |
col1 |
|
8577 |
^ col |
|
8578 |
! |
|
8579 |
||
8580 |
col2 |
|
8581 |
^ col |
|
8582 |
! |
|
8583 |
||
8584 |
line |
|
8585 |
^ line |
|
8586 |
! |
|
8587 |
||
3160 | 8588 |
line:lineArg col:colArg character:characterArg |
2952 | 8589 |
line := lineArg. |
8590 |
col := colArg. |
|
8591 |
character := characterArg. |
|
8592 |
! ! |
|
8593 |
||
8594 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8595 |
||
3160 | 8596 |
executeIn:editor |
8597 |
editor |
|
4823 | 8598 |
replace:character |
8599 |
atLine:line |
|
8600 |
col:col. |
|
2952 | 8601 |
editor cursorLine:line col:col. |
105 | 8602 |
! ! |
8603 |
||
3235 | 8604 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8605 |
||
8606 |
characters |
|
8607 |
^ characters |
|
8608 |
! |
|
8609 |
||
8610 |
col1 |
|
8611 |
^ col1 |
|
8612 |
! |
|
8613 |
||
8614 |
col2 |
|
8615 |
^ col2 |
|
8616 |
! |
|
8617 |
||
8618 |
line |
|
8619 |
^ line |
|
8620 |
! |
|
8621 |
||
8622 |
line:lineArg col:colArg character:characterArg |
|
8623 |
line := lineArg. |
|
8624 |
col1 := col2 := colArg. |
|
8625 |
characters := characterArg asString. |
|
8626 |
! |
|
8627 |
||
8628 |
line:lineArg col:colArg characters:charactersArg |
|
8629 |
line := lineArg. |
|
8630 |
col1 := colArg. |
|
8631 |
characters := charactersArg asString. |
|
8632 |
col2 := col1 + charactersArg size - 1 |
|
8633 |
! ! |
|
8634 |
||
8635 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8636 |
||
8637 |
canCombineWithNext:anotherAction |
|
8638 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8639 |
! |
|
8640 |
||
8641 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8642 |
"I will combine only if we both are single character deletes, |
|
8643 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8644 |
(i.e. single-character typing)" |
|
8645 |
||
8646 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 8647 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
8648 |
^ true |
|
8649 |
]. |
|
3235 | 8650 |
]. |
8651 |
||
8652 |
^ false |
|
8653 |
! |
|
8654 |
||
8655 |
combineWithNext:nextReplaceAction |
|
8656 |
self assert:(line == nextReplaceAction line). |
|
8657 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8658 |
||
8659 |
col2 := nextReplaceAction col2. |
|
8660 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8661 |
characters := characters , nextReplaceAction characters. |
|
8662 |
! ! |
|
8663 |
||
8664 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8665 |
||
8666 |
executeIn:editor |
|
8667 |
editor |
|
4823 | 8668 |
replaceString:characters |
8669 |
atLine:line |
|
8670 |
col:col1. |
|
3235 | 8671 |
editor cursorLine:line col:col1. |
8672 |
! ! |
|
8673 |
||
3131 | 8674 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8675 |
||
8676 |
text:something |
|
8677 |
text := something. |
|
8678 |
! ! |
|
8679 |
||
8680 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8681 |
||
3160 | 8682 |
executeIn:editor |
3131 | 8683 |
editor contents:text |
8684 |
! ! |
|
8685 |
||
3130 | 8686 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8687 |
||
3160 | 8688 |
line:lineArg string:stringArg |
3130 | 8689 |
line := lineArg. |
8690 |
text := stringArg. |
|
8691 |
! ! |
|
8692 |
||
8693 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
8694 |
||
3160 | 8695 |
executeIn:editor |
3130 | 8696 |
editor list at:line put:text. |
8697 |
editor invalidateLine:line |
|
8698 |
! ! |
|
8699 |
||
3402 | 8700 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
8701 |
||
8702 |
line:lineArg lines:lineCollectionArg |
|
8703 |
line := lineArg. |
|
8704 |
text := lineCollectionArg. |
|
8705 |
||
8706 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
8707 |
! ! |
|
8708 |
||
8709 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
8710 |
||
8711 |
executeIn:editor |
|
8712 |
|lnr| |
|
8713 |
||
8714 |
lnr := line. |
|
8715 |
text do:[:eachLine | |
|
4823 | 8716 |
editor list at:lnr put:eachLine. |
8717 |
editor invalidateLine:lnr. |
|
8718 |
lnr := lnr + 1. |
|
3402 | 8719 |
]. |
8720 |
||
8721 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
8722 |
! ! |
|
8723 |
||
865 | 8724 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8725 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8726 |
version |
5260 | 8727 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.634 2015-02-18 13:13:39 cg Exp $' |
3945 | 8728 |
! |
8729 |
||
8730 |
version_CVS |
|
5260 | 8731 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.634 2015-02-18 13:13:39 cg Exp $' |
0 | 8732 |
! ! |
4481 | 8733 |