author | Claus Gittinger <cg@exept.de> |
Fri, 07 Apr 2006 19:43:13 +0200 | |
changeset 3303 | add21df4dcb1 |
parent 3296 | 7322b2e5222c |
child 3310 | 83368f9014a1 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
3160 | 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 |
" |
|
12 |
||
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
14 |
|
0 | 15 |
TextView subclass:#EditTextView |
2724 | 16 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
17 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
18 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
2952 | 19 |
cursorTypeNoFocus typeOfSelection lastString lastReplacement |
20 |
lastAction replacing showMatchingParenthesis hasKeyboardFocus |
|
21 |
acceptAction lockUpdates tabMeansNextField autoIndent insertMode |
|
3235 | 22 |
editMode trimBlankLines wordWrap replacementWordSelectStyle |
23 |
acceptChannel acceptEnabled st80Mode disableIfInvisible |
|
2952 | 24 |
cursorMovementWhenUpdating learnMode learnedMacro |
3241 | 25 |
cursorLineHolder cursorColHolder tabRequiresControl undoSupport' |
2724 | 26 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
27 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
28 |
DefaultCursorTypeNoFocus' |
|
29 |
poolDictionaries:'' |
|
30 |
category:'Views-Text' |
|
0 | 31 |
! |
32 |
||
2952 | 33 |
Object subclass:#EditAction |
3115 | 34 |
instanceVariableNames:'userFriendlyInfo' |
2952 | 35 |
classVariableNames:'' |
36 |
poolDictionaries:'' |
|
37 |
privateIn:EditTextView |
|
38 |
! |
|
39 |
||
40 |
EditTextView::EditAction subclass:#DeleteRange |
|
41 |
instanceVariableNames:'line1 col1 line2 col2' |
|
42 |
classVariableNames:'' |
|
43 |
poolDictionaries:'' |
|
44 |
privateIn:EditTextView |
|
45 |
! |
|
46 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
47 |
EditTextView::EditAction subclass:#DeleteCharacters |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
48 |
instanceVariableNames:'line col1 col2' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
classVariableNames:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
50 |
poolDictionaries:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
51 |
privateIn:EditTextView |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
53 |
|
3235 | 54 |
Object subclass:#EditMode |
55 |
instanceVariableNames:'' |
|
56 |
classVariableNames:'' |
|
57 |
poolDictionaries:'' |
|
58 |
privateIn:EditTextView |
|
59 |
! |
|
60 |
||
61 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
62 |
instanceVariableNames:'' |
|
63 |
classVariableNames:'' |
|
64 |
poolDictionaries:'' |
|
65 |
privateIn:EditTextView::EditMode |
|
66 |
! |
|
67 |
||
68 |
EditTextView::EditMode subclass:#InsertMode |
|
69 |
instanceVariableNames:'' |
|
70 |
classVariableNames:'' |
|
71 |
poolDictionaries:'' |
|
72 |
privateIn:EditTextView::EditMode |
|
73 |
! |
|
74 |
||
75 |
EditTextView::EditMode subclass:#OverwriteMode |
|
76 |
instanceVariableNames:'' |
|
77 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
78 |
poolDictionaries:'' |
|
79 |
privateIn:EditTextView::EditMode |
|
80 |
! |
|
81 |
||
2952 | 82 |
EditTextView::EditAction subclass:#InsertCharacter |
83 |
instanceVariableNames:'line col character' |
|
84 |
classVariableNames:'' |
|
85 |
poolDictionaries:'' |
|
86 |
privateIn:EditTextView |
|
87 |
! |
|
88 |
||
89 |
EditTextView::EditAction subclass:#PasteString |
|
90 |
instanceVariableNames:'line col string selected' |
|
91 |
classVariableNames:'' |
|
92 |
poolDictionaries:'' |
|
93 |
privateIn:EditTextView |
|
94 |
! |
|
95 |
||
96 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
97 |
instanceVariableNames:'line col character' |
|
98 |
classVariableNames:'' |
|
99 |
poolDictionaries:'' |
|
100 |
privateIn:EditTextView |
|
101 |
! |
|
102 |
||
3235 | 103 |
EditTextView::EditAction subclass:#ReplaceCharacters |
104 |
instanceVariableNames:'line col1 col2 characters' |
|
105 |
classVariableNames:'' |
|
106 |
poolDictionaries:'' |
|
107 |
privateIn:EditTextView |
|
108 |
! |
|
109 |
||
3131 | 110 |
EditTextView::EditAction subclass:#ReplaceContents |
111 |
instanceVariableNames:'text' |
|
112 |
classVariableNames:'' |
|
113 |
poolDictionaries:'' |
|
114 |
privateIn:EditTextView |
|
115 |
! |
|
116 |
||
3130 | 117 |
EditTextView::EditAction subclass:#ReplaceLine |
118 |
instanceVariableNames:'line text' |
|
119 |
classVariableNames:'' |
|
120 |
poolDictionaries:'' |
|
121 |
privateIn:EditTextView |
|
122 |
! |
|
123 |
||
865 | 124 |
!EditTextView class methodsFor:'documentation'! |
0 | 125 |
|
33 | 126 |
copyright |
127 |
" |
|
128 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3160 | 129 |
All Rights Reserved |
33 | 130 |
|
131 |
This software is furnished under a license and may be used |
|
132 |
only in accordance with the terms of that license and with the |
|
133 |
inclusion of the above copyright notice. This software may not |
|
134 |
be provided or otherwise made available to, or used by, any |
|
135 |
other person. No title to or ownership of the software is |
|
136 |
hereby transferred. |
|
137 |
" |
|
138 |
! |
|
139 |
||
0 | 140 |
documentation |
141 |
" |
|
142 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 143 |
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
|
144 |
acceptAction to be performed for accept |
125 | 145 |
|
146 |
If used with a model, this is informed by sending it a changeMsg with |
|
147 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
148 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 149 |
|
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
|
150 |
Please read the historic notice in the ListView class. |
0 | 151 |
|
586 | 152 |
[Instance variables:] |
0 | 153 |
|
3160 | 154 |
cursorLine <Number> line where cursor sits (1..) |
155 |
||
156 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
157 |
||
158 |
cursorCol <Number> col where cursor sits (1..) |
|
159 |
||
160 |
cursorShown <Boolean> true, if cursor is currently shown |
|
161 |
||
162 |
readOnly <Boolean> true, if text may not be edited |
|
163 |
||
164 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
165 |
cleared on accept. |
|
166 |
||
167 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
168 |
||
169 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
170 |
||
171 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
172 |
if it returns true, the modification will be done anyway. |
|
173 |
if it returns anything else, the modification is not done. |
|
174 |
||
175 |
cursorFgColor <Color> color used for cursor drawing |
|
176 |
cursorBgColor <Color> color used for cursor drawing |
|
177 |
||
178 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
179 |
are #block (solid-block cursor), #ibeam |
|
180 |
(vertical bar at insertion point) |
|
181 |
and #caret (caret below insertion-point) |
|
182 |
||
183 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
184 |
nil means: hide the cursor. |
|
185 |
||
186 |
undoAction <Block> block which undoes last cut, paste or replace |
|
187 |
(not yet fully implemented) |
|
188 |
||
189 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
190 |
this affects the next keyPress: if #paste it does not |
|
191 |
replace; otherwise it replaces the selection. |
|
192 |
||
193 |
lastCut <String> last cut or replaced string |
|
194 |
||
195 |
lastReplacement <String> last replacement |
|
196 |
||
197 |
replacing <Boolean> true if entered characters replace last selection |
|
198 |
||
199 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
200 |
when entering one; this is the default. |
|
201 |
||
202 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
203 |
||
204 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
205 |
argument |
|
206 |
||
207 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
208 |
focus to the next field. For editTextViews, this is false |
|
209 |
by default (i.e. tabs can be entered into the text). |
|
210 |
For some subclasses (inputFields), this may be true. |
|
211 |
||
212 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
213 |
removed when editing. |
|
214 |
Default is true. |
|
215 |
||
216 |
wordWrap <Boolean> Currently not used. |
|
217 |
||
218 |
lockUpdates <Boolean> internal, private |
|
219 |
||
220 |
prevCursorState <Boolean> temporary, private |
|
221 |
||
222 |
cursorMovementWhenUpdating |
|
223 |
<Symbol> defines where the cursor is to be positioned if the |
|
224 |
model changes its value by some outside activity |
|
225 |
(i.e. not by user input into the field). |
|
226 |
Can be one of: |
|
227 |
#keep / nil -> stay where it was |
|
228 |
#endOfText -> cursor to the end |
|
229 |
#endOfLine -> stay in the line, but move to end |
|
230 |
#beginOfText -> cursor to the beginning |
|
231 |
#beginOfLine -> stay in the line, but move to begin |
|
232 |
The default is #beginOfText |
|
233 |
||
234 |
||
235 |
||
236 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 237 |
|
238 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
239 |
userPreference values: |
3160 | 240 |
userPreferences.st80EditMode |
241 |
<Boolean> if true, cursor positioning is |
|
242 |
done as in vi or ST80; i.e. |
|
243 |
wysiwyg mode is somewhat relaxed, |
|
244 |
in that the cursor cannot be |
|
245 |
positioned behind a lines end. |
|
246 |
This is not yet completely implemented. |
|
33 | 247 |
used globals: |
248 |
||
3160 | 249 |
DeleteHistory <Text> last 1000 lines of deleted text |
250 |
(but only if this variable exists already) |
|
586 | 251 |
|
252 |
[styleSheet parameters:] |
|
121 | 253 |
|
3160 | 254 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
255 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
256 |
textCursorNoFocusForegroundColor |
|
257 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
258 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 259 |
|
260 |
[author:] |
|
3160 | 261 |
Claus Gittinger |
586 | 262 |
|
263 |
[see also:] |
|
3160 | 264 |
CodeView Workspace TextView ListView |
265 |
EditField |
|
0 | 266 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
267 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
268 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
269 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
270 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
271 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
272 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
273 |
basic setup: |
3160 | 274 |
[exBegin] |
275 |
|top textView| |
|
276 |
||
277 |
top := StandardSystemView new. |
|
278 |
top extent:300@200. |
|
279 |
||
280 |
textView := EditTextView new. |
|
281 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
282 |
top addSubView:textView. |
|
283 |
||
284 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
285 |
||
286 |
top open. |
|
287 |
[exEnd] |
|
594 | 288 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
289 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
with vertical scrollbar: |
3160 | 291 |
[exBegin] |
292 |
|top scrollView textView| |
|
293 |
||
294 |
top := StandardSystemView new. |
|
295 |
top extent:300@200. |
|
296 |
||
297 |
scrollView := ScrollableView for:EditTextView. |
|
298 |
textView := scrollView scrolledView. |
|
299 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
300 |
top addSubView:scrollView. |
|
301 |
||
302 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
303 |
||
304 |
top open. |
|
305 |
[exEnd] |
|
594 | 306 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
307 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
308 |
with horizontal & vertical scrollbars: |
3160 | 309 |
[exBegin] |
310 |
|top scrollView textView| |
|
311 |
||
312 |
top := StandardSystemView new. |
|
313 |
top extent:300@200. |
|
314 |
||
315 |
scrollView := HVScrollableView for:EditTextView. |
|
316 |
textView := scrollView scrolledView. |
|
317 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
318 |
top addSubView:scrollView. |
|
319 |
||
320 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
321 |
||
322 |
top open. |
|
323 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
324 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
325 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
326 |
set the action for accept: |
3160 | 327 |
[exBegin] |
328 |
|top textView| |
|
329 |
||
330 |
top := StandardSystemView new. |
|
331 |
top extent:300@200. |
|
332 |
||
333 |
textView := EditTextView new. |
|
334 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
335 |
top addSubView:textView. |
|
336 |
||
337 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
338 |
textView acceptAction:[:contents | |
|
339 |
Transcript showCR:'will not overwrite the file with:'. |
|
340 |
Transcript showCR:contents asString |
|
341 |
]. |
|
342 |
top open. |
|
343 |
[exEnd] |
|
594 | 344 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
346 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
347 |
non-string (text) items: |
3160 | 348 |
[exBegin] |
349 |
|top textView list| |
|
350 |
||
351 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
352 |
1 to:list size by:2 do:[:nr | |
|
353 |
list at:nr put:(Text string:(list at:nr) |
|
354 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
355 |
]. |
|
356 |
||
357 |
top := StandardSystemView new. |
|
358 |
top extent:300@200. |
|
359 |
||
360 |
textView := EditTextView new. |
|
361 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
362 |
top addSubView:textView. |
|
363 |
||
364 |
textView contents:list. |
|
365 |
top open. |
|
366 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
367 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
368 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
369 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
370 |
MVC operation: |
594 | 371 |
(the examples model here is a plug simulating a real model; |
372 |
real world applications would not use a plug ..) |
|
3160 | 373 |
[exBegin] |
374 |
|top textView model| |
|
375 |
||
376 |
model := Plug new. |
|
377 |
model respondTo:#accepted: |
|
378 |
with:[:newContents | |
|
379 |
Transcript showCR:'will not overwrite the file with:'. |
|
380 |
Transcript showCR:newContents asString |
|
381 |
]. |
|
382 |
model respondTo:#getList |
|
383 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
384 |
||
385 |
||
386 |
top := StandardSystemView new. |
|
387 |
top extent:300@200. |
|
388 |
||
389 |
textView := EditTextView new. |
|
390 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
391 |
top addSubView:textView. |
|
392 |
||
393 |
textView listMessage:#getList; |
|
394 |
model:model; |
|
395 |
changeMessage:#accepted:; |
|
396 |
aspect:#list. |
|
397 |
top open. |
|
398 |
[exEnd] |
|
594 | 399 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
400 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
401 |
two textViews on the same model: |
3160 | 402 |
[exBegin] |
403 |
|top1 textView1 top2 textView2 model currentContents| |
|
404 |
||
405 |
model := Plug new. |
|
406 |
model respondTo:#accepted: |
|
407 |
with:[:newContents | |
|
408 |
Transcript showCR:'accepted:'. |
|
409 |
Transcript showCR:newContents asString. |
|
410 |
currentContents := newContents. |
|
411 |
model changed:#contents |
|
412 |
]. |
|
413 |
model respondTo:#getList |
|
414 |
with:[Transcript showCR:'query'. |
|
415 |
currentContents]. |
|
416 |
||
417 |
||
418 |
top1 := StandardSystemView new. |
|
419 |
top1 extent:300@200. |
|
420 |
||
421 |
textView1 := EditTextView new. |
|
422 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
423 |
top1 addSubView:textView1. |
|
424 |
||
425 |
textView1 listMessage:#getList; |
|
426 |
model:model; |
|
427 |
aspect:#contents; |
|
428 |
changeMessage:#accepted:. |
|
429 |
top1 open. |
|
430 |
||
431 |
top2 := StandardSystemView new. |
|
432 |
top2 extent:300@200. |
|
433 |
||
434 |
textView2 := EditTextView new. |
|
435 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
436 |
top2 addSubView:textView2. |
|
437 |
||
438 |
textView2 listMessage:#getList; |
|
439 |
model:model; |
|
440 |
aspect:#contents; |
|
441 |
changeMessage:#accepted:. |
|
442 |
top2 open. |
|
443 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
444 |
" |
0 | 445 |
! ! |
446 |
||
865 | 447 |
!EditTextView class methodsFor:'defaults'! |
59 | 448 |
|
1419 | 449 |
st80Mode |
450 |
"return true, if the st80 editing mode is turned on. |
|
451 |
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
|
452 |
beyond the end of a line or the end of the text." |
1419 | 453 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
454 |
^ UserPreferences current st80EditMode |
1419 | 455 |
|
456 |
" |
|
457 |
EditTextView st80Mode:true |
|
458 |
EditTextView st80Mode:false |
|
459 |
" |
|
460 |
||
461 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
462 |
! |
|
463 |
||
464 |
st80Mode:aBoolean |
|
465 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 466 |
beyond the end of a line or the last line" |
1419 | 467 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
468 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 469 |
|
470 |
" |
|
471 |
EditTextView st80Mode:true |
|
472 |
EditTextView st80Mode:false |
|
473 |
" |
|
474 |
||
475 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
476 |
! |
|
477 |
||
59 | 478 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
479 |
"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
|
480 |
|
1390 | 481 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
3160 | 482 |
#'textCursor.noFocusForegroundColor' |
483 |
#'textCursor.type' |
|
484 |
#'textCursor.typeNoFocus' |
|
485 |
#'editText.st80Mode')> |
|
1355 | 486 |
|
487 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
488 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
489 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
490 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
491 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
492 |
|
1419 | 493 |
" |
494 |
self updateStyleCache |
|
495 |
" |
|
496 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
497 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 498 |
! ! |
499 |
||
2744 | 500 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
501 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
502 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
503 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
504 |
|
2019 | 505 |
"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
|
506 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
507 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
508 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
509 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
510 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
511 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
512 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
513 |
|
1390 | 514 |
cutSelection |
515 |
self cut |
|
516 |
||
517 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
518 |
! |
|
519 |
||
1590 | 520 |
deselect |
521 |
"remove the selection" |
|
522 |
||
523 |
^ self unselect |
|
524 |
||
525 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
526 |
! |
|
527 |
||
2101 | 528 |
enabled:aBoolean |
529 |
||
530 |
self readOnly:aBoolean not |
|
531 |
||
532 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
533 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
534 |
! |
|
535 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
536 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
537 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
538 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
539 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
540 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
541 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
542 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
543 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
544 |
"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
|
545 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
546 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
547 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
548 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
549 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
550 |
col < 1 ifTrue:[ |
3160 | 551 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
552 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
553 |
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
|
554 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
555 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
556 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
557 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
558 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
559 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
560 |
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
|
561 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
562 |
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
|
563 |
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
|
564 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
565 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
566 |
"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
|
567 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
568 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
569 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
570 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
571 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
572 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
573 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
574 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 575 |
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
|
576 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
577 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 578 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
579 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
580 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
581 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
582 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
583 |
v insertAndSelect:'<- hello there' at:5. |
125 | 584 |
" |
1390 | 585 |
! |
586 |
||
587 |
pasteSelection |
|
588 |
self paste |
|
589 |
||
590 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 591 |
! |
592 |
||
593 |
replaceSelectionWith:aString |
|
594 |
^ self replaceSelectionBy:aString |
|
595 |
||
596 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
597 |
! |
|
598 |
||
599 |
selectAt:pos |
|
600 |
"move the cursor before cursorPosition." |
|
601 |
||
602 |
self cursorToCharacterPosition:pos |
|
603 |
||
604 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
605 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
606 |
! |
|
607 |
||
608 |
selectFrom:startPos to:endPos |
|
609 |
"change the selection given two aCharacterPositions." |
|
610 |
||
611 |
|line1 col1 line2 col2| |
|
612 |
||
613 |
startPos > endPos ifTrue:[ |
|
3160 | 614 |
^ self unselect |
1590 | 615 |
]. |
616 |
||
617 |
line1 := self lineOfCharacterPosition:startPos. |
|
618 |
col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1. |
|
619 |
col1 < 1 ifTrue:[ |
|
3160 | 620 |
col1 := 1 |
1590 | 621 |
]. |
622 |
line2 := self lineOfCharacterPosition:endPos. |
|
623 |
col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1. |
|
624 |
col2 < 1 ifTrue:[ |
|
3160 | 625 |
col2 := 1 |
1590 | 626 |
]. |
627 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
628 |
||
629 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
2101 | 630 |
! |
631 |
||
632 |
textHasChanged |
|
633 |
^ self modified |
|
634 |
||
635 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
636 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
637 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
638 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
639 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
640 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
641 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
642 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
643 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
644 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
645 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
646 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
648 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
649 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
650 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
651 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
652 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
653 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
654 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
655 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
657 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
658 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
659 |
|
2792 | 660 |
acceptChannel |
661 |
"return the valueHolder holding true if text was accepted. |
|
662 |
By placing a true into this channel, an accept can also be forced." |
|
663 |
||
664 |
^ acceptChannel |
|
665 |
||
666 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
667 |
! |
|
668 |
||
669 |
acceptChannel:aValueHolder |
|
670 |
"set the valueHolder holding true if text was accepted. |
|
671 |
By placing a true into this channel, an accept can also be forced." |
|
672 |
||
673 |
|prev| |
|
674 |
||
675 |
prev := acceptChannel. |
|
676 |
acceptChannel := aValueHolder. |
|
677 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
678 |
||
679 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
680 |
! |
|
681 |
||
1108 | 682 |
acceptEnabled:aBoolean |
683 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
684 |
||
685 |
acceptEnabled := aBoolean |
|
686 |
||
687 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
688 |
! |
|
689 |
||
2792 | 690 |
accepted |
691 |
"return true if text was accepted" |
|
692 |
||
693 |
^ acceptChannel value |
|
694 |
||
695 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
696 |
! |
|
697 |
||
698 |
accepted:aBoolean |
|
699 |
"set/clear the accepted flag. |
|
700 |
This may force my current contents to be placed into my model." |
|
701 |
||
702 |
acceptChannel value:aBoolean. |
|
703 |
||
704 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
705 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
706 |
! |
|
707 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
708 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
709 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
710 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
711 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
712 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
713 |
|
2774 | 714 |
cursorMovementWhenUpdating |
3160 | 715 |
"return what is be done with the cursor, |
2774 | 716 |
when I get a new text (via the model or the #contents/#list) |
717 |
Allowed arguments are: |
|
3160 | 718 |
#keep / nil -> stay where it was |
719 |
#endOfText -> position cursor to the end |
|
720 |
#beginOfText -> position cursor to the beginning |
|
721 |
#endOfLine -> position cursor to the current lines end |
|
722 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 723 |
The default is #beginOfText. |
724 |
This may be useful for fields which get new values assigned from |
|
725 |
the program (i.e. not from the user)" |
|
726 |
||
727 |
^ cursorMovementWhenUpdating |
|
728 |
||
729 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
730 |
! |
|
731 |
||
2133 | 732 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 733 |
"define what should be done with the cursor, |
2133 | 734 |
when I get a new text (via the model or the #contents/#list) |
735 |
Allowed arguments are: |
|
3160 | 736 |
#keep / nil -> stay where it was |
737 |
#endOfText -> position cursor to the end |
|
738 |
#beginOfText -> position cursor to the beginning |
|
739 |
#endOfLine -> position cursor to the current lines end |
|
740 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 741 |
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
|
742 |
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
|
743 |
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
|
744 |
|
2133 | 745 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
746 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
747 |
"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
|
748 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
749 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
750 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
751 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
752 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
753 |
|
2438 | 754 |
dontReplaceSelectionOnInput |
755 |
typeOfSelection := #paste |
|
756 |
! |
|
757 |
||
3235 | 758 |
editModeHolder |
759 |
^ editMode. |
|
760 |
! |
|
761 |
||
762 |
editModeInsert |
|
763 |
editMode value:EditMode insertMode |
|
764 |
! |
|
765 |
||
766 |
editModeInsertAndSelect |
|
767 |
editMode value:EditMode insertAndSelectMode |
|
768 |
! |
|
769 |
||
770 |
editModeOverwrite |
|
771 |
editMode value:EditMode overwriteMode |
|
772 |
! |
|
773 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
774 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
775 |
"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
|
776 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
777 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
778 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
779 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
780 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
781 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
782 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
783 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
784 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
785 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
786 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
787 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
788 |
readOnly == true ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
789 |
readOnly := true. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
790 |
middleButtonMenu notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
791 |
middleButtonMenu disableAll:#(cut paste replace indent) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
792 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
793 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
794 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
795 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
796 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
797 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
798 |
insertMode:aBoolean |
3235 | 799 |
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
|
800 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
801 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
802 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
803 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
804 |
insertModeHolder |
3235 | 805 |
^ BlockValue |
806 |
with:[:m | m value isInsertMode] |
|
807 |
argument:(editMode). |
|
808 |
! |
|
809 |
||
810 |
isInInsertMode |
|
811 |
^ editMode value isInsertMode |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
812 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
813 |
|
2792 | 814 |
isReadOnly |
815 |
"return true, if the text is readonly." |
|
816 |
||
817 |
^ readOnly value |
|
818 |
||
819 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
820 |
! |
|
821 |
||
2796 | 822 |
modeLabelHolder |
823 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
824 |
||
3160 | 825 |
^ BlockValue |
3235 | 826 |
with:[:e :l | |
827 |
self isReadOnly ifTrue:[ |
|
828 |
'' |
|
829 |
] ifFalse:[ |
|
830 |
l value |
|
831 |
ifTrue:[ |
|
832 |
'L' asText allBold colorizeAllWith:Color red] |
|
833 |
ifFalse:[ |
|
834 |
e value infoPrintString]]] |
|
835 |
argument:(self editModeHolder) |
|
836 |
argument:(self learnModeHolder). |
|
2796 | 837 |
! |
838 |
||
2792 | 839 |
modified |
840 |
"return true if text was modified" |
|
841 |
||
842 |
^ modifiedChannel value |
|
843 |
! |
|
844 |
||
845 |
modified:aBoolean |
|
846 |
"set/clear the modified flag" |
|
847 |
||
848 |
modifiedChannel value:aBoolean |
|
849 |
||
850 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
851 |
! |
|
852 |
||
853 |
modifiedChannel |
|
854 |
"return the valueHolder holding true if text was modified" |
|
855 |
||
856 |
^ modifiedChannel |
|
857 |
! |
|
858 |
||
859 |
modifiedChannel:aValueHolder |
|
860 |
"set the valueHolder holding true if text was modified" |
|
861 |
||
862 |
|prev| |
|
863 |
||
864 |
prev := modifiedChannel. |
|
865 |
modifiedChannel := aValueHolder. |
|
866 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
867 |
||
868 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
869 |
! |
|
870 |
||
871 |
readOnly |
|
872 |
"make the text readonly. |
|
873 |
Somewhat obsolete - use #readOnly:" |
|
874 |
||
875 |
<resource:#obsolete> |
|
876 |
||
877 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
878 |
readOnly := true |
|
879 |
||
880 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
881 |
! |
|
882 |
||
883 |
readOnly:aBoolean |
|
884 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
885 |
The argument may also be a valueHolder." |
|
886 |
||
887 |
readOnly := aBoolean |
|
888 |
||
889 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
890 |
! |
|
891 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
892 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
893 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
894 |
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
|
895 |
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
|
896 |
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
|
897 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
898 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
899 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
900 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
901 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
902 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
903 |
"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
|
904 |
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
|
905 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
906 |
|
3160 | 907 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
908 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
909 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
910 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
911 |
"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
|
912 |
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
|
913 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
914 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
915 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
916 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
917 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
918 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
919 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
920 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
921 |
"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
|
922 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
923 |
(self at:lineNr) = aLine ifFalse:[ |
3160 | 924 |
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
|
925 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
926 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
927 |
|
522 | 928 |
at:lineNr put:aLine |
929 |
(self at:lineNr) = aLine ifFalse:[ |
|
3160 | 930 |
super at:lineNr put:aLine. |
931 |
self textChanged |
|
522 | 932 |
]. |
933 |
! |
|
934 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
935 |
characterBeforeCursor |
2707 | 936 |
"return the character under the cursor - space if beyond line. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
937 |
For non-block cursors, this is the character immediately to the right |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
938 |
of the insertion-bar or caret." |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
939 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
940 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
941 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
942 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
943 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
944 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
945 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
946 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
947 |
characterUnderCursor |
2707 | 948 |
"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
|
949 |
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
|
950 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
952 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
953 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
954 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
contents |
2213 | 956 |
"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
|
957 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
958 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
959 |
self removeTrailingBlankLines. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
960 |
^ list asStringWithCRs |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
961 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
962 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
963 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
964 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
965 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
966 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
967 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
968 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
969 |
keepUndoHistory ifFalse:[ |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
970 |
undoSupport resetHistories. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
971 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
972 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
973 |
|
2213 | 974 |
contentsAsString |
975 |
"return the contents as a String (i.e. without emphasis)" |
|
976 |
||
977 |
list isNil ifTrue:[^ '']. |
|
978 |
self removeTrailingBlankLines. |
|
979 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
3160 | 980 |
ifFalse:[each string] |
981 |
]) asStringWithCRs |
|
2213 | 982 |
! |
983 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
984 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
985 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
986 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
987 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
988 |
^ cursorCol |
125 | 989 |
! |
990 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
991 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
992 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
993 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
994 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
995 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
996 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
997 |
cursorLine |
3160 | 998 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
999 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1000 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1001 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1002 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1003 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1004 |
cursorLineHolder |
3160 | 1005 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1006 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1007 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1008 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1009 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1010 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1011 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1012 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1013 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1014 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1015 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1016 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1017 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1018 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1019 |
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
|
1020 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1021 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1022 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1023 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1024 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1025 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1026 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1027 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1028 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1029 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1030 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1031 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1032 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1033 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1034 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1035 |
^ 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
|
1036 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1037 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1038 |
"/ 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
|
1039 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1040 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1041 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1042 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1043 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1044 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1045 |
undoSupport resetHistories. |
2955 | 1046 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1047 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1048 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1049 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1050 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1051 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1052 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1053 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1054 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1055 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1056 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1057 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1058 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1059 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1060 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1061 |
wasOn := self hideCursor. |
1993 | 1062 |
cursorFgColor := color1 onDevice:device. |
1063 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1064 |
wasOn ifTrue:[self showCursor] |
1333 | 1065 |
! |
1066 |
||
1899 | 1067 |
cursorType |
1068 |
"return the style of the text cursor. |
|
1069 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1070 |
#bigCaret and #bigSolidCaret" |
1899 | 1071 |
|
1072 |
^ cursorType |
|
1073 |
||
1074 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1075 |
! |
|
1076 |
||
1333 | 1077 |
cursorType:aCursorTypeSymbol |
1078 |
"set the style of the text cursor. |
|
1079 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1080 |
#bigCaret and #bigSolidCaret" |
1333 | 1081 |
|
1334 | 1082 |
cursorType := aCursorTypeSymbol. |
1333 | 1083 |
|
1084 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1085 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1086 |
! |
1087 |
||
1899 | 1088 |
cursorTypeNoFocus |
1089 |
"return the style of the text cursor when the view has no focus. |
|
1090 |
If left unspecified, this is the same as the regular cursorType." |
|
1091 |
||
1092 |
^ cursorTypeNoFocus |
|
1093 |
||
1094 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1095 |
! |
|
1096 |
||
1334 | 1097 |
cursorTypeNoFocus:aCursorTypeSymbol |
1098 |
"set the style of the text cursor when the view has no focus. |
|
1099 |
If left unspecified, this is the same as the regular cursorType." |
|
1100 |
||
1101 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1102 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1103 |
|
2119 | 1104 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1105 |
|
125 | 1106 |
accept |
1107 |
"accept the current contents by executing the accept-action and/or |
|
1108 |
changeMessage." |
|
1109 |
||
1108 | 1110 |
acceptEnabled == false ifTrue:[ |
3160 | 1111 |
self beep. |
1112 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1113 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1114 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3160 | 1115 |
^ self |
1108 | 1116 |
]. |
1117 |
||
125 | 1118 |
lockUpdates := true. |
1013 | 1119 |
|
1120 |
"/ |
|
1121 |
"/ ST-80 way of doing it |
|
1122 |
"/ |
|
1123 |
model notNil ifTrue:[ |
|
3160 | 1124 |
self sendChangeMessageWith:self argForChangeMessage. |
1013 | 1125 |
]. |
1126 |
||
2999 | 1127 |
model notNil ifTrue:[ |
3160 | 1128 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1129 |
]. |
1130 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1131 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1132 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1133 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1134 |
"/ 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
|
1135 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1136 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1137 |
acceptAction notNil ifTrue:[ |
3160 | 1138 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1139 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1140 |
|
125 | 1141 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1142 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1143 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1144 |
! |
1145 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1146 |
argForChangeMessage |
597 | 1147 |
"return the argument to be passed with the change notification. |
1148 |
Defined as separate method for easier subclassability." |
|
1149 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1150 |
^ self contents |
597 | 1151 |
|
1152 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1153 |
! |
1154 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1155 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1156 |
"get my contents from the model. |
597 | 1157 |
Redefined to ignore updates resulting from my own changes |
1158 |
(i.e. if lockUpdates is true)." |
|
121 | 1159 |
|
1160 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1161 |
ignore updates from my own change |
121 | 1162 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1163 |
lockUpdates ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1164 |
lockUpdates := false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1165 |
^ self |
121 | 1166 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1167 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1168 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1169 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1170 |
"/ validate the cursorLine |
3160 | 1171 |
(cursorLine notNil |
2310 | 1172 |
and:[ cursorLine > list size ]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1173 |
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
|
1174 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1175 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1176 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1177 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1178 |
changedObject == acceptChannel ifTrue:[ |
3160 | 1179 |
acceptChannel value == true ifTrue:[ |
1180 |
self accept. |
|
1181 |
]. |
|
1182 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1183 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1184 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1185 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1186 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1187 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1188 |
! ! |
1189 |
||
1190 |
!EditTextView methodsFor:'cursor handling'! |
|
1191 |
||
2406 | 1192 |
characterPositionOfCursor |
1193 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1194 |
! |
|
1195 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1196 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1197 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1198 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1199 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1200 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1201 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1202 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1203 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1204 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1205 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1206 |
|
2822 | 1207 |
(cursorCol == newCol) ifTrue:[^ self]. |
1208 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1209 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1210 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1211 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1212 |
|
1213 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1214 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1215 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1216 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1217 |
"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
|
1218 |
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
|
1219 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1220 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1221 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1222 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1223 |
|
2707 | 1224 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1225 |
cursorLine > list size ifTrue:[ |
3160 | 1226 |
wasOn := self hideCursor. |
1227 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1228 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1229 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1230 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1231 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1232 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1233 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1234 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1235 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1236 |
"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
|
1237 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1238 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1240 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1241 |
wasOn := self hideCursor. |
1242 |
nv := cursorVisibleLine + n - 1. |
|
1243 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1244 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1245 |
]. |
|
1246 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1247 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1248 |
] ifFalse:[ |
3160 | 1249 |
(nL := cursorLine) isNil ifTrue:[ |
1250 |
nL := firstLineShown |
|
1251 |
]. |
|
1252 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
|
1253 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1254 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1255 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1256 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1257 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1258 |
|
121 | 1259 |
cursorHome |
597 | 1260 |
"scroll to top AND move cursor to first line of text." |
121 | 1261 |
|
674 | 1262 |
self cursorLine:1 col:1 |
1263 |
||
1264 |
"/ |wasOn| |
|
1265 |
"/ |
|
1266 |
"/ wasOn := self hideCursor. |
|
1267 |
"/ self scrollToTop. |
|
1268 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1269 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1270 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1271 |
||
1272 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1273 |
! |
1274 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1275 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1276 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1277 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1278 |
(cursorCol ~~ 1) ifTrue:[ |
3160 | 1279 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1280 |
] ifFalse:[ |
3160 | 1281 |
cursorLine ~~ 1 ifTrue:[ |
1282 |
self st80EditMode ifTrue:[ |
|
1283 |
self cursorUp. |
|
1284 |
self cursorToEndOfLine. |
|
1285 |
] |
|
1286 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1287 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1288 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1289 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1292 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1293 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1294 |
|
676 | 1295 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1296 |
|
2822 | 1297 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1298 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1299 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1300 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1301 |
|
672 | 1302 |
(col < 1) ifTrue:[ |
3160 | 1303 |
newCol := 1 |
672 | 1304 |
] ifFalse:[ |
3160 | 1305 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1306 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1307 |
self st80EditMode ifTrue:[ |
3160 | 1308 |
(cursorLine == list size |
1309 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1310 |
newCol := (self listAt:(list size)) size + 1. |
|
1311 |
] |
|
1419 | 1312 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1313 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1314 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1315 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1316 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1317 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1318 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1319 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1320 |
"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
|
1321 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1322 |
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
|
1323 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1324 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1325 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1326 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1327 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1328 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1329 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1330 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1331 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1332 |
"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
|
1333 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1334 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1335 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1336 |
self checkForExistingLine:(cursorLine + 1). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1337 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1338 |
nFullLinesShown notNil ifTrue:[ |
1339 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1340 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1341 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1342 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1343 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1344 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1345 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1346 |
|
674 | 1347 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1348 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1349 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1350 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1351 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1352 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1353 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1354 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1355 |
self st80EditMode ifTrue:[ |
3160 | 1356 |
l := (self listAt:cursorLine). |
1357 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1358 |
cursorLine < list size ifTrue:[ |
|
1359 |
self cursorReturn. |
|
1360 |
]. |
|
1361 |
^ self |
|
1362 |
] |
|
1363 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1364 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1365 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1366 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1367 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1368 |
|
1833 | 1369 |
cursorShown:aBoolean |
1370 |
"change cursor visibility |
|
1371 |
return true if cursor was visible before." |
|
1372 |
||
1373 |
|oldState| |
|
1374 |
||
1375 |
oldState := cursorShown. |
|
1376 |
||
1377 |
aBoolean ifTrue:[ |
|
3160 | 1378 |
self drawCursor. |
1833 | 1379 |
] ifFalse:[ |
3160 | 1380 |
(cursorShown and:[shown]) ifTrue: [ |
1381 |
self undrawCursor. |
|
1382 |
]. |
|
1833 | 1383 |
]. |
1384 |
cursorShown := aBoolean. |
|
1385 |
||
1386 |
^ oldState |
|
1387 |
||
1388 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1389 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1390 |
! |
|
1391 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1392 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1393 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1394 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1395 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1396 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1398 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1399 |
"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
|
1400 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1401 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1402 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1403 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1404 |
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
|
1405 |
cursorCol > textStart ifTrue:[ |
3160 | 1406 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1407 |
] ifFalse:[ |
3160 | 1408 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1409 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1410 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1411 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1412 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1413 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1414 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1415 |
"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
|
1416 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1417 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1419 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1420 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1421 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1422 |
(newTop < 1) ifTrue:[ |
3160 | 1423 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1424 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1425 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1426 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1427 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1428 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1429 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1430 |
|
674 | 1431 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1432 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1433 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1434 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1435 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1436 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1437 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1438 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1439 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1440 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1441 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1442 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1443 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1444 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1445 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1446 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1447 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1448 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1449 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1450 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1451 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1452 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1453 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1454 |
cursorLine >= lineNr ifTrue:[ |
3238
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1455 |
line := self listAt:cursorLine. |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1456 |
(line isEmptyOrNil) ifTrue:[ |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1457 |
^ self |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1458 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1459 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1460 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1461 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1462 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1463 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1464 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1465 |
(newTop < 1) ifTrue:[ |
3238
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1466 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1467 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1468 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1469 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1470 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1471 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1472 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1473 |
|
674 | 1474 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1475 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1476 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1477 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1478 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1479 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1480 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1481 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1482 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1483 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1484 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1485 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1486 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1487 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1488 |
cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1489 |
"move cursor to the end of the text (behinf last character in last line)" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1490 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1491 |
|wasOn newTop| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1492 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1493 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1494 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1495 |
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
|
1496 |
(newTop < 1) ifTrue:[ |
3160 | 1497 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1498 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1499 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1500 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1501 |
self setValidatedCursorLine:list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1502 |
self setCursorCol:(self validateCursorCol:(self listAt:cursorLine) size inLine:cursorLine). |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1503 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1504 |
self makeCursorVisibleAndShowCursor:wasOn. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1505 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1506 |
|
131 | 1507 |
cursorToFirstVisibleLine |
1508 |
"place cursor into the first visible line; do not scroll." |
|
1509 |
||
1510 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1511 |
! |
|
1512 |
||
1513 |
cursorToLastVisibleLine |
|
1514 |
"place cursor into the first visible line; do not scroll." |
|
1515 |
||
1516 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1517 |
! |
|
1518 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1519 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1520 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1521 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1522 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1523 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1524 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1525 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1526 |
self wordAtLine:cursorLine col:cursorCol do:[ |
3160 | 1527 |
:beginLine :beginCol :endLine :endCol :style | |
1528 |
||
1529 |
line := endLine. |
|
1530 |
col := endCol + 1. |
|
1531 |
searching := true. |
|
1532 |
[searching |
|
1533 |
and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
1534 |
self wordAtLine:line col:col do:[ |
|
1535 |
:beginLine :beginCol :endLine :endCol :style | |
|
1536 |
||
1537 |
(line > list size) ifTrue:[ |
|
1538 |
"break out" |
|
1539 |
searching := false |
|
1540 |
] ifFalse:[ |
|
1541 |
line := endLine. |
|
1542 |
col := endCol + 1. |
|
1543 |
] |
|
1544 |
] |
|
1545 |
]. |
|
1546 |
self cursorLine:line col:col |
|
121 | 1547 |
] |
1548 |
! |
|
1549 |
||
499 | 1550 |
cursorToPreviousWord |
1551 |
"move the cursor to the beginning of this or the previous word" |
|
1552 |
||
1553 |
|col line searching l| |
|
1554 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1555 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1556 |
|
1557 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
3160 | 1558 |
:beginLine :beginCol :endLine :endCol :style | |
1559 |
||
1560 |
line := beginLine. |
|
1561 |
col := beginCol. |
|
1562 |
style == #wordLeft ifTrue:[ |
|
1563 |
col := col + 1 |
|
1564 |
]. |
|
1565 |
||
1566 |
(cursorLine == line |
|
1567 |
and:[cursorCol == col]) ifTrue:[ |
|
1568 |
searching := true. |
|
1569 |
||
1570 |
col > 1 ifTrue:[ |
|
1571 |
col := col - 1. |
|
1572 |
]. |
|
1573 |
||
1574 |
[searching] whileTrue:[ |
|
1575 |
(col == 1) ifTrue:[ |
|
1576 |
line == 1 ifTrue:[ |
|
1577 |
searching := false |
|
1578 |
] ifFalse:[ |
|
1579 |
line := line - 1. |
|
1580 |
l := list at:line. |
|
1581 |
col := l size + 1. |
|
1582 |
] |
|
1583 |
] ifFalse:[ |
|
1584 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
1585 |
self wordAtLine:line col:col do:[ |
|
1586 |
:beginLine :beginCol :endLine :endCol :style | |
|
1587 |
||
1588 |
line := beginLine. |
|
1589 |
col := beginCol. |
|
1590 |
style == #wordLeft ifTrue:[ |
|
1591 |
col := col + 1 |
|
1592 |
]. |
|
1593 |
searching := false. |
|
1594 |
] |
|
1595 |
] ifTrue:[ |
|
1596 |
col := col - 1 |
|
1597 |
] |
|
1598 |
] |
|
1599 |
] |
|
1600 |
]. |
|
1601 |
self cursorLine:line col:col |
|
499 | 1602 |
] |
1603 |
||
1604 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
1605 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
1606 |
! |
|
1607 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1608 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1610 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1611 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1612 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1613 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1614 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1615 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1616 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1617 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1618 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1620 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1621 |
"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
|
1622 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
|wasOn nv nl| |
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 |
cursorLine isNil ifTrue:[ |
3160 | 1626 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
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 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1629 |
nl < 1 ifTrue:[nl := 1]. |
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 |
(nl ~~ cursorLine) ifTrue: [ |
3160 | 1632 |
wasOn := self hideCursor. |
1633 |
cursorVisibleLine notNil ifTrue:[ |
|
1634 |
nv := cursorVisibleLine - n. |
|
1635 |
nv < 1 ifTrue:[ |
|
1636 |
self scrollUp:(nv negated + 1) |
|
1637 |
]. |
|
1638 |
]. |
|
1639 |
self setValidatedCursorLine:nl col:cursorCol. |
|
1640 |
wasOn ifTrue:[self showCursor]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1641 |
] |
672 | 1642 |
|
674 | 1643 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1644 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1645 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1646 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1647 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1648 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1649 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1650 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1651 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1652 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1653 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1654 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1655 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1656 |
|
676 | 1657 |
newCol := colNr. |
1658 |
(newCol < 1) ifTrue:[ |
|
3160 | 1659 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1660 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1661 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1662 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1663 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1664 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
1665 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1666 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1667 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1668 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1669 |
"put cursor to position next to x/y coordinate in view" |
121 | 1670 |
|
1671 |
|line col| |
|
1672 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1673 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1674 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1675 |
self cursorVisibleLine:line col:col. |
121 | 1676 |
! |
1677 |
||
1678 |
drawCursor |
|
1679 |
"draw the cursor if shown and cursor is visible. |
|
1680 |
(but not, if there is a selection - to avoid confusion)" |
|
1681 |
||
1682 |
shown ifTrue:[ |
|
3160 | 1683 |
cursorVisibleLine notNil ifTrue:[ |
1684 |
self hasSelection ifFalse:[ |
|
1685 |
self drawCursorCharacter |
|
1686 |
] |
|
1687 |
] |
|
121 | 1688 |
] |
1689 |
! |
|
1690 |
||
1691 |
drawCursor:cursorType with:fgColor and:bgColor |
|
1692 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 1693 |
of cursor should be drawn. |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1694 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
3160 | 1695 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1696 |
|
2570 | 1697 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 1698 |
|
1699 |
self hasSelection ifTrue:[ |
|
3160 | 1700 |
" |
1701 |
hide cursor, if there is a selection |
|
1702 |
" |
|
1703 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 1704 |
]. |
1705 |
||
1334 | 1706 |
cursorType == #none ifTrue:[ |
3160 | 1707 |
^ self |
1334 | 1708 |
]. |
1709 |
||
121 | 1710 |
cursorType == #block ifTrue:[ |
3160 | 1711 |
super drawVisibleLine:cursorVisibleLine |
1712 |
col:cursorCol |
|
1713 |
with:fgColor |
|
1714 |
and:bgColor. |
|
1715 |
^ self |
|
121 | 1716 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1717 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 1718 |
y := self yOfVisibleLine:cursorVisibleLine. |
1719 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
1720 |
oldPaint := self paint. "/ do not clobber GC |
121 | 1721 |
cursorType == #frame ifTrue:[ |
3160 | 1722 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1723 |
||
1724 |
char := self characterUnderCursor asString. |
|
1725 |
self paint:bgColor. |
|
1726 |
self displayRectangleX:x y:y |
|
1727 |
width:(font widthOf:char) height:fontHeight. |
|
133 | 1728 |
] ifFalse:[ |
3160 | 1729 |
self paint:bgColor. |
1730 |
cursorType == #ibeam ifTrue:[ |
|
1731 |
x1 := x - 1. |
|
1732 |
y2 := y + fontHeight - 1. |
|
1733 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
1734 |
self displayLineFromX:x y:y toX:x y:y2. |
|
1735 |
^ self |
|
1736 |
]. |
|
1737 |
||
1738 |
cursorType == #Ibeam ifTrue:[ |
|
1739 |
x1 := x - 1. |
|
1740 |
y := y + 1. |
|
1741 |
y2 := y + fontHeight - 1. |
|
1742 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
1743 |
self displayLineFromX:x y:y toX:x y:y2. |
|
1744 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
1745 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
1746 |
^ self |
|
1747 |
]. |
|
1748 |
||
1749 |
y := y + fontHeight - 3. |
|
1750 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
1751 |
w := (fontWidth * 2 // 3) max:4. |
|
1752 |
y2 := y + w + (w//2). |
|
1753 |
] ifFalse:[ |
|
1754 |
w := (fontWidth // 2) max:4. |
|
1755 |
y2 := y + w. |
|
1756 |
]. |
|
1757 |
x1 := x - w. |
|
1758 |
x2 := x + w. |
|
1759 |
||
1760 |
oldClip := self clippingRectangleOrNil. |
|
1761 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
1762 |
||
1763 |
cursorType == #caret ifTrue:[ |
|
1764 |
self lineWidth:2. |
|
1765 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
1766 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
1767 |
] ifFalse:[ |
|
1768 |
"anything else: solidCaret" |
|
1769 |
||
1770 |
self fillPolygon:(Array with:(x1 @ y2) |
|
1771 |
with:(x @ y) |
|
1772 |
with:(x2 @ y2)) |
|
1773 |
]. |
|
1774 |
||
1775 |
self clippingRectangle:oldClip |
|
121 | 1776 |
]. |
133 | 1777 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
1778 |
|
2088 | 1779 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 1780 |
! |
1781 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1782 |
drawCursorCharacter |
3160 | 1783 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1784 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1785 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1786 |
|
3160 | 1787 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1788 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1789 |
and:[self isReadOnly not]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1790 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1791 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1792 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1793 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1794 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1795 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1796 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1797 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1798 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1799 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1800 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1801 |
self hasSelection ifTrue:[ |
3160 | 1802 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 1803 |
]. |
1804 |
cursorType == #none ifTrue:[ |
|
3160 | 1805 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1806 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1807 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 1808 |
|
1809 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1810 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1811 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1812 |
drawNoFocusCursor |
3160 | 1813 |
"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
|
1814 |
|
1334 | 1815 |
|cType| |
1816 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1817 |
self hasSelection ifTrue:[ |
3160 | 1818 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 1819 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1820 |
|
1334 | 1821 |
cType := cursorTypeNoFocus ? cursorType. |
1822 |
cType == #none ifTrue:[ |
|
3160 | 1823 |
^ self undrawCursor |
1334 | 1824 |
]. |
1825 |
||
1826 |
cType == #block ifTrue:[ |
|
3160 | 1827 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1828 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
1829 |
|
1334 | 1830 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
1831 |
||
1832 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1833 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1834 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1835 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1836 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1837 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1838 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1839 |
self makeLineVisible:aLineNumber. |
2951 | 1840 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1841 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1842 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1843 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1844 |
hideCursor |
1833 | 1845 |
"make cursor invisible if currently invisible" |
1846 |
||
1847 |
^ self cursorShown:false |
|
1848 |
||
1849 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 1850 |
! |
1851 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1852 |
makeCursorVisible |
3160 | 1853 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1854 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1855 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1856 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1858 |
cursorLine notNil ifTrue:[ |
3160 | 1859 |
line := cursorLine. |
1860 |
col := cursorCol. |
|
1861 |
" |
|
1862 |
if there is a selection, its better to |
|
1863 |
have its start being visible, instead of the end |
|
1864 |
" |
|
1865 |
(selectionStartLine notNil |
|
1866 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
1867 |
expandingTop ~~ false ifTrue:[ |
|
1868 |
line := selectionStartLine. |
|
1869 |
col := selectionStartCol. |
|
1870 |
] ifFalse:[ |
|
1871 |
line := selectionEndLine. |
|
1872 |
col := selectionEndCol |
|
1873 |
] |
|
1874 |
]. |
|
1875 |
self makeLineVisible:line. |
|
1876 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1877 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1878 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
1879 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1880 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1881 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1882 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1883 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1884 |
if flag is true, draw the cursor" |
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 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1887 |
flag ifTrue:[self showCursor] |
121 | 1888 |
! |
1889 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1890 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1891 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1892 |
|
2815 | 1893 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1894 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1895 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1896 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1897 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1898 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1899 |
|
3303 | 1900 |
"/ self assert:(lineNr notNil). |
1901 |
||
1902 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1903 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1904 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1905 |
! |
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 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1908 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1909 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1910 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1911 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1912 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1913 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1914 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1915 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1916 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1917 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1918 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1919 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1920 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1921 |
"strictly private: set the cursorLine and update the visibleLine" |
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 setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1924 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1925 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1926 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1927 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1928 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1929 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1930 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1931 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1932 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1933 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1934 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1935 |
|
1833 | 1936 |
^ self cursorShown:true |
1937 |
||
1938 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1941 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1942 |
"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
|
1943 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1944 |
|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
|
1945 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1946 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1947 |
prevCol := cursorCol - 1. |
1948 |
||
1949 |
"/ if there is any italic stuff in the cursor line, |
|
1950 |
"/ redraw it completely (because characters overlap). |
|
1951 |
cursorCol > 1 ifTrue:[ |
|
1952 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
1953 |
line hasChangeOfEmphasis ifTrue:[ |
|
1954 |
line size >= (cursorCol-1) ifTrue:[ |
|
1955 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
1956 |
line size >= (cursorCol) ifTrue:[ |
|
1957 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
1958 |
line size >= (cursorCol+1) ifTrue:[ |
|
1959 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
1960 |
]. |
|
1961 |
]. |
|
1962 |
]. |
|
1963 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
1964 |
^ super redrawVisibleLine:cursorVisibleLine |
|
1965 |
] |
|
1966 |
] |
|
1967 |
] |
|
1968 |
]. |
|
1969 |
||
1970 |
((cursorType == #caret) |
|
1971 |
or:[cursorType == #solidCaret |
|
1972 |
or:[cursorType == #bigSolidCaret |
|
1973 |
or:[cursorType == #bigCaret |
|
1974 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
1975 |
"caret-cursor touches 4 characters" |
|
1976 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
1977 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
1978 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
1979 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
1980 |
] ifFalse:[ |
|
1981 |
"care for left margin" |
|
1982 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
1983 |
]. |
|
1984 |
^ self |
|
1985 |
]. |
|
1986 |
||
1987 |
cursorType == #ibeam ifTrue:[ |
|
1988 |
"ibeam-cursor touches 2 characters" |
|
1989 |
cursorCol > 1 ifTrue:[ |
|
1990 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
1991 |
] ifFalse:[ |
|
1992 |
"care for left margin" |
|
1993 |
super redrawVisibleLine:cursorVisibleLine. |
|
1994 |
]. |
|
1995 |
^ self |
|
1996 |
]. |
|
1997 |
||
1998 |
"block cursor is simple - just one character under cursor" |
|
1999 |
||
2000 |
"/ however, if italic characters are involved, we must care |
|
2001 |
"/ for the chars before/after the cursor. |
|
2002 |
"/ We redraw the part of the previous character which got |
|
2003 |
"/ detroyed by the block cursor. |
|
2004 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2005 |
||
2006 |
line := self visibleAt:cursorVisibleLine. |
|
2007 |
(line notNil and:[line isText]) ifTrue:[ |
|
2008 |
cursorCol > 1 ifTrue:[ |
|
2009 |
oldClip := self clippingRectangleOrNil. |
|
2010 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2011 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2012 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
2013 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2014 |
self clippingRectangle:oldClip. |
|
2015 |
^ self. |
|
2016 |
]. |
|
2017 |
]. |
|
2018 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2019 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2020 |
|
2088 | 2021 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2022 |
! |
2023 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2024 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2025 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2026 |
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
|
2027 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2028 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2029 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2030 |
|
672 | 2031 |
validateCursorCol:col inLine:line |
674 | 2032 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2033 |
Here, no limits are enforced (and col is returned), |
2034 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2035 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2036 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2037 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2038 |
|
1419 | 2039 |
"/ in ST80 mode, |
2707 | 2040 |
"/ the cursor may not be positioned beyond the |
2041 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2042 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2043 |
self st80EditMode ifTrue:[ |
3160 | 2044 |
l := (self listAt:line). |
2045 |
max := l size + 1. |
|
2046 |
col > max ifTrue:[ |
|
2047 |
^ max |
|
2048 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2049 |
]. |
672 | 2050 |
^ col |
2051 |
||
1419 | 2052 |
"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
|
2053 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2054 |
! |
2055 |
||
2056 |
validateCursorLine:line |
|
2057 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2058 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2059 |
redefined in views which dont like the cursor to be positioned |
2060 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2061 |
skip reserved regions" |
|
2062 |
||
1419 | 2063 |
"/ |
2064 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2065 |
"/ beyond the last line |
1419 | 2066 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2067 |
self st80EditMode ifTrue:[ |
3160 | 2068 |
^ (line min:(list size)) max:1 |
1419 | 2069 |
]. |
674 | 2070 |
^ line |
2071 |
||
1419 | 2072 |
"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
|
2073 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2074 |
! |
2075 |
||
121 | 2076 |
withCursorOffDo:aBlock |
2077 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2078 |
||
2079 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
3160 | 2080 |
^ aBlock value |
121 | 2081 |
]. |
2082 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2083 |
aBlock ensure:[ |
3160 | 2084 |
self showCursor |
121 | 2085 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2086 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
|
2589 | 2088 |
!EditTextView methodsFor:'drag & drop'! |
2089 |
||
2090 |
allowDrop:aBoolean |
|
3236 | 2091 |
"enable/disable drop support" |
2092 |
||
2589 | 2093 |
aBoolean ifFalse:[ |
3236 | 2094 |
dropTarget := nil. |
2589 | 2095 |
] ifTrue:[ |
3236 | 2096 |
dropTarget ifNil:[ |
2097 |
dropTarget := DropTarget receiver:self |
|
2098 |
argument:nil |
|
2099 |
dropSelector:#'drop:' |
|
2100 |
canDropSelector:#'canDrop:' |
|
2101 |
] |
|
2102 |
]. |
|
2103 |
! |
|
2104 |
||
2105 |
canDrop:aDropContextOrCollectionOfDropObjects |
|
2106 |
"I accept textObjects and fileObjects only. |
|
2107 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2108 |
||
2589 | 2109 |
|objects| |
2110 |
||
2111 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2112 |
||
3236 | 2113 |
aDropContextOrCollectionOfDropObjects isCollection ifTrue:[ |
2114 |
objects := aDropContextOrCollectionOfDropObjects. |
|
2115 |
] ifFalse:[ |
|
2116 |
aDropContextOrCollectionOfDropObjects sourceWidget == self ifTrue:[^ false]. |
|
2117 |
||
2118 |
objects := aDropContextOrCollectionOfDropObjects dropObjects. |
|
2119 |
]. |
|
2120 |
||
2589 | 2121 |
objects isEmpty ifTrue:[ ^ false ]. |
2122 |
||
2123 |
objects do:[:el| |
|
3236 | 2124 |
(el isTextObject or:[el isFileObject]) ifFalse:[^ false]. |
2589 | 2125 |
]. |
2126 |
^ true |
|
2127 |
! |
|
2128 |
||
3236 | 2129 |
drop:aDropContextOrCollectionOfDropObjects at:aPoint |
2589 | 2130 |
"drop objects |
3236 | 2131 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2132 |
||
2133 |
|text objects| |
|
2134 |
||
2135 |
(self canDrop:aDropContextOrCollectionOfDropObjects) ifFalse:[^ self]. |
|
2136 |
||
2137 |
aDropContextOrCollectionOfDropObjects isCollection ifTrue:[ |
|
2138 |
objects := aDropContextOrCollectionOfDropObjects. |
|
2139 |
] ifFalse:[ |
|
2140 |
objects := aDropContextOrCollectionOfDropObjects dropObjects. |
|
2141 |
]. |
|
2589 | 2142 |
|
2143 |
text := StringCollection new. |
|
2144 |
||
3236 | 2145 |
objects do:[:el| |
2146 |
|obj| |
|
2147 |
||
2148 |
obj := el theObject. |
|
2149 |
el isTextObject ifTrue:[ text addAll:obj ] |
|
2150 |
ifFalse:[ text add:(obj asString) ] |
|
2589 | 2151 |
]. |
2152 |
self pasteOrReplace:text. |
|
2153 |
! ! |
|
2154 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2155 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2156 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2157 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2158 |
"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
|
2159 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2160 |
selectionStartLine notNil ifTrue:[ |
3160 | 2161 |
self setClipboardText:(self selection). |
2162 |
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
|
2163 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2164 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2165 |
"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
|
2166 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2167 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2168 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2169 |
"delete single character under cursor; does not merge lines" |
121 | 2170 |
|
2171 |
|wasOn| |
|
2172 |
||
2173 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2174 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2175 |
wasOn ifTrue:[self showCursor] |
2176 |
! |
|
2177 |
||
827 | 2178 |
deleteCharAtLine:lineNr col:colNr |
2179 |
"delete a single character at colNr in line lineNr" |
|
2180 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2181 |
self st80EditMode ifTrue:[ |
3160 | 2182 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2183 |
| wasOn | |
|
2184 |
wasOn := self hideCursor. |
|
2185 |
self |
|
2186 |
cursorReturn; |
|
2187 |
cursorCol:1; |
|
2188 |
deleteCharBeforeCursor. |
|
2189 |
wasOn ifTrue:[ self showCursor]. |
|
2190 |
^ self. |
|
2191 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2192 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2193 |
|
827 | 2194 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2195 |
! |
|
2196 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2197 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
"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
|
2199 |
|
2491 | 2200 |
|soCol wasOn lineNrAboveCursor ln prevTab| |
121 | 2201 |
|
2202 |
wasOn := self hideCursor. |
|
2491 | 2203 |
autoIndent ifTrue:[ |
3160 | 2204 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
2205 |
ln := (list at:cursorLine) ? ''. |
|
2206 |
ln size < prevTab ifTrue:[ |
|
2207 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2208 |
]. |
|
2209 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2210 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2211 |
cursorCol > prevTab ifTrue:[ |
|
2212 |
self cursorLine:cursorLine col:prevTab. |
|
2213 |
wasOn ifTrue:[ self showCursor ]. |
|
2214 |
^ self |
|
2215 |
]. |
|
2216 |
] ifFalse:[ |
|
2217 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2218 |
self cursorLine:cursorLine col:prevTab. |
|
2219 |
wasOn ifTrue:[ self showCursor ]. |
|
2220 |
^ self. |
|
2221 |
] |
|
2222 |
]. |
|
827 | 2223 |
]. |
2224 |
||
2491 | 2225 |
"/ (autoIndent |
2226 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2227 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2228 |
"/ ifTrue:[ |
2229 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2230 |
"/ |
|
2231 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2232 |
"/ ln := list at:cursorLine. |
|
2233 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2234 |
"/ soCol := 1 |
|
2235 |
"/ ] |
|
2236 |
"/ ] |
|
2237 |
"/ ] ifFalse:[ |
|
3160 | 2238 |
soCol := 1. |
2491 | 2239 |
"/ ]. |
2240 |
||
1419 | 2241 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
3160 | 2242 |
" |
2243 |
somewhere in the middle of a line |
|
2244 |
" |
|
2245 |
self cursorLeft. |
|
2246 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2247 |
] ifFalse:[ |
3160 | 2248 |
" |
2249 |
at begin of line - merge with previous line; |
|
2250 |
except for the very first line. |
|
2251 |
" |
|
2252 |
(cursorLine == 1) ifFalse:[ |
|
2253 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2254 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2255 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2256 |
"/ we are beyond the end of the text. |
|
2257 |
"/ move the cursor to the previous line. |
|
2258 |
self cursorLine:lineNrAboveCursor col:1. |
|
2259 |
] ifFalse:[ |
|
2260 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2261 |
] |
|
2262 |
] |
|
2263 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2264 |
]. |
827 | 2265 |
wasOn ifTrue:[ self showCursor ] |
2266 |
||
1419 | 2267 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2268 |
! |
2269 |
||
2270 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2271 |
"delete characters from colNr up to the end in line lineNr" |
|
2272 |
||
2273 |
|line| |
|
2274 |
||
2275 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
3160 | 2276 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2277 |
] |
2278 |
||
2279 |
! |
|
2280 |
||
2281 |
deleteCharsAtLine:lineNr toCol:colNr |
|
2282 |
"delete characters from start up to colNr in line lineNr" |
|
2283 |
||
2284 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2285 |
||
2286 |
||
121 | 2287 |
! |
2288 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2289 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
self deleteLine:cursorLine |
121 | 2293 |
! |
2294 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2295 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2296 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2297 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2298 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2299 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2300 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2301 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2302 |
col1 == 0 ifTrue:[ |
3160 | 2303 |
line1 := line1 - 1. |
2304 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2305 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2306 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2307 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2308 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2309 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2310 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2311 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2312 |
|
2954 | 2313 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2314 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2315 |
joining lines if nescessary" |
|
2316 |
||
2317 |
|line newLine lineSize nMore| |
|
2318 |
||
2319 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2320 |
list isNil ifTrue:[^ self]. |
|
2321 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2322 |
||
2323 |
(startLine == endLine) ifTrue:[ |
|
3160 | 2324 |
"/ delete chars within a line |
2325 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2326 |
^ self |
|
2954 | 2327 |
]. |
2328 |
||
2329 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
3160 | 2330 |
"/ delete full lines only |
2331 |
endLine > startLine ifTrue:[ |
|
2332 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2333 |
]. |
|
2334 |
^ self |
|
2954 | 2335 |
]. |
2336 |
||
2337 |
"/ delete right rest of 1st line |
|
2338 |
self deleteCharsAtLine:startLine fromCol:startCol. |
|
2339 |
||
2340 |
"/ delete the inner lines ... |
|
2341 |
endLine > (startLine + 1) ifTrue:[ |
|
3160 | 2342 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 2343 |
]. |
2344 |
||
2345 |
(endCol ~~ 0) ifTrue:[ |
|
3160 | 2346 |
"/ delete the left rest of the last line |
2347 |
||
2348 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2349 |
||
2350 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2351 |
||
2352 |
line := list at:startLine. |
|
2353 |
lineSize := line size. |
|
2354 |
(startCol > lineSize) ifTrue:[ |
|
2355 |
newLine := line. |
|
2356 |
line isNil ifTrue:[ |
|
2357 |
newLine := String new:(startCol - 1) |
|
2358 |
] ifFalse:[ |
|
2359 |
nMore := startCol - 1 - lineSize. |
|
2360 |
nMore > 0 ifTrue:[ |
|
2361 |
newLine := line , (line species new:nMore) |
|
2362 |
] |
|
2363 |
]. |
|
2364 |
newLine ~~ line ifTrue:[ |
|
2365 |
list at:startLine put:newLine. |
|
2366 |
]. |
|
2367 |
"/ TODO: remember old maxwidth of linerange, |
|
2368 |
"/ only clear widthOfWidestLine, if this max |
|
2369 |
"/ length was (one of) the longest. |
|
2370 |
"/ avoids slow delete with huge texts. |
|
2371 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2372 |
self textChanged. |
|
2373 |
] |
|
2954 | 2374 |
]. |
2375 |
||
2376 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
2377 |
self mergeLine:startLine removeBlanks:false |
|
2378 |
||
2379 |
"Modified: / 10.11.1998 / 23:52:59 / cg" |
|
2380 |
! |
|
2381 |
||
827 | 2382 |
deleteLine:lineNr |
2383 |
"delete line" |
|
2384 |
||
2385 |
self deleteFromLine:lineNr toLine:lineNr |
|
2386 |
||
2387 |
||
2388 |
! |
|
2389 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2390 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2391 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2392 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2393 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2396 |
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
|
2397 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
(endLine > list size) ifTrue:[ |
3160 | 2400 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2401 |
] ifFalse:[ |
3160 | 2402 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2403 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2404 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2405 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2406 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2407 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2408 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2409 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2410 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2411 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2412 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2413 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2414 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2415 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2416 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2417 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2419 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2420 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2421 |
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
|
2422 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2423 |
selectionStartLine notNil ifTrue:[ |
3160 | 2424 |
wasOn := self hideCursor. |
2425 |
||
2426 |
startLine := selectionStartLine. |
|
2427 |
startCol := selectionStartCol. |
|
2428 |
endLine := selectionEndLine. |
|
2429 |
endCol := selectionEndCol. |
|
2430 |
self unselectWithoutRedraw. |
|
2431 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
2432 |
self setCursorLine:startLine col:startCol. |
|
2433 |
||
2434 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2435 |
] |
121 | 2436 |
! |
2437 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2438 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2439 |
"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
|
2440 |
|
2952 | 2441 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2442 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2443 |
wasOn := self hideCursor. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2444 |
endCol := cursorCol-1. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2445 |
endLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2446 |
self cursorToPreviousWord. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2447 |
beginCol := cursorCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2448 |
beginLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2449 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2450 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2451 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2452 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2453 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2454 |
|
121 | 2455 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2456 |
"insert a single character at cursor-position - advance cursor." |
121 | 2457 |
|
2458 |
|wasOn| |
|
2459 |
||
2460 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2461 |
aCharacter == Character tab ifTrue:[ |
3160 | 2462 |
"/ needs special care to advance cursor correctly |
2463 |
self insertTabAtCursor |
|
121 | 2464 |
] ifFalse:[ |
3160 | 2465 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
2466 |
aCharacter == (Character cr) ifTrue:[ |
|
2467 |
self cursorReturn |
|
2468 |
] ifFalse:[ |
|
2469 |
self cursorRight. |
|
2470 |
]. |
|
121 | 2471 |
]. |
2472 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2473 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2474 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 2475 |
! |
2476 |
||
641 | 2477 |
insertLine:aString before:lineNr |
2478 |
"insert the line aString before line lineNr" |
|
2479 |
||
2480 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
2481 |
||
2482 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
2483 |
! |
|
2484 |
||
155 | 2485 |
insertLines:aStringCollection before:lineNr |
2486 |
"insert a bunch before line lineNr" |
|
2487 |
||
2488 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
2489 |
||
2490 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
2491 |
! |
|
2492 |
||
654 | 2493 |
insertLines:lines withCR:withCr |
3160 | 2494 |
"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
|
2495 |
Cursor is moved behind insertion. |
641 | 2496 |
If withCr is true, append cr after last line" |
2497 |
||
2498 |
|start end nLines wasOn| |
|
2499 |
||
2500 |
lines notNil ifTrue:[ |
|
3160 | 2501 |
nLines := lines size. |
2502 |
(nLines == 1) ifTrue:[ |
|
2503 |
self insertStringAtCursor:(lines at:1). |
|
2504 |
withCr ifTrue:[ |
|
2505 |
self insertCharAtCursor:(Character cr) |
|
2506 |
] |
|
2507 |
] ifFalse:[ |
|
2508 |
(cursorCol ~~ 1) ifTrue:[ |
|
2509 |
self insertStringAtCursor:(lines at:1). |
|
2510 |
self insertCharAtCursor:(Character cr). |
|
2511 |
start := 2 |
|
2512 |
] ifFalse:[ |
|
2513 |
start := 1 |
|
2514 |
]. |
|
2515 |
withCr ifTrue:[ |
|
2516 |
end := nLines |
|
2517 |
] ifFalse:[ |
|
2518 |
end := nLines - 1 |
|
2519 |
]. |
|
2520 |
(start < nLines) ifTrue:[ |
|
2521 |
(end >= start) ifTrue:[ |
|
2522 |
wasOn := self hideCursor. |
|
2523 |
self insertLines:lines from:start to:end before:cursorLine. |
|
2524 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
2525 |
wasOn ifTrue:[self showCursor]. |
|
2526 |
] |
|
2527 |
]. |
|
2528 |
withCr ifFalse:[ |
|
2529 |
"last line without cr" |
|
2530 |
self insertStringAtCursor:(lines at:nLines) |
|
2531 |
] |
|
2532 |
] |
|
641 | 2533 |
] |
654 | 2534 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2535 |
"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
|
2536 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 2537 |
! |
2538 |
||
2539 |
insertLines:lines withCr:withCr |
|
2540 |
"insert a bunch of lines at cursor position. Cursor |
|
2541 |
is moved behind insertion. |
|
2542 |
If withCr is true, append cr after last line" |
|
2543 |
||
2363 | 2544 |
<resource:#obsolete> |
2545 |
||
1292 | 2546 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
2547 |
self insertLines:lines withCR:withCr. |
|
2548 |
||
2549 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 2550 |
! |
2551 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2552 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2553 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2554 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2555 |
|startLine startCol| |
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 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2558 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2559 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2560 |
self selectFromLine:startLine col:startCol |
3160 | 2561 |
toLine:cursorLine col:(cursorCol - 1) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2562 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2563 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2564 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2565 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2566 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2567 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2568 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2569 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2570 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2571 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2572 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2573 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2574 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2575 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2576 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2578 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2579 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2580 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2581 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2582 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2583 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2584 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2585 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2586 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 2587 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2588 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2589 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2590 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2591 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2592 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2593 |
[start <= end] whileTrue:[ |
3160 | 2594 |
stop := aString indexOf:(Character cr) startingAt:start. |
2595 |
stop == 0 ifTrue:[ |
|
2596 |
stop := end + 1 |
|
2597 |
]. |
|
2598 |
subString := aString copyFrom:start to:(stop - 1). |
|
2599 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
2600 |
(stop <= end) ifTrue:[ |
|
2601 |
c := c + subString size. |
|
2602 |
self insert:(Character cr) atLine:l col:c. |
|
2603 |
l := l + 1. |
|
2604 |
c := 1 |
|
2605 |
]. |
|
2606 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2607 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2608 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2609 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 2610 |
! |
2611 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2612 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2613 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2614 |
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
|
2615 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2616 |
aString isNil ifTrue:[ |
3160 | 2617 |
"new:" |
2618 |
self insertCharAtCursor:(Character cr). |
|
2619 |
^ self |
|
105 | 2620 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2621 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2622 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 2623 |
]. |
2624 |
||
654 | 2625 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2626 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2627 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 2628 |
! |
2629 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2630 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2631 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2632 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2633 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2634 |
shown ifTrue:[self redrawLine:lineNr from:colNr] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2635 |
|
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2636 |
"Modified: / 5.4.1998 / 16:51:14 / cg" |
105 | 2637 |
! |
2638 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2639 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2640 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2641 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2643 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2644 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2645 |
aString size > 0 ifTrue:[ |
3160 | 2646 |
wasOn := self hideCursor. |
2647 |
(aString includes:Character tab) ifTrue:[ |
|
2648 |
self checkForExistingLine:cursorLine. |
|
2649 |
oldLen := (list at:cursorLine) size. |
|
2650 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
2651 |
newLen := (list at:cursorLine) size. |
|
2652 |
deltaLen := newLen - oldLen. |
|
2653 |
] ifFalse:[ |
|
2654 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
2655 |
deltaLen := aString size. |
|
2656 |
]. |
|
2657 |
self setCursorCol:(cursorCol + deltaLen). |
|
2658 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2659 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2660 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2661 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2662 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2663 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2664 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2665 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2666 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2667 |
|wasOn nextTab| |
105 | 2668 |
|
121 | 2669 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2670 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2671 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2672 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 2673 |
! |
2674 |
||
2952 | 2675 |
mergeLine:lineNr |
2676 |
"merge line lineNr with line lineNr+1" |
|
2677 |
||
2678 |
self mergeLine:lineNr removeBlanks:true |
|
2679 |
||
2680 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
2681 |
! |
|
2682 |
||
2506 | 2683 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2684 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2685 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2686 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2687 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2688 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2689 |
|
2506 | 2690 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
3160 | 2691 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
2692 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
2693 |
newSelectionEnd := newSelectionEnd-1. |
|
2694 |
]. |
|
2695 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
2696 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2697 |
newSelectionEnd := newSelectionEnd-1. |
|
2698 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2699 |
] ifFalse:[ |
3160 | 2700 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
2701 |
newSelectionEnd := newSelectionEnd+1. |
|
2702 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
2703 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2704 |
newSelectionEnd := newSelectionEnd+1. |
|
2705 |
] |
|
2706 |
]. |
|
2707 |
self |
|
2708 |
selectFromLine:selectionStartLine col:selectionStartCol |
|
2709 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2710 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2711 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2712 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2713 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2714 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2715 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2716 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2717 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2718 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2719 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2720 |
[finished] whileFalse:[ |
3160 | 2721 |
(lastLine <= 1) ifTrue:[ |
2722 |
finished := true |
|
2723 |
] ifFalse:[ |
|
2724 |
line := list at:lastLine. |
|
2725 |
line notNil ifTrue:[ |
|
2726 |
line isBlank ifTrue:[ |
|
2727 |
list at:lastLine put:nil. |
|
2728 |
line := nil |
|
2729 |
] |
|
2730 |
]. |
|
2731 |
line notNil ifTrue:[ |
|
2732 |
finished := true |
|
2733 |
] ifFalse:[ |
|
2734 |
lastLine := lastLine - 1 |
|
2735 |
] |
|
2736 |
] |
|
118 | 2737 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2738 |
(lastLine ~~ list size) ifTrue:[ |
3160 | 2739 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2740 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2741 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2742 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2743 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2744 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2745 |
"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
|
2746 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2747 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2748 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2749 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2750 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 2751 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2752 |
] ifFalse:[ |
3160 | 2753 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
2754 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2755 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2756 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2757 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2758 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2759 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2760 |
|
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2761 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2762 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2763 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2764 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2765 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2766 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
2767 |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2768 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2769 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2770 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2771 |
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
|
2772 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2773 |
|
1809 | 2774 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2775 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2776 |
lines notNil ifTrue:[ |
3160 | 2777 |
wasOn := self hideCursor. |
2778 |
nLines := lines size. |
|
2779 |
line := cursorLine. |
|
2780 |
col := cursorCol. |
|
2781 |
lines keysAndValuesDo:[:i :l | |
|
2782 |
self replaceString:l atLine:line col:col. |
|
2783 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
2784 |
line := line + 1. |
|
2785 |
col := 1. |
|
2786 |
] ifFalse:[ |
|
2787 |
col := col + (l size). |
|
2788 |
] |
|
2789 |
]. |
|
2790 |
self cursorLine:line col:col. |
|
2791 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2792 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2793 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2794 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2795 |
"Created: / 18.5.1996 / 15:32:06 / cg" |
1567
0eff7ca88e89
much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents:
1566
diff
changeset
|
2796 |
"Modified: / 12.6.1998 / 22:05:51 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2797 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2798 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2799 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2800 |
"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
|
2801 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2802 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2803 |
self replaceSelectionBy:something keepCursor:false |
105 | 2804 |
! |
2805 |
||
2806 |
replaceSelectionBy:something keepCursor:keep |
|
2807 |
"delete the selection (if any) and insert something, a character or string; |
|
2808 |
leave cursor after insertion or leave it, depending on keep" |
|
2809 |
||
2810 |
|sel l c| |
|
2811 |
||
2812 |
l := cursorLine. |
|
2813 |
c := cursorCol. |
|
2814 |
||
2815 |
sel := self selection. |
|
2816 |
sel notNil ifTrue:[ |
|
3161 | 2817 |
lastString := sel. |
2818 |
self deleteSelection. |
|
2819 |
replacing := true. |
|
2820 |
lastReplacement := ''. |
|
2821 |
undoSupport actionInfo:'replace'. |
|
2822 |
]. |
|
2823 |
||
2824 |
something isCharacter ifTrue:[ |
|
2825 |
lastReplacement notNil ifTrue:[ |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2826 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2827 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2828 |
"/ lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2829 |
"/ lastReplacement := lastReplacement copyWith:something. |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2830 |
"/ lastReplacement := lastReplacement copyWith:Character space |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2831 |
"/ ] ifFalse:[ |
3161 | 2832 |
lastReplacement := lastReplacement copyWith:something. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2833 |
"/ ] |
3161 | 2834 |
]. |
3235 | 2835 |
self isInInsertMode ifTrue:[ |
3161 | 2836 |
self insertCharAtCursor:something |
2837 |
] ifFalse:[ |
|
2838 |
self replaceCharAtCursor:something |
|
2839 |
] |
|
105 | 2840 |
] ifFalse:[ |
3161 | 2841 |
something isString ifTrue:[ |
2842 |
lastReplacement := something. |
|
3235 | 2843 |
self isInInsertMode ifTrue:[ |
3161 | 2844 |
self insertStringAtCursor:something |
2845 |
] ifFalse:[ |
|
2846 |
self replaceStringAtCursor:something |
|
2847 |
] |
|
2848 |
] ifFalse:[ |
|
2849 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
2850 |
]. |
|
105 | 2851 |
]. |
2852 |
keep ifTrue:[ |
|
3161 | 2853 |
self cursorLine:l col:c |
105 | 2854 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
2855 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
2856 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2857 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2858 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2859 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2860 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2861 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2862 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2863 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2864 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2865 |
(aString includes:Character tab) ifTrue:[ |
3160 | 2866 |
"/ need special care for TAB (to move cursor correctly) |
2867 |
i1 := 1. |
|
2868 |
[i1 ~~ 0] whileTrue:[ |
|
2869 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
2870 |
i2 ~~ 0 ifTrue:[ |
|
2871 |
i1 ~~ i2 ifTrue:[ |
|
2872 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
2873 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
2874 |
]. |
|
2875 |
self replaceTABAtCursor. |
|
2876 |
i2 := i2 + 1. |
|
2877 |
] ifFalse:[ |
|
2878 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
2879 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
2880 |
]. |
|
2881 |
i1 := i2. |
|
2882 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2883 |
] ifFalse:[ |
3160 | 2884 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
2885 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2886 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2887 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2888 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
2889 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2890 |
"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
|
2891 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2892 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2893 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2894 |
"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
|
2895 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2896 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2897 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2898 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2899 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2900 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2901 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2902 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2903 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2904 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2905 |
|
2752 | 2906 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2907 |
|
2952 | 2908 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
827 | 2909 |
"delete characters from startCol to endCol in line lineNr |
2910 |
" |
|
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
2911 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2912 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2913 |
line := self listAt:lineNr. |
827 | 2914 |
|
3160 | 2915 |
(self checkModificationsAllowed and:[line notNil]) ifTrue:[ |
2916 |
lineSize := line size. |
|
2917 |
||
2918 |
startCol == 0 ifFalse:[ start := startCol ] |
|
2919 |
ifTrue:[ start := 1 ]. |
|
2920 |
||
2921 |
endCol > lineSize ifFalse:[ stop := endCol ] |
|
2922 |
ifTrue:[ stop := lineSize ]. |
|
2923 |
||
2924 |
stop >= start ifTrue:[ |
|
2925 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
2926 |
ifFalse:[ newLine := '' ]. |
|
2927 |
||
2928 |
stop == lineSize ifFalse:[ |
|
2929 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
2930 |
newLine := line string species fromString:newLine. |
|
2931 |
]. |
|
2932 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
2933 |
]. |
|
2934 |
||
2935 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
2936 |
newLine := nil |
|
2937 |
]. |
|
2938 |
||
2939 |
prevWidth := self widthOfLine:lineNr. |
|
2940 |
||
2941 |
list at:lineNr put:newLine. |
|
2942 |
||
2943 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
2944 |
"/ remember old width of this line, |
|
2945 |
"/ only clear widthOfWidestLine, if this lines |
|
2946 |
"/ length was (one of) the longest. |
|
2947 |
"/ avoids slow delete with huge texts. |
|
2948 |
widthOfWidestLine := nil. "i.e. unknown" |
|
2949 |
||
2950 |
"/ scroll left if reqiured |
|
2951 |
viewOrigin x > 0 ifTrue:[ |
|
2952 |
newWidth := self widthOfLine:lineNr. |
|
2953 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
2954 |
self scrollHorizontalTo:(newWidth |
|
2955 |
- width |
|
2956 |
+ margin + margin |
|
2957 |
+ (font widthOf:' ')) |
|
2958 |
] |
|
2959 |
]. |
|
2960 |
self textChanged. |
|
2961 |
] ifFalse:[ |
|
2962 |
self textChanged "/ textChangedButNoSizeChange |
|
2963 |
]. |
|
2964 |
self redrawLine:lineNr from:start. |
|
2965 |
||
2966 |
] |
|
827 | 2967 |
] |
2968 |
||
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2969 |
"Modified: / 11.11.1998 / 00:01:09 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2970 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2971 |
|
2952 | 2972 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2973 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2974 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2975 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2976 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2977 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2978 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2979 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2980 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2981 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2982 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2983 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2984 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2985 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2986 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2987 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2988 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2989 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2990 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2991 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2992 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2993 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2994 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2995 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2996 |
(firstLineShown >= nLines) ifTrue:[ |
3160 | 2997 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2998 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2999 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3000 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3001 |
"Modified: / 10.11.1998 / 23:55:05 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3002 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3003 |
|
2952 | 3004 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3005 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3006 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3007 |
|
2952 | 3008 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3009 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3010 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3011 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3012 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3013 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3014 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3015 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3016 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3017 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3018 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3019 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3020 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3021 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3022 |
|
2952 | 3023 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 3024 |
"insert a single character at lineNr/colNr; |
827 | 3025 |
set emphasis to character at current position" |
3026 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
3027 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3028 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3029 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3030 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3031 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3032 |
self splitLine:lineNr before:colNr. |
3033 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3034 |
]. |
827 | 3035 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3036 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3037 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3038 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3039 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3040 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3041 |
self st80EditMode ifFalse:[ |
3160 | 3042 |
(trimBlankLines |
3043 |
and:[colNr > lineSize |
|
3044 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
3045 |
^ self |
|
3046 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3047 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3048 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3049 |
(lineSize == 0) ifTrue:[ |
3160 | 3050 |
newLine := aCharacter asString species new:colNr. |
3051 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3052 |
] ifFalse: [ |
3160 | 3053 |
(colNr > lineSize) ifTrue: [ |
3054 |
colNr == (lineSize +1) ifTrue:[ |
|
3055 |
attribute := line emphasisAt:lineSize |
|
3056 |
]. |
|
3057 |
newLine := line species new:colNr. |
|
3058 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3059 |
drawCharacterOnly := true |
|
3060 |
] ifFalse: [ |
|
3061 |
attribute := line emphasisAt:colNr. |
|
3062 |
newLine := line species new:(lineSize + 1). |
|
3063 |
||
3064 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
3065 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
3066 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3067 |
]. |
827 | 3068 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3069 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
3160 | 3070 |
newLine := aCharacter asString species fromString:newLine. |
3071 |
line isText ifTrue:[ |
|
3072 |
newLine := newLine asText |
|
3073 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3074 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3075 |
newLine at:colNr put:aCharacter. |
827 | 3076 |
|
3077 |
attribute notNil ifTrue:[ |
|
3160 | 3078 |
newLine emphasisAt:colNr put:attribute |
827 | 3079 |
]. |
3080 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3081 |
aCharacter == (Character tab) ifTrue:[ |
3160 | 3082 |
newLine := self withTabsExpanded:newLine. |
3083 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3084 |
]. |
827 | 3085 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3086 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3087 |
widthOfWidestLine notNil ifTrue:[ |
3160 | 3088 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3089 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3090 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3091 |
shown ifTrue:[ |
3160 | 3092 |
"/ care for italic text - in this case, we must also |
3093 |
"/ redraw the character before the insertion in order |
|
3094 |
"/ to fix the slanted piece of the character. |
|
3095 |
"/ (but we must clip, to avoid destoying the character before) |
|
3096 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
3097 |
colNr > 1 ifTrue:[ |
|
3098 |
cursorVisibleLine notNil ifTrue:[ |
|
3099 |
oldClip := self clippingRectangleOrNil. |
|
3100 |
x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
3101 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
3102 |
drawCharacterOnly ifTrue:[ |
|
3103 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
3104 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
3105 |
] ifFalse:[ |
|
3106 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
3107 |
self redrawLine:lineNr from:colNr-1 |
|
3108 |
]. |
|
3109 |
self clippingRectangle:oldClip. |
|
3110 |
]. |
|
3111 |
^ self. |
|
3112 |
]. |
|
3113 |
]. |
|
3114 |
drawCharacterOnly ifTrue:[ |
|
3115 |
self redrawLine:lineNr col:colNr |
|
3116 |
] ifFalse:[ |
|
3117 |
self redrawLine:lineNr from:colNr |
|
3118 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3119 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3120 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
3121 |
"Modified: / 20.6.1998 / 18:19:22 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3122 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3123 |
|
2952 | 3124 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 3125 |
"merge line lineNr with line lineNr+1" |
3126 |
||
827 | 3127 |
|leftPart rightPart bothParts nextLineNr i| |
3128 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3129 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
3160 | 3130 |
"/ empty list or beyond end of text |
3131 |
^ self |
|
827 | 3132 |
]. |
3133 |
leftPart := self listAt:lineNr. |
|
3134 |
||
3135 |
leftPart isNil ifTrue:[ |
|
3160 | 3136 |
leftPart := ''. |
3137 |
autoIndent ifTrue:[ |
|
3138 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
3139 |
leftPart := String new:i |
|
3140 |
] |
|
3141 |
] |
|
827 | 3142 |
]. |
3143 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
3144 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
3145 |
||
3146 |
nextLineNr > (list size) ifFalse:[ |
|
3160 | 3147 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
3148 |
rightPart := '' |
|
3149 |
] ifFalse:[ |
|
3150 |
removeBlanks ifTrue:[ |
|
3151 |
rightPart := rightPart withoutLeadingSeparators. |
|
3152 |
] |
|
3153 |
]. |
|
3154 |
||
3155 |
bothParts := leftPart , rightPart. |
|
3156 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
3157 |
list at:lineNr put:bothParts. |
|
3158 |
self redrawLine:lineNr. |
|
3159 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3160 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3161 |
|
1319 | 3162 |
"Created: 9.9.1997 / 09:27:38 / cg" |
3163 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3164 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3165 |
|
2952 | 3166 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3167 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3168 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3169 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3170 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3171 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3172 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3173 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3174 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3175 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3176 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3177 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3178 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3179 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3180 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3181 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3182 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3183 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3184 |
and:[aCharacter == Character space]]) ifTrue:[ |
3160 | 3185 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3186 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3187 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3188 |
(lineSize == 0) ifTrue:[ |
3160 | 3189 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3190 |
] ifFalse: [ |
3160 | 3191 |
(colNr > lineSize) ifTrue: [ |
3192 |
newLine := line species new:colNr. |
|
3193 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3194 |
] ifFalse: [ |
|
3195 |
newLine := line copy. |
|
3196 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3197 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3198 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3199 |
aCharacter == (Character tab) ifTrue:[ |
3160 | 3200 |
newLine := self withTabsExpanded:newLine. |
3201 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3202 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3203 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3204 |
widthOfWidestLine notNil ifTrue:[ |
3160 | 3205 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3206 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3207 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3208 |
shown ifTrue:[ |
3160 | 3209 |
drawCharacterOnly ifTrue:[ |
3210 |
self redrawLine:lineNr col:colNr |
|
3211 |
] ifFalse:[ |
|
3212 |
self redrawLine:lineNr from:colNr |
|
3213 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3214 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3215 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3216 |
"Created: / 6.3.1996 / 12:29:20 / cg" |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3217 |
"Modified: / 10.6.1998 / 18:50:18 / cg" |
105 | 3218 |
! |
3219 |
||
3235 | 3220 |
basicReplaceString:aString atLine:lineNr col:colNr |
3221 |
"replace multiple characters starting at lineNr/colNr. |
|
3222 |
This is not prepared to encounter special chars (except TAB) |
|
3223 |
in the string." |
|
3224 |
||
3225 |
|line lineSize newLine endCol| |
|
3226 |
||
3227 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3228 |
||
3229 |
self checkForExistingLine:lineNr. |
|
3230 |
line := list at:lineNr. |
|
3231 |
lineSize := line size. |
|
3232 |
||
3233 |
endCol := colNr + aString size - 1. |
|
3234 |
(lineSize == 0) ifTrue:[ |
|
3235 |
newLine := aString species new:endCol. |
|
3236 |
] ifFalse: [ |
|
3237 |
(endCol > lineSize) ifTrue: [ |
|
3238 |
aString isText ifTrue:[ |
|
3239 |
newLine := aString species new:endCol. |
|
3240 |
] ifFalse:[ |
|
3241 |
newLine := line species new:endCol. |
|
3242 |
]. |
|
3243 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3244 |
] ifFalse: [ |
|
3245 |
aString isText ifTrue:[ |
|
3246 |
newLine := aString species new:line size. |
|
3247 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3248 |
] ifFalse:[ |
|
3249 |
newLine := line copy. |
|
3250 |
] |
|
3251 |
] |
|
3252 |
]. |
|
3253 |
newLine replaceFrom:colNr with:aString. |
|
3254 |
(aString includes:(Character tab)) ifTrue:[ |
|
3255 |
newLine := self withTabsExpanded:newLine. |
|
3256 |
]. |
|
3257 |
list at:lineNr put:newLine. |
|
3258 |
widthOfWidestLine notNil ifTrue:[ |
|
3259 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3260 |
]. |
|
3261 |
self textChanged. |
|
3262 |
shown ifTrue:[ |
|
3263 |
self redrawLine:lineNr from:colNr |
|
3264 |
] |
|
3265 |
||
3266 |
"Created: / 11.6.1998 / 10:38:32 / cg" |
|
3267 |
"Modified: / 20.6.1998 / 20:23:50 / cg" |
|
3268 |
! |
|
3269 |
||
2952 | 3270 |
basicSplitLine:lineNr before:colNr |
3271 |
"split the line linNr before colNr; the right part (from colNr) |
|
3272 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3273 |
||
3160 | 3274 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 3275 |
srcY "{ Class: SmallInteger }" | |
3276 |
||
3027 | 3277 |
list isNil ifTrue:[ ^ self ]. |
3278 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
3279 |
||
3280 |
(colNr == 1) ifTrue:[ |
|
3160 | 3281 |
self nonUndoableDo:[ |
3282 |
self insertLine:nil before:lineNr. |
|
3283 |
]. |
|
3284 |
^ self |
|
3027 | 3285 |
]. |
3286 |
||
3287 |
line := list at:lineNr. |
|
3288 |
line isNil ifFalse:[ |
|
3160 | 3289 |
lineSize := line size. |
3290 |
(colNr <= lineSize) ifTrue:[ |
|
3291 |
rightRest := line copyFrom:colNr to:lineSize. |
|
3292 |
(colNr > 1) ifTrue:[ |
|
3293 |
leftRest := line copyTo:(colNr - 1) |
|
3294 |
] |
|
3295 |
] ifFalse:[ |
|
3296 |
leftRest := line |
|
3297 |
] |
|
3027 | 3298 |
]. |
3299 |
leftRest notNil ifTrue:[ |
|
3160 | 3300 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 3301 |
]. |
3302 |
list at:lineNr put:leftRest. |
|
3303 |
self nonUndoableDo:[ |
|
3160 | 3304 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 3305 |
]. |
3306 |
visLine := self listLineToVisibleLine:(lineNr). |
|
3307 |
visLine notNil ifTrue:[ |
|
3160 | 3308 |
w := self widthForScrollBetween:lineNr |
3309 |
and:(firstLineShown + nLinesShown). |
|
3310 |
srcY := topMargin + (visLine * fontHeight). |
|
3311 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
3312 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
3313 |
self catchExpose. |
|
3314 |
self |
|
3315 |
copyFrom:self |
|
3316 |
x:textStartLeft y:srcY |
|
3317 |
toX:textStartLeft y:(srcY + fontHeight) |
|
3318 |
width:w |
|
3319 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
3320 |
async:true. |
|
3321 |
]. |
|
3322 |
self redrawLine:lineNr. |
|
3323 |
self redrawLine:(lineNr + 1). |
|
3324 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 3325 |
]. |
3326 |
widthOfWidestLine := nil. "/ unknown |
|
3327 |
self textChanged. |
|
2952 | 3328 |
|
3329 |
"Modified: 29.1.1997 / 13:03:22 / cg" |
|
3330 |
! |
|
3331 |
||
3332 |
basicWithoutRedrawInsertLine:aString before:lineNr |
|
3333 |
"insert the argument, aString before line lineNr; the string |
|
3334 |
becomes line nileNr; everything else is moved down; the view |
|
3335 |
is not redrawn" |
|
3336 |
||
3337 |
|line| |
|
3338 |
||
3339 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3340 |
||
3341 |
line := aString. |
|
3342 |
line notNil ifTrue:[ |
|
3160 | 3343 |
line isString ifTrue:[ |
3344 |
line isBlank ifTrue:[ |
|
3345 |
line := nil |
|
3346 |
] ifFalse:[ |
|
3347 |
(line includes:(Character tab)) ifTrue:[ |
|
3348 |
line := self withTabsExpanded:line |
|
3349 |
] |
|
3350 |
] |
|
3351 |
] |
|
2952 | 3352 |
]. |
3353 |
list isNil ifTrue: [ |
|
3160 | 3354 |
list := StringCollection new:lineNr |
2952 | 3355 |
] ifFalse: [ |
3160 | 3356 |
list grow:((list size + 1) max:lineNr) |
3357 |
]. |
|
3358 |
||
3359 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2952 | 3360 |
overlapping copy - if it didn't, we had to use:" |
3361 |
" |
|
3362 |
index := list size. |
|
3363 |
[index > lineNr] whileTrue: [ |
|
3160 | 3364 |
pIndex := index - 1. |
3365 |
list at:index put:(list at:pIndex). |
|
3366 |
index := pIndex |
|
2952 | 3367 |
]. |
3368 |
" |
|
3369 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
|
3370 |
list at:lineNr put:line. |
|
3371 |
self contentsChanged |
|
3372 |
||
3373 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
|
3374 |
! |
|
3375 |
||
2954 | 3376 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
3377 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3378 |
||
3379 |
|newLine newLines nLines| |
|
3380 |
||
3381 |
nLines := end - start + 1. |
|
3382 |
newLines := Array new:(lines size). |
|
3383 |
start to:end do:[:index | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3384 |
newLine := lines at:index. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3385 |
newLine notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3386 |
newLine isString ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3387 |
newLine isBlank ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3388 |
newLine := nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3389 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3390 |
(newLine includes:(Character tab)) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3391 |
newLine := self withTabsExpanded:newLine |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3392 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3393 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3394 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3395 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3396 |
newLines at:index put:newLine |
2954 | 3397 |
]. |
3398 |
list isNil ifTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3399 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 3400 |
] ifFalse: [ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3401 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 3402 |
]. |
3403 |
||
3404 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 3405 |
overlapping copy - if it didn't, we had to use:" |
3406 |
" |
|
3407 |
index := list size. |
|
3408 |
[index > lineNr] whileTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3409 |
pIndex := index - 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3410 |
list at:index put:(list at:pIndex). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3411 |
index := pIndex |
2954 | 3412 |
]. |
3413 |
" |
|
3414 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
3415 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
3416 |
self contentsChanged |
|
3417 |
||
3418 |
"Modified: / 10.6.1998 / 19:01:16 / cg" |
|
3419 |
! |
|
3420 |
||
3421 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3422 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3423 |
||
3424 |
|isText strLen line lineSize newLine stringType sz| |
|
3425 |
||
3426 |
(aString notNil) ifFalse:[ ^ self]. |
|
3427 |
||
3428 |
strLen := aString size. |
|
3429 |
self checkForExistingLine:lineNr. |
|
3430 |
||
3431 |
stringType := aString string species. |
|
3432 |
isText := aString isText. |
|
3433 |
line := list at:lineNr. |
|
3434 |
||
3435 |
line notNil ifTrue:[ |
|
3160 | 3436 |
lineSize := line size. |
3437 |
line isString ifFalse:[ |
|
3438 |
stringType := line species |
|
3439 |
] ifTrue:[ |
|
3440 |
line bitsPerCharacter > aString bitsPerCharacter ifTrue:[ |
|
3441 |
stringType := line string species |
|
3442 |
]. |
|
3443 |
line isText ifTrue:[ isText := true ] |
|
3444 |
]. |
|
2954 | 3445 |
] ifFalse:[ |
3160 | 3446 |
lineSize := 0 |
2954 | 3447 |
]. |
3448 |
||
3449 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
3160 | 3450 |
newLine := aString |
2954 | 3451 |
] ifFalse:[ |
3160 | 3452 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
3453 |
sz := colNr + strLen - 1 |
|
3454 |
] ifFalse:[ |
|
3455 |
sz := lineSize + strLen |
|
3456 |
]. |
|
3457 |
||
3458 |
isText ifFalse:[ |
|
3459 |
newLine := stringType new:sz |
|
3460 |
] ifTrue:[ |
|
3461 |
newLine := Text string:(stringType new:sz) |
|
3462 |
]. |
|
3463 |
||
3464 |
(lineSize ~~ 0) ifTrue: [ |
|
3465 |
(colNr > lineSize) ifTrue: [ |
|
3466 |
newLine replaceFrom:1 to:lineSize |
|
3467 |
with:line startingAt:1 |
|
3468 |
] ifFalse: [ |
|
3469 |
newLine replaceFrom:1 to:(colNr - 1) |
|
3470 |
with:line startingAt:1. |
|
3471 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) |
|
3472 |
with:line startingAt:colNr |
|
3473 |
] |
|
3474 |
]. |
|
3475 |
newLine replaceFrom:colNr to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 3476 |
]. |
3477 |
||
3478 |
(aString includes:(Character tab)) ifTrue:[ |
|
3160 | 3479 |
newLine := self withTabsExpanded:newLine |
2954 | 3480 |
]. |
3481 |
||
3482 |
list at:lineNr put:newLine. |
|
3483 |
widthOfWidestLine notNil ifTrue:[ |
|
3160 | 3484 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 3485 |
]. |
3486 |
self textChanged. |
|
3487 |
||
3488 |
"Modified: / 10.6.1998 / 19:01:52 / cg" |
|
3489 |
! |
|
3490 |
||
2952 | 3491 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3492 |
"delete characters from startCol to endCol in line lineNr |
|
3493 |
" |
|
3494 |
|deleted| |
|
3495 |
||
3496 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3497 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3115 | 3498 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
2952 | 3499 |
! |
3500 |
||
3501 |
deleteFromLine:startLineNr toLine:endLineNr |
|
3502 |
"delete some lines" |
|
3503 |
||
3504 |
|deleted| |
|
3505 |
||
3506 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3507 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3115 | 3508 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
2952 | 3509 |
! |
3510 |
||
3511 |
deleteLineWithoutRedraw:lineNr |
|
3512 |
"delete line - no redraw; |
|
3513 |
return true, if something was really deleted" |
|
3514 |
||
3515 |
|deleted ret| |
|
3516 |
||
3517 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3518 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3115 | 3519 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
2952 | 3520 |
^ ret. |
3521 |
! |
|
3522 |
||
3523 |
insert:aCharacter atLine:lineNr col:colNr |
|
3160 | 3524 |
"insert a single character at lineNr/colNr; |
2952 | 3525 |
set emphasis to character at current position" |
3526 |
||
3527 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3528 |
aCharacter ~~ Character cr ifTrue:[ |
|
3160 | 3529 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
2952 | 3530 |
] |
3531 |
! |
|
3532 |
||
3533 |
insertLines:someText from:start to:end before:lineNr |
|
3534 |
"insert a bunch of lines before line lineNr" |
|
3535 |
||
2954 | 3536 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
3537 |
srcY "{ Class: SmallInteger }" |
|
3538 |
dstY "{ Class: SmallInteger }" | |
|
3539 |
||
3540 |
autoIndent ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3541 |
indent := self leftIndentForLine:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3542 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3543 |
text := someText collect:[:ln||line| |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3544 |
ln notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3545 |
line := ln withoutLeadingSeparators. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3546 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3547 |
line := (String new:indent), line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3548 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3549 |
line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3550 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3551 |
nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3552 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3553 |
]. |
2954 | 3554 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3555 |
text := someText |
2954 | 3556 |
]. |
3557 |
||
3558 |
visLine := self listLineToVisibleLine:lineNr. |
|
3559 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3560 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3561 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3562 |
before:lineNr. |
2954 | 3563 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3564 |
nLines := end - start + 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3565 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3566 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3567 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3568 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3569 |
self redrawFromVisibleLine:visLine to:nLinesShown |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3570 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3571 |
w := self widthForScrollBetween:(lineNr + nLines) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3572 |
and:(firstLineShown + nLines + nLinesShown). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3573 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3574 |
dstY := srcY + (nLines * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3575 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3576 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3577 |
"/ scroll ... |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3578 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3579 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3580 |
stupid: must catchExpose before inserting new |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3581 |
stuff - since catchExpose may perform redraws |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3582 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3583 |
self catchExpose. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3584 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3585 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3586 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3587 |
self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3588 |
copyFrom:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3589 |
x:textStartLeft y:srcY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3590 |
toX:textStartLeft y:dstY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3591 |
width:w |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3592 |
height:(height - dstY) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3593 |
async:true. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3594 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3595 |
self waitForExpose |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3596 |
]. |
2954 | 3597 |
]. |
3598 |
widthOfWidestLine notNil ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3599 |
text do:[:line | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3600 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3601 |
] |
2954 | 3602 |
]. |
3603 |
self textChanged. |
|
3604 |
||
3605 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
2952 | 3606 |
! |
3607 |
||
3608 |
mergeLine:lineNr removeBlanks:removeBlanks |
|
3609 |
"merge line lineNr with line lineNr+1" |
|
3610 |
||
3611 |
|len| |
|
3612 |
||
3613 |
len := (self listAt:lineNr) size. |
|
3614 |
self nonUndoableDo:[ |
|
3160 | 3615 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
2952 | 3616 |
]. |
3617 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3618 |
! |
|
3619 |
||
3620 |
replace:aCharacter atLine:lineNr col:colNr |
|
3621 |
"replace a single character at lineNr/colNr" |
|
3622 |
||
3623 |
|originalChar| |
|
3624 |
||
3625 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3626 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3235 | 3627 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
2952 | 3628 |
! |
3629 |
||
3131 | 3630 |
replaceContentsWith:newContents |
3631 |
"replace everything" |
|
3632 |
||
3633 |
|originalContents| |
|
3634 |
||
3635 |
originalContents := self contents. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
3636 |
self contents:newContents keepUndoHistory:true. |
3131 | 3637 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
3638 |
! |
|
3639 |
||
3130 | 3640 |
replaceLine:lineNr with:newText |
3641 |
"replace a line at lineNr" |
|
3642 |
||
3643 |
|originalLine| |
|
3644 |
||
3645 |
originalLine := self listAt:lineNr. |
|
3646 |
self list at:lineNr put:newText. |
|
3647 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3648 |
self invalidateLine:lineNr. |
|
3649 |
! |
|
3650 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3651 |
replaceString:aString atLine:lineNr col:colNr |
1557 | 3652 |
"replace multiple characters starting at lineNr/colNr. |
3235 | 3653 |
This is not prepared to encounter special chars (except TAB) in the string." |
3654 |
||
3655 |
|originalString| |
|
1557 | 3656 |
|
3657 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3658 |
||
3235 | 3659 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
3660 |
||
3661 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3662 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
1557 | 3663 |
! |
3664 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3665 |
splitLine:lineNr before:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3666 |
"split the line linNr before colNr; the right part (from colNr) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3667 |
is cut off and inserted after lineNr; the view is redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3668 |
|
2952 | 3669 |
self basicSplitLine:lineNr before:colNr. |
3115 | 3670 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3671 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3672 |
|
3130 | 3673 |
withoutRedrawAt:lineNr put:aString |
3674 |
"replace a line at lineNr" |
|
3675 |
||
3676 |
|originalLine| |
|
3677 |
||
3678 |
originalLine := self listAt:lineNr. |
|
3679 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3680 |
super withoutRedrawAt:lineNr put:aString. |
|
3681 |
! |
|
3682 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3683 |
withoutRedrawInsertLine:aString before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3684 |
"insert the argument, aString before line lineNr; the string |
2954 | 3685 |
becomes line lineNr; everything else is moved down; the view |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3686 |
is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3687 |
|
2952 | 3688 |
self basicWithoutRedrawInsertLine:aString before:lineNr. |
3115 | 3689 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3690 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3691 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3692 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3693 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3694 |
|
2954 | 3695 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3696 |
self isReadOnly ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3697 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3698 |
]. |
121 | 3699 |
! |
3700 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3701 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3702 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3703 |
|
2954 | 3704 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
3115 | 3705 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3706 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3707 |
|
2752 | 3708 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3709 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3710 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3711 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3712 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3713 |
hasKeyboardFocus := true. |
2589 | 3714 |
dragIsActive := false. |
3715 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3716 |
cursorShown ifTrue: [ |
3160 | 3717 |
self drawCursor |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3718 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3720 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 3721 |
self hideCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3722 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3723 |
(button == #paste) ifTrue:[ |
3160 | 3724 |
self pasteOrReplace. |
3725 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3726 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3727 |
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
|
3728 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
3729 |
"Modified: / 23.3.1999 / 13:51:40 / cg" |
121 | 3730 |
! |
3731 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3732 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3733 |
"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
|
3734 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3735 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 3736 |
typeOfSelection := nil. |
3737 |
||
3738 |
dragIsActive ifTrue:[ |
|
3739 |
self unselect |
|
3740 |
]. |
|
3741 |
selectionStartLine isNil ifTrue:[ |
|
3742 |
clickCol notNil ifTrue:[ |
|
3743 |
self cursorMovementAllowed ifTrue:[ |
|
3744 |
self cursorLine:clickLine col:clickCol |
|
3745 |
] |
|
3746 |
] |
|
3747 |
] ifFalse:[ |
|
3748 |
lastString := nil. "new selection invalidates remembered string" |
|
3749 |
]. |
|
3750 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3751 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3752 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3753 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
3754 |
"Modified: / 18.6.1998 / 14:14:05 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3755 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3756 |
|
2580 | 3757 |
cursorKeyPress:key shifted:shifted |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3758 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
3759 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
3760 |
self changeTypeOfSelectionTo:nil. |
2580 | 3761 |
|
3762 |
(key == #CursorRight) ifTrue:[ |
|
3232 | 3763 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3764 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3765 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
3766 |
expandingTop := false. |
|
3767 |
self validateNewSelection. |
|
3768 |
self redrawLine:selectionStartLine. |
|
3769 |
^ self. |
|
3770 |
]. |
|
3771 |
||
3772 |
selectionStartLine notNil ifTrue:[ |
|
3773 |
self cursorMovementAllowed ifTrue:[ |
|
3774 |
"/ |
|
3775 |
"/ treat the whole selection as cursor |
|
3776 |
"/ |
|
3303 | 3777 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 3778 |
selectionEndCol == 0 ifTrue:[ |
3779 |
selectionEndCol := 1. |
|
3780 |
]. |
|
3781 |
self setCursorCol:selectionEndCol. |
|
3782 |
shifted ifTrue:[ |
|
3783 |
self expandSelectionRight. |
|
3784 |
^ self |
|
3785 |
]. |
|
3786 |
self unselect; makeCursorVisible. |
|
3787 |
cursorCol == 1 ifTrue:[^ self]. |
|
3788 |
]. |
|
3789 |
]. |
|
3790 |
self cursorRight. |
|
3791 |
^ self |
|
2580 | 3792 |
]. |
3793 |
(key == #CursorDown) ifTrue:[ |
|
3232 | 3794 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3795 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
3796 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
3797 |
selectionEndCol == 1 ifTrue:[ |
|
3798 |
selectionEndCol := 0. |
|
3799 |
]. |
|
3800 |
self validateNewSelection. |
|
3801 |
self redrawLine:selectionStartLine. |
|
3802 |
expandingTop := false. |
|
3803 |
self redrawLine:selectionEndLine. |
|
3804 |
^ self |
|
3805 |
]. |
|
3806 |
||
3807 |
selectionStartLine notNil ifTrue:[ |
|
3808 |
self cursorMovementAllowed ifTrue:[ |
|
3809 |
"/ |
|
3810 |
"/ treat the whole selection as cursor |
|
3811 |
"/ |
|
3303 | 3812 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 3813 |
self setCursorCol:selectionStartCol. |
3814 |
cursorCol == 0 ifTrue:[ |
|
3815 |
self setCursorCol:1. |
|
3816 |
self setCursorLine:(cursorLine - 1). |
|
3817 |
]. |
|
3818 |
self makeCursorVisible. |
|
3819 |
||
3820 |
shifted ifTrue:[ |
|
3821 |
clickLine := cursorLine. |
|
3822 |
clickCol := cursorCol. |
|
3823 |
self expandSelectionDown. |
|
3824 |
^ self |
|
3825 |
]. |
|
3826 |
self unselect. |
|
3827 |
]. |
|
3828 |
]. |
|
3829 |
||
3830 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
3831 |
self cursorDown:n. |
|
3832 |
"/ |
|
3833 |
"/ flush keyboard to avoid runaway cursor |
|
3834 |
"/ |
|
3835 |
self sensor flushKeyboardFor:self. |
|
3836 |
^ self |
|
2580 | 3837 |
]. |
3838 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
3232 | 3839 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3840 |
expandingTop := true. |
|
3841 |
key == #CursorLeft ifTrue:[ |
|
3842 |
cursorCol > 1 ifTrue:[ |
|
3843 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
3844 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
3845 |
selectionStartCol := cursorCol-1. |
|
3846 |
self validateNewSelection. |
|
3847 |
self redrawLine:selectionStartLine. |
|
3848 |
^ self |
|
3849 |
] |
|
3850 |
] ifFalse:[ |
|
3851 |
cursorLine > 1 ifTrue:[ |
|
3852 |
selectionEndLine := clickStartLine := cursorLine. |
|
3853 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
3854 |
selectionStartLine := cursorLine - 1. |
|
3855 |
selectionEndCol == 1 ifTrue:[ |
|
3856 |
selectionEndCol := 0. |
|
3857 |
]. |
|
3858 |
self validateNewSelection. |
|
3859 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
3860 |
^ self |
|
3861 |
] |
|
3862 |
] |
|
3863 |
]. |
|
3864 |
||
3865 |
selectionStartLine notNil ifTrue:[ |
|
3866 |
self cursorMovementAllowed ifTrue:[ |
|
3867 |
"/ |
|
3868 |
"/ treat the whole selection as cursor |
|
3869 |
"/ |
|
3870 |
self setCursorLine:selectionStartLine. |
|
3871 |
self setCursorCol:selectionStartCol. |
|
3872 |
(key == #CursorLeft) ifTrue:[ |
|
3873 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
3874 |
]. |
|
3875 |
self makeCursorVisible. |
|
3876 |
||
3877 |
shifted ifTrue:[ |
|
3878 |
(key == #CursorUp) ifTrue:[ |
|
3879 |
clickLine := cursorLine. |
|
3880 |
self expandSelectionUp. |
|
3881 |
] ifFalse:[ |
|
3882 |
self expandSelectionLeft. |
|
3883 |
]. |
|
3884 |
^ self |
|
3885 |
]. |
|
3886 |
self unselect. |
|
3887 |
]. |
|
3888 |
]. |
|
3889 |
(key == #CursorLeft) ifTrue:[ |
|
3890 |
self cursorLeft. ^self |
|
3891 |
]. |
|
3892 |
(key == #CursorUp) ifTrue:[ |
|
3893 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
3894 |
self cursorUp:n. |
|
3895 |
"/ |
|
3896 |
"/ flush keyboard to avoid runaway cursor |
|
3897 |
"/ |
|
3898 |
self sensor flushKeyboardFor:self. |
|
3899 |
^ self |
|
3900 |
]. |
|
2580 | 3901 |
]. |
3902 |
! |
|
3903 |
||
2952 | 3904 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3905 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3906 |
|
2978 | 3907 |
<resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept |
3235 | 3908 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
3909 |
#SelectWord #DeleteSpaces |
|
3910 |
#SearchMatchingParent #SelectMatchingParents |
|
3911 |
#SelectToEnd #SelectFromBeginning |
|
3912 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
3913 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
3914 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
3915 |
#GotoLine #Delete #BeginOfText #EndOfText |
|
3916 |
#SelectLine #ExpandSelectionByLine #DeleteLine |
|
3917 |
#InsertLine |
|
3918 |
#SelectLineFromBeginning |
|
3919 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
3920 |
#'F*' #'f*')> |
|
2017 | 3921 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3922 |
|fKeyMacros shiftPressed ctrlPressed i event cmdMacro| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3923 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3924 |
event := WindowGroup lastEventQuerySignal query. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3925 |
shiftPressed := event hasShift. |
3024 | 3926 |
ctrlPressed := event hasCtrl and:[(event rawKey startsWith:'Ctrl') not]. |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3927 |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3928 |
cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3929 |
cmdMacro notNil ifTrue:[ |
3235 | 3930 |
self |
3931 |
undoableDo: |
|
3932 |
[ self executeKeyboardMacro:cmdMacro ] |
|
3933 |
info: key. |
|
3934 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3935 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
3936 |
|
3257 | 3937 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3235 | 3938 |
selectionStartLine notNil ifTrue:[ |
3939 |
(key == #BasicBackspace) ifTrue:[ |
|
3940 |
self deleteSelection. |
|
3941 |
] ifFalse: [ |
|
3942 |
self copyAndDeleteSelection. |
|
3943 |
]. |
|
3944 |
^ self |
|
3945 |
]. |
|
3946 |
||
3947 |
self makeCursorVisible. |
|
3948 |
shiftPressed ifTrue:[ |
|
3949 |
self deleteWordBeforeCursor. |
|
3950 |
] ifFalse:[ |
|
3951 |
self deleteCharBeforeCursor. |
|
3952 |
]. |
|
3953 |
||
3954 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
3955 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3956 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3957 |
(key == #LearnKeyboardMacro) ifTrue:[ |
3235 | 3958 |
self toggleLearnMode. |
3959 |
^ self |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3960 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3961 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
3235 | 3962 |
self executeLearnedKeyboardMacro. |
3963 |
^ self. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3964 |
]. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
3965 |
self learnMode ifTrue:[ |
3235 | 3966 |
learnedMacro add:event. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3967 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3968 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3969 |
(key isMemberOf:Character) ifTrue:[ |
3235 | 3970 |
self handleNonCommandKey:key. |
3971 |
^ self |
|
3972 |
]. |
|
3973 |
||
3974 |
key == #ToggleInsertMode ifTrue:[ |
|
3975 |
editMode value == EditMode insertMode ifTrue:[ |
|
3976 |
editMode value:(EditMode overwriteMode). |
|
3977 |
^ self. |
|
3978 |
]. |
|
3979 |
editMode value == EditMode overwriteMode ifTrue:[ |
|
3980 |
editMode value:(EditMode insertAndSelectMode). |
|
3981 |
^ self. |
|
3982 |
]. |
|
3983 |
editMode value == EditMode insertAndSelectMode ifTrue:[ |
|
3984 |
editMode value:(EditMode insertMode). |
|
3985 |
^ self. |
|
3986 |
]. |
|
3987 |
^ self. |
|
3160 | 3988 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3989 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3990 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3991 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3992 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3993 |
Fn pastes a key-sequence (but only if not overlayed with |
3235 | 3994 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3995 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3996 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3997 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
3998 |
(key at:1) asLowercase == $f ifTrue:[ |
3235 | 3999 |
(('[fF][0-9]' match:key) |
4000 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4001 |
shiftPressed ifFalse:[ |
|
4002 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
4003 |
fKeyMacros notNil ifTrue:[ |
|
4004 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4005 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4006 |
^ self |
|
4007 |
] |
|
4008 |
] |
|
4009 |
] |
|
4010 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4011 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4012 |
|
2506 | 4013 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3235 | 4014 |
self parenthizeSelectionWith:$( and:$). |
4015 |
^ self. |
|
2506 | 4016 |
]. |
4017 |
(key == #'Ctrl2') ifTrue:[ |
|
3235 | 4018 |
self parenthizeSelectionWith:$" and:$". |
4019 |
^ self. |
|
2506 | 4020 |
]. |
4021 |
(key == #'Ctrl#') ifTrue:[ |
|
3235 | 4022 |
self parenthizeSelectionWith:$' and:$'. |
4023 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4024 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4025 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4026 |
(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
|
4027 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4028 |
((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4029 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4030 |
(key == #Again) ifTrue:[self again. ^self]. |
2978 | 4031 |
(key == #Undo) ifTrue:[self undo. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4032 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4033 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4034 |
(key == #SelectWord) ifTrue:[ |
3235 | 4035 |
self makeCursorVisible. |
4036 |
self selectWordUnderCursor. |
|
4037 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4038 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4039 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4040 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4041 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4042 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4043 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4044 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4045 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4046 |
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
|
4047 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
4048 |
(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
|
4049 |
(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
|
4050 |
(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
|
4051 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4052 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4053 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4054 |
(key == #BeginOfLine) ifTrue:[ |
3235 | 4055 |
shiftPressed ifTrue: [ |
4056 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4057 |
"/ self unselect. |
|
4058 |
"/ self cursorHome. |
|
4059 |
"Jan's modification" |
|
4060 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
4061 |
] ifFalse: [ |
|
4062 |
self unselect. |
|
4063 |
ctrlPressed ifTrue:[ |
|
4064 |
self cursorHome. |
|
4065 |
] ifFalse:[ |
|
4066 |
self cursorToBeginOfLine. |
|
4067 |
] |
|
4068 |
]. |
|
4069 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4070 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4071 |
(key == #EndOfLine) ifTrue:[ |
3235 | 4072 |
shiftPressed ifTrue:[ |
4073 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4074 |
"/ self unselect. |
|
4075 |
"/ self cursorToBottom |
|
4076 |
"Jan's modification" |
|
4077 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
4078 |
] ifFalse:[ |
|
4079 |
self unselect. |
|
4080 |
ctrlPressed ifTrue:[ |
|
4081 |
self cursorToBottom |
|
4082 |
] ifFalse:[ |
|
4083 |
self cursorToEndOfLine. |
|
4084 |
] |
|
4085 |
]. |
|
4086 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4087 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4088 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
499 | 4089 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4090 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4091 |
|
2580 | 4092 |
(key == #CursorRight |
4093 |
or:[key == #CursorDown |
|
4094 |
or:[key == #CursorLeft |
|
4095 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3235 | 4096 |
self cursorKeyPress:key shifted:shiftPressed. |
4097 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4098 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4099 |
|
3257 | 4100 |
(key == #NonInsertingReturn) ifTrue:[ |
4101 |
self unselect. self cursorReturn. |
|
4102 |
^ self |
|
4103 |
]. |
|
4104 |
||
4105 |
(key == #Return) ifTrue:[ |
|
3235 | 4106 |
shiftPressed ifTrue:[ |
4107 |
self unselect. self cursorReturn. |
|
4108 |
^ self |
|
4109 |
]. |
|
4110 |
self isReadOnly ifTrue:[ |
|
4111 |
self unselect; makeCursorVisible. |
|
4112 |
self cursorReturn |
|
4113 |
] ifFalse:[ |
|
4114 |
self isInInsertMode ifFalse:[ |
|
4115 |
self cursorReturn. |
|
4116 |
autoIndent == true ifTrue:[ |
|
4117 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4118 |
self cursorCol:(i+1 max:1) |
|
4119 |
] |
|
4120 |
] ifTrue:[ |
|
4121 |
"/ old version just unselected ... |
|
4122 |
"/ self unselect; makeCursorVisible. |
|
4123 |
||
4124 |
"/ new version deletes ... |
|
4125 |
typeOfSelection == #paste ifTrue:[ |
|
4126 |
self unselect; makeCursorVisible. |
|
4127 |
] ifFalse:[ |
|
4128 |
self copyAndDeleteSelection. |
|
4129 |
]. |
|
4130 |
self insertCharAtCursor:(Character cr). |
|
4131 |
autoIndent == true ifTrue:[ |
|
4132 |
i := self leftIndentForLine:cursorLine. |
|
4133 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
4134 |
self cursorCol:(i+1 max:1) |
|
4135 |
]. |
|
4136 |
]. |
|
4137 |
]. |
|
4138 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4139 |
]. |
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
|
4140 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4141 |
(key == #NonInsertingTab) ifTrue:[ |
3235 | 4142 |
self unselect. self cursorTab. |
4143 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4144 |
]. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4145 |
(key == #BackTab) ifTrue:[ |
3235 | 4146 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
4147 |
self unselect. self cursorBacktab. |
|
4148 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4149 |
]. |
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4150 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4151 |
(key == #Tab) ifTrue:[ |
3235 | 4152 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
4153 |
||
3257 | 4154 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
4155 |
self unselect. self cursorTab. |
|
4156 |
^ self |
|
3235 | 4157 |
]. |
3257 | 4158 |
|
3235 | 4159 |
self unselect. self insertTabAtCursor. |
4160 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4161 |
]. |
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
|
4162 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4163 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4164 |
(key == #Delete) ifTrue:[ |
3235 | 4165 |
shiftPressed ifTrue:[ |
4166 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
4167 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
4168 |
self makeCursorVisible. |
|
4169 |
self deleteCharAtCursor. |
|
4170 |
]. |
|
4171 |
^ self |
|
4172 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4173 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4174 |
|
870 | 4175 |
(key == #Delete |
4176 |
or:[key == #BasicDelete]) ifTrue:[ |
|
3235 | 4177 |
selectionStartLine notNil ifTrue:[ |
4178 |
(key == #BasicDelete) ifTrue:[ |
|
4179 |
self deleteSelection. |
|
4180 |
] ifFalse:[ |
|
4181 |
self copyAndDeleteSelection. |
|
4182 |
]. |
|
4183 |
^ self |
|
4184 |
]. |
|
4185 |
self makeCursorVisible. |
|
4186 |
self deleteCharAtCursor. |
|
4187 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4188 |
]. |
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
|
4189 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4190 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3235 | 4191 |
self unselect. |
4192 |
cursorVisibleLine == 1 ifTrue:[ |
|
4193 |
self cursorHome. |
|
4194 |
] ifFalse:[ |
|
4195 |
self cursorToFirstVisibleLine |
|
4196 |
]. |
|
4197 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4198 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4199 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3235 | 4200 |
self unselect. |
4201 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
4202 |
self cursorToBottom. |
|
4203 |
] ifFalse:[ |
|
4204 |
self cursorToLastVisibleLine |
|
4205 |
]. |
|
4206 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4207 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4208 |
((key == #Escape) |
3257 | 4209 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3235 | 4210 |
self makeCursorVisible. |
4211 |
self unselect. self selectCursorLineFromBeginning. |
|
4212 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4213 |
]. |
3257 | 4214 |
(key == #SelectLine) ifTrue:[ |
3235 | 4215 |
self makeCursorVisible. |
4216 |
self unselect. self selectCursorLine. |
|
4217 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4218 |
]. |
3257 | 4219 |
(key == #ExpandSelectionByLine) ifTrue:[ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4220 |
"/ self makeCursorVisible. |
3235 | 4221 |
self selectExpandCursorLine. |
4222 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4223 |
]. |
3257 | 4224 |
(key == #DeleteLine) ifTrue:[ |
3235 | 4225 |
self makeCursorVisible. |
4226 |
self unselect. self deleteCursorLine. |
|
4227 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4228 |
]. |
3257 | 4229 |
(key == #InsertLine) ifTrue:[ |
3235 | 4230 |
self makeCursorVisible. |
4231 |
self unselect. self insertLine:nil before:cursorLine. |
|
4232 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4233 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4234 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4235 |
|
1446
609e20a4a234
Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents:
1439
diff
changeset
|
4236 |
"Modified: / 6.2.1998 / 11:59:59 / stefan" |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4237 |
"Modified: / 22.2.2000 / 23:01:23 / cg" |
121 | 4238 |
! |
4239 |
||
2952 | 4240 |
executeKeyboardMacro:cmdMacro |
4241 |
Error handle:[:ex | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4242 |
self warn:'Error in keyboard macro: ' , ex description. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4243 |
ex return. |
2952 | 4244 |
] do:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4245 |
AbortOperationRequest handle:[:ex | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4246 |
self warn:'Keyboard macro aborted'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4247 |
ex return. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4248 |
] do:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4249 |
Parser |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4250 |
evaluate:cmdMacro asString |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4251 |
receiver:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4252 |
notifying:nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4253 |
compile:false. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4254 |
]. |
2952 | 4255 |
]. |
4256 |
! |
|
4257 |
||
4258 |
handleNonCommandKey:keyArg |
|
4259 |
|selStartLine selStartCol selEndLine selEndCol sel key| |
|
4260 |
||
4261 |
self isReadOnly ifTrue:[ |
|
3235 | 4262 |
self flash. |
4263 |
^ self. |
|
2952 | 4264 |
]. |
4265 |
||
4266 |
key := keyArg. |
|
4267 |
||
4268 |
typeOfSelection == #paste ifTrue:[ |
|
3235 | 4269 |
"pasted selection will NOT be replaced by keystroke" |
4270 |
self unselect |
|
2952 | 4271 |
]. |
4272 |
||
4273 |
selStartLine := selectionStartLine. |
|
4274 |
selStartCol := self selectionStartCol. |
|
4275 |
selEndLine := selectionEndLine. |
|
4276 |
selEndCol := self selectionEndCol. |
|
4277 |
sel := self selection. |
|
4278 |
||
4279 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
|
3235 | 4280 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
2952 | 4281 |
]. |
4282 |
||
4283 |
"replace selection by what is typed in - |
|
3235 | 4284 |
if word was selected with a space, keep it. |
4285 |
if there was no selection, the keys character is inserted" |
|
4286 |
||
4287 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4288 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
|
4289 |
]. |
|
2952 | 4290 |
|
4291 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3235 | 4292 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 4293 |
] ifFalse:[ |
3235 | 4294 |
(selectStyle == #wordRight) ifTrue:[ |
4295 |
self replaceSelectionBy:(key asString , ' '). |
|
4296 |
self cursorLeft |
|
4297 |
] ifFalse:[ |
|
4298 |
self replaceSelectionBy:key |
|
4299 |
] |
|
3160 | 4300 |
]. |
2952 | 4301 |
selectStyle := nil. |
4302 |
||
3235 | 4303 |
editMode value isInsertAndSelectMode ifTrue:[ |
4304 |
selectionStartLine := selStartLine. |
|
4305 |
selectionStartCol := selStartCol. |
|
4306 |
selectionEndLine := selEndLine. |
|
4307 |
selectionEndCol := selEndCol. |
|
4308 |
]. |
|
4309 |
||
2952 | 4310 |
showMatchingParenthesis ifTrue:[ |
3235 | 4311 |
"emacs style parenthesis shower" |
4312 |
||
4313 |
"claus: only do it for closing parenthesis - |
|
4314 |
otherwise its too anoying. |
|
4315 |
" |
|
2952 | 4316 |
" |
3235 | 4317 |
(#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[ |
2952 | 4318 |
" |
3235 | 4319 |
(#( $) $] $} ) includes:key) ifTrue:[ |
4320 |
self |
|
4321 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
4322 |
ifFound:[:line :col | |
|
4323 |
|savLine savCol sensor| |
|
4324 |
||
4325 |
self withCursor:Cursor eye do:[ |
|
4326 |
savLine := cursorLine. |
|
4327 |
savCol := cursorCol. |
|
4328 |
self cursorLine:line col:col. |
|
4329 |
device flush. |
|
4330 |
||
4331 |
"/ want to wait 200ms, but not if another keyPress |
|
4332 |
"/ arrives in the meantime ... |
|
4333 |
||
4334 |
sensor := self sensor. |
|
4335 |
5 timesRepeat:[ |
|
4336 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
4337 |
Processor activeProcess millisecondDelay:40. |
|
4338 |
] |
|
4339 |
]. |
|
4340 |
self cursorLine:savLine col:savCol |
|
4341 |
] |
|
4342 |
] |
|
4343 |
ifNotFound:[self showNotFound] |
|
4344 |
onError:[self beep] |
|
4345 |
]. |
|
2952 | 4346 |
]. |
4347 |
||
4348 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
4349 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
4350 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
4351 |
"/ |
|
4352 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4353 |
"/ self selection. |
|
4354 |
"/ typeOfSelection := #paste. |
|
3160 | 4355 |
"/ ]. |
3235 | 4356 |
"/ ]. |
4357 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4358 |
selectionStartLine isNil ifTrue:[ |
|
4359 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
4360 |
] ifFalse:[ |
|
4361 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
4362 |
]. |
|
4363 |
]. |
|
2952 | 4364 |
! |
4365 |
||
4366 |
keyPress:key x:x y:y |
|
4367 |
"handle keyboard input" |
|
4368 |
||
4369 |
self undoableDo:[ |
|
3160 | 4370 |
self doKeyPress:key x:x y:y |
2952 | 4371 |
]. |
4372 |
! |
|
4373 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4374 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4375 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4376 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4377 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4378 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4379 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4380 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4381 |
requestAutoAccept |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4382 |
"this is invoked when a dialog closes via accept or cancel. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4383 |
This forces my value to be accepted into my model" |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4384 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4385 |
acceptEnabled == false ifTrue:[ |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4386 |
"/ nope - |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4387 |
^ false |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4388 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4389 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4390 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4391 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4392 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4393 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4394 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4395 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4396 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4398 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4399 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4400 |
cv notNil ifTrue:[ |
3160 | 4401 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4402 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4403 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4404 |
|
1807 | 4405 |
!EditTextView methodsFor:'focus handling'! |
4406 |
||
4407 |
hasKeyboardFocus:aBoolean |
|
4408 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
4409 |
(otherwise, I would not know about this)" |
|
4410 |
||
4411 |
hasKeyboardFocus := aBoolean. |
|
3160 | 4412 |
(cursorShown |
4413 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4414 |
and:[self isReadOnly not]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4415 |
self drawCursor |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4416 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4417 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4418 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 4419 |
! |
4420 |
||
4421 |
showFocus:explicit |
|
4422 |
"in addition to however my superclass thinks how a focusView is to be |
|
4423 |
displayed, show the cursor when I got the focus" |
|
4424 |
||
4425 |
self showCursor. |
|
4426 |
self hasKeyboardFocus:true. |
|
4427 |
super showFocus:explicit |
|
4428 |
||
4429 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4430 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4431 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4432 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4433 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4434 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4435 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4436 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4437 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4438 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4439 |
and:[self isReadOnly not]]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4440 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4441 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4442 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4443 |
^ false |
1807 | 4444 |
! ! |
4445 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4446 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4447 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4448 |
indent |
3221 | 4449 |
"indent a line-range - this is done by searching for the |
4450 |
last non-empty line before the selection, and changing the indent |
|
4451 |
of the selected line-range based on that lines indent." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4452 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4453 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4455 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 4456 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4457 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4458 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4459 |
(selectionEndCol == 0) ifTrue:[ |
3221 | 4460 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4461 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4462 |
self unselect. |
3160 | 4463 |
self |
3221 | 4464 |
undoableDo:[ |
4465 |
self indentFromLine:start toLine:end |
|
4466 |
] |
|
4467 |
info:'indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4468 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4469 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4470 |
indentFromLine:start toLine:end |
3221 | 4471 |
"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
|
4472 |
last non-empty line before start, and change the indent |
3221 | 4473 |
of the selected line-range based on that lines indent." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4474 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4475 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4476 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4477 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4478 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4479 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4480 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4481 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4482 |
(delta > 0) ifTrue:[ |
3221 | 4483 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4484 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4485 |
start to:end do:[:lineNr | |
3221 | 4486 |
line := self listAt:lineNr. |
4487 |
line notNil ifTrue:[ |
|
4488 |
line isBlank ifTrue:[ |
|
4489 |
list at:lineNr put:nil |
|
4490 |
] ifFalse:[ |
|
4491 |
(delta > 0) ifTrue:[ |
|
4492 |
line := spaces , line. |
|
4493 |
widthOfWidestLine notNil ifTrue:[ |
|
4494 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4495 |
] |
|
4496 |
] ifFalse:[ |
|
4497 |
"check if deletion is ok" |
|
4498 |
d := delta negated + 1. |
|
4499 |
||
4500 |
line size > d ifTrue:[ |
|
4501 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
4502 |
line := line copyFrom:d |
|
4503 |
] |
|
4504 |
]. |
|
4505 |
widthOfWidestLine := nil |
|
4506 |
]. |
|
4507 |
self replaceLine:lineNr with:line. |
|
4508 |
self textChanged. |
|
4509 |
] |
|
4510 |
] |
|
4511 |
]. |
|
4512 |
"/ self redrawFromLine:start to:end |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4513 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4514 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4515 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4516 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4517 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4518 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4519 |
this is done by searching for the last non-empty line before it |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4520 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4521 |
|
827 | 4522 |
"SHOULD GO TO ListView" |
4523 |
||
4524 |
|line lnr indent| |
|
4525 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4526 |
lnr := lineNr. |
827 | 4527 |
|
4528 |
[lnr ~~ 1] whileTrue:[ |
|
3160 | 4529 |
lnr := lnr - 1. |
4530 |
line := self listAt:lnr. |
|
4531 |
||
4532 |
line notNil ifTrue:[ |
|
4533 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
4534 |
indent ~~ 0 ifTrue:[ |
|
4535 |
^ indent - 1 |
|
4536 |
] |
|
4537 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4538 |
]. |
827 | 4539 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4540 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4541 |
"Created: 5.3.1996 / 14:58:53 / cg" |
105 | 4542 |
! ! |
4543 |
||
0 | 4544 |
!EditTextView methodsFor:'initialization'! |
4545 |
||
941 | 4546 |
fetchDeviceResources |
4547 |
"fetch device colors, to avoid reallocation at redraw time" |
|
4548 |
||
4549 |
super fetchDeviceResources. |
|
4550 |
||
1993 | 4551 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
4552 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
4553 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 4554 |
|
4555 |
"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
|
4556 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 4557 |
! |
4558 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4559 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4560 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4561 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4562 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4563 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4564 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4565 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4566 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4567 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4568 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4569 |
super initStyle. |
2088 | 4570 |
lineSpacing := 1. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4571 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4572 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4573 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4574 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4575 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4576 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 4577 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4578 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
3160 | 4579 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4580 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4581 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4582 |
cursorNoFocusFgColor isNil ifTrue:[ |
3160 | 4583 |
cursorType ~~ #block ifTrue:[ |
4584 |
cursorNoFocusFgColor := cursorBgColor |
|
4585 |
] ifFalse:[ |
|
4586 |
cursorNoFocusFgColor := cursorFgColor |
|
4587 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4588 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4589 |
|
2088 | 4590 |
"Modified: / 15.12.1999 / 22:27:45 / 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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4593 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4594 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4595 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4596 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4597 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4598 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4599 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4600 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4601 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4602 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4603 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4604 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4605 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4606 |
cursorCol := 1. |
2815 | 4607 |
cursorLineHolder := 1 asValue. |
4608 |
cursorColHolder := 1 asValue. |
|
2119 | 4609 |
modifiedChannel := ValueHolder with:false. |
4610 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
4611 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4612 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4613 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4614 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4615 |
autoIndent := false. |
3235 | 4616 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4617 |
learnMode := false asValue. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4618 |
trimBlankLines := self st80EditMode not. |
2131 | 4619 |
cursorMovementWhenUpdating := #beginOfText. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
4620 |
|
3236 | 4621 |
"/ enable drop by default |
2589 | 4622 |
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
|
4623 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4624 |
undoSupport := UndoSupport for:self. |
0 | 4625 |
! ! |
4626 |
||
2580 | 4627 |
!EditTextView methodsFor:'macros'! |
4628 |
||
4629 |
executeLearnedKeyboardMacro |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4630 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3160 | 4631 |
learnedMacro do:[:event | |
4632 |
WindowGroup lastEventQuerySignal answer:event |
|
4633 |
do:[ |
|
4634 |
self |
|
4635 |
dispatchEvent:event |
|
4636 |
withFocusOn:nil |
|
4637 |
delegate:false |
|
4638 |
] |
|
4639 |
]. |
|
2580 | 4640 |
] ifFalse:[ |
3160 | 4641 |
self flash. |
2580 | 4642 |
]. |
4643 |
! |
|
4644 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4645 |
learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4646 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4647 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4648 |
|
2580 | 4649 |
learnMode:aBoolean |
4650 |
|fg bg| |
|
4651 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4652 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4653 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4654 |
aBoolean ifTrue:[ |
3160 | 4655 |
learnedMacro := OrderedCollection new. |
4656 |
fg := Color white. |
|
4657 |
bg := Color black. |
|
2580 | 4658 |
] ifFalse:[ |
3160 | 4659 |
cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor. |
4660 |
cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor. |
|
2580 | 4661 |
]. |
4662 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
4663 |
! |
|
4664 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4665 |
learnModeHolder |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4666 |
learnMode isNil ifTrue:[ |
3160 | 4667 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4668 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4669 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4670 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4671 |
|
2580 | 4672 |
toggleLearnMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4673 |
self learnMode: self learnMode not. |
2580 | 4674 |
! ! |
4675 |
||
121 | 4676 |
!EditTextView methodsFor:'menu actions'! |
4677 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4678 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4679 |
"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
|
4680 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4681 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4682 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4683 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4684 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4685 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4686 |
self withWaitCursorDo:[ |
3160 | 4687 |
SOAP::SoapImplError handle:[:ex | |
4688 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
4689 |
] do:[ |
|
4690 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
4691 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4692 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4693 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4694 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4695 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4696 |
self unselect. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4697 |
self undoablePaste:translated |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4698 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4699 |
|
121 | 4700 |
cut |
4701 |
"cut selection into copybuffer" |
|
4702 |
||
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4703 |
|line col history sel s| |
121 | 4704 |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4705 |
(self checkModificationsAllowed) ifFalse:[ |
3160 | 4706 |
self flash. |
4707 |
^ self |
|
1548
d4a3d61388dc
flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents:
1546
diff
changeset
|
4708 |
]. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4709 |
|
121 | 4710 |
sel := self selection. |
4711 |
sel notNil ifTrue:[ |
|
3160 | 4712 |
lastString := s := sel asStringWithCRs. |
4713 |
line := selectionStartLine. |
|
4714 |
col := selectionStartCol. |
|
4715 |
||
4716 |
" |
|
4717 |
remember in CopyBuffer |
|
4718 |
" |
|
4719 |
self setClipboardText:sel. "/ lastString. |
|
4720 |
||
4721 |
" |
|
4722 |
append to DeleteHistory (if there is one) |
|
4723 |
" |
|
4724 |
history := Smalltalk at:#DeleteHistory. |
|
4725 |
history notNil ifTrue:[ |
|
4726 |
history addAll:(sel asStringCollection). |
|
4727 |
history size > 1000 ifTrue:[ |
|
4728 |
history := history copyFrom:(history size - 1000) |
|
4729 |
]. |
|
4730 |
]. |
|
4731 |
||
4732 |
" |
|
4733 |
now, delete it |
|
4734 |
" |
|
4735 |
self undoableDo:[ |
|
4736 |
self deleteSelection. |
|
4737 |
]. |
|
4738 |
lastReplacement := nil |
|
121 | 4739 |
] ifFalse:[ |
3160 | 4740 |
" |
4741 |
a cut without selection will search&cut again |
|
4742 |
" |
|
4743 |
self undoableDo:[ |
|
4744 |
self again |
|
4745 |
] |
|
121 | 4746 |
] |
1290 | 4747 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4748 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
121 | 4749 |
! |
4750 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4751 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4752 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4753 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4754 |
cursorLine notNil ifTrue:[ |
3160 | 4755 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4756 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4757 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4758 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4759 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4760 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4761 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4762 |
|
488 | 4763 |
<resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
4764 |
<resource: #programMenu> |
1054 | 4765 |
|
3252 | 4766 |
|items m sub translateItems sortItems miscItems toolItems subSub toolSub what undoIdx sensor| |
1515 | 4767 |
|
2460 | 4768 |
items := #( |
3221 | 4769 |
('Redo' redo ) |
4770 |
('Again (for All)' multipleAgain ) |
|
4771 |
('-' ) |
|
4772 |
('Search...' search Find ) |
|
4773 |
('Goto Line...' gotoLine GotoLine ) |
|
4774 |
('-' ) |
|
4775 |
('Tools' tools ) |
|
4776 |
('Misc' misc ) |
|
4777 |
('-' ) |
|
4778 |
('Insert File...' insertFile ) |
|
4779 |
('-' ) |
|
4780 |
('Save As...' save SaveAs ) |
|
4781 |
('Print' doPrint Print ) |
|
4782 |
). |
|
2460 | 4783 |
|
2866 | 4784 |
miscItems := #( |
3221 | 4785 |
('AutoIndent \c' autoIndent: ) |
4786 |
('InsertMode \c' insertMode: ) |
|
4787 |
('-' ) |
|
4788 |
('Learn Macro \c' learnMode: LearnKeyboardMacro) |
|
4789 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
4790 |
('-' ) |
|
3223 | 4791 |
('Special Characters...' specialCharacters ) |
4792 |
('Font...' changeFont ) |
|
2870 | 4793 |
"/ ('Encoding...' changeEncoding ) |
3221 | 4794 |
). |
2866 | 4795 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4796 |
translateItems := #( |
3221 | 4797 |
('English -> German' (babelFishTranslate: 'en_de') ) |
4798 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
4799 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
4800 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
4801 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
4802 |
('-' ) |
|
4803 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
4804 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
4805 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
4806 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
4807 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
4808 |
). |
|
4809 |
||
4810 |
sortItems := #( |
|
4811 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
|
4812 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4813 |
('Lines by nth Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
4814 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
4815 |
('-' ) |
|
4816 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
4817 |
('Lines by First Word (ignore case)'(sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
4818 |
('Lines by nth Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
4819 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4820 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4821 |
|
2762 | 4822 |
toolItems := #( |
3221 | 4823 |
('Indent' indent ) |
4824 |
('Sort' sort ) |
|
4825 |
('-' ) |
|
4826 |
('Google Spell' googleSpellingSuggestion ) |
|
4827 |
('Translate' babelFishTranslate ) |
|
4828 |
('-' ) |
|
4829 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
4830 |
). |
|
2762 | 4831 |
|
2460 | 4832 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 4833 |
sub receiver:self. |
2460 | 4834 |
|
2919 | 4835 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
4836 |
toolSub receiver:self. |
|
4837 |
sub subMenuAt:#tools put:toolSub. |
|
4838 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4839 |
subSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
4840 |
subSub receiver:self. |
2919 | 4841 |
toolSub subMenuAt:#babelFishTranslate put:subSub. |
2762 | 4842 |
|
3221 | 4843 |
subSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
4844 |
subSub receiver:self. |
|
4845 |
toolSub subMenuAt:#sort put:subSub. |
|
4846 |
||
2866 | 4847 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
4848 |
subSub receiver:self. |
|
2952 | 4849 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 4850 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 4851 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
2866 | 4852 |
sub subMenuAt:#misc put:subSub. |
4853 |
||
3252 | 4854 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
3221 | 4855 |
m := sub |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4856 |
] ifFalse:[ |
3221 | 4857 |
items := #( |
4858 |
('Undo' undo Undo ) |
|
4859 |
('Again' again Again ) |
|
4860 |
('-' ) |
|
4861 |
('Cut' cut Cut ) |
|
4862 |
('Copy' copySelection Copy ) |
|
4863 |
('Paste' pasteOrReplace Paste ) |
|
4864 |
('-' ) |
|
4865 |
('Accept' accept Accept ) |
|
4866 |
('=' ) |
|
4867 |
('More' others Ctrl ) |
|
4868 |
). |
|
4869 |
m := PopUpMenu itemList:items resources:resources. |
|
4870 |
||
4871 |
m subMenuAt:#others put:sub. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4872 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4873 |
|
2676 | 4874 |
SOAP::GoogleClient isNil ifTrue:[ |
3221 | 4875 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
4876 |
m disable:#googleSpellingSuggestion |
|
2676 | 4877 |
]. |
4878 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
4879 |
self isReadOnly ifTrue:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4880 |
m disableAll:#(undo again multipleAgain redo paste pasteOrReplace cut indent autoIndent: insertMode: |
3223 | 4881 |
insertFile babelFishTranslate googleSpellingSuggestion sort) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4882 |
]. |
2817 | 4883 |
self hasSelectionForCopy ifFalse:[ |
3221 | 4884 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4885 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4886 |
self hasSelection ifFalse:[ |
3223 | 4887 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt sort indent). |
2762 | 4888 |
] ifTrue:[ |
3221 | 4889 |
(Error handle:[:ex | |
4890 |
ex return:false |
|
4891 |
] do:[ |
|
4892 |
self selectionAsString asSingleByteString asFilename exists |
|
4893 |
]) ifFalse:[ |
|
4894 |
m disableAll:#(openFileBrowserOnIt). |
|
4895 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4896 |
]. |
2569 | 4897 |
self hasUndoAction ifFalse:[ |
3221 | 4898 |
m disable:#undo. |
3115 | 4899 |
] ifTrue:[ |
3221 | 4900 |
what := undoSupport undoActionInfo. |
4901 |
what notNil ifTrue:[ |
|
4902 |
undoIdx := m indexOf:#undo. |
|
4903 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
4904 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
4905 |
]. |
2952 | 4906 |
self hasRedoAction ifFalse:[ |
3221 | 4907 |
m disable:#redo. |
2952 | 4908 |
]. |
1108 | 4909 |
acceptEnabled == false ifTrue:[ |
3221 | 4910 |
m disable:#accept |
1108 | 4911 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4912 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4913 |
|
2461 | 4914 |
"Modified: / 13.11.2001 / 10:39:16 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4915 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
4916 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4917 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4918 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4919 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4920 |
history := device getCopyBufferHistory copy. |
3160 | 4921 |
list := history collect:[:entry | |
4922 |
entry asString string asCollectionOfLines |
|
4923 |
detect:[:line| line notEmptyOrNil] |
|
4924 |
ifNone:[' '] |
|
4925 |
]. |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4926 |
box := ListSelectionBox |
3160 | 4927 |
title:'CopyBuffer History' |
4928 |
okText:'Paste' |
|
4929 |
abortText:'Cancel' |
|
4930 |
list:list |
|
4931 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4932 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4933 |
box show. |
3160 | 4934 |
^ sel. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4935 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4936 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4937 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4938 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4939 |
self sensor shiftDown ifTrue:[ |
3160 | 4940 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4941 |
]. |
2724 | 4942 |
|
4943 |
"/ return either the (xterm-) selection or the clipBoard |
|
3160 | 4944 |
^ self |
4945 |
getClipboardText:(self sensor ctrlDown |
|
4946 |
ifTrue:#selection |
|
4947 |
ifFalse:#clipboard) |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4948 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
4949 |
|
2676 | 4950 |
googleSpellingSuggestion |
4951 |
"insert the google-spelling suggestion for the selected text. |
|
4952 |
Requires that the SOAP stuff is loaded and working." |
|
4953 |
||
2677 | 4954 |
|text suggestion| |
2676 | 4955 |
|
4956 |
self withWaitCursorDo:[ |
|
3160 | 4957 |
text := self selection asString string withoutSeparators. |
4958 |
text size == 0 ifTrue:[^ self]. |
|
4959 |
||
4960 |
SOAP::SoapImplError handle:[:ex | |
|
4961 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
4962 |
^ self. |
|
4963 |
] do:[ |
|
4964 |
suggestion := SOAP::GoogleClient new spellingSuggestionOf:text. |
|
4965 |
]. |
|
4966 |
suggestion size == 0 ifTrue:[ |
|
4967 |
Transcript showCR:'No SpellingSuggestion from Google for: ' , text. |
|
4968 |
^ self. |
|
4969 |
]. |
|
2676 | 4970 |
]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4971 |
self undoablePaste:suggestion. |
2676 | 4972 |
! |
4973 |
||
4974 |
insertFile |
|
3160 | 4975 |
"insert contents of a file |
2676 | 4976 |
- ask user for filename using a fileSelectionBox." |
4977 |
||
2909 | 4978 |
|file text ok| |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4979 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
4980 |
[ |
3190 | 4981 |
|why| |
4982 |
||
4983 |
file := Dialog |
|
4984 |
requestFileName:(resources string:'Insert contents of:') |
|
4985 |
default:nil |
|
4986 |
ok:(resources string:'Insert') |
|
4987 |
abort:(resources string:'Cancel') |
|
4988 |
pattern:nil |
|
4989 |
fromDirectory:directoryForFileDialog. |
|
4990 |
file isNil ifTrue:[ |
|
4991 |
"cancel" |
|
4992 |
^ self. |
|
4993 |
]. |
|
4994 |
file := file asFilename. |
|
4995 |
directoryForFileDialog := file. |
|
4996 |
||
4997 |
ok := file isReadable and:[file isDirectory not]. |
|
4998 |
ok ifFalse:[ |
|
4999 |
file isReadable ifFalse:[ |
|
5000 |
why := '%1 is unreadable.\\Please try again.' |
|
5001 |
] ifTrue:[ |
|
5002 |
why := '%1 is a directory.\\Please try again.' |
|
5003 |
]. |
|
5004 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
5005 |
]. |
|
2909 | 5006 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5007 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5008 |
text := file contentsOfEntireFile. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5009 |
self undoablePaste:text. |
2676 | 5010 |
! |
5011 |
||
2762 | 5012 |
openFileBrowserOnIt |
5013 |
"open a fileBrowser on the selected fileName" |
|
5014 |
||
5015 |
|fn dir| |
|
5016 |
||
5017 |
fn := self selectionAsString asFilename. |
|
5018 |
fn exists ifFalse:[ |
|
3160 | 5019 |
^ self warn:'Oops - file is gone'. |
2762 | 5020 |
]. |
5021 |
(dir := fn) isDirectory ifFalse:[ |
|
3160 | 5022 |
dir := fn directory |
2762 | 5023 |
]. |
5024 |
UserPreferences fileBrowserClass openOn:dir |
|
5025 |
! |
|
5026 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5027 |
paste |
1289 | 5028 |
"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
|
5029 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5030 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5031 |
self checkModificationsAllowed ifTrue:[ |
3160 | 5032 |
self withSelfAndTextForPasteDo:[:me :text | |
5033 |
me unselect. |
|
5034 |
me undoablePaste:text |
|
5035 |
] |
|
2952 | 5036 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5037 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5038 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5039 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5040 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5041 |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5042 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5043 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5044 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5045 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5046 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5047 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5048 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5049 |
CharacterEncoderError handle:[:ex | |
3180 | 5050 |
|code msg| |
5051 |
||
5052 |
code := ex parameter. |
|
5053 |
codingErrorReported ifFalse:[ |
|
5054 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
|
5055 |
code notNil ifTrue:[ |
|
5056 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
5057 |
]. |
|
3190 | 5058 |
Dialog warn:(resources stringWithCRs:msg). |
3180 | 5059 |
codingErrorReported := true. |
5060 |
]. |
|
5061 |
ex proceedWith:($? codePoint) |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5062 |
] do:[ |
3180 | 5063 |
s isString ifTrue:[ |
5064 |
s encoding ~~ characterEncoding ifTrue:[ |
|
5065 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5066 |
]. |
|
5067 |
||
5068 |
s := s asStringCollection. |
|
5069 |
(someText endsWith:Character cr) ifTrue:[ |
|
5070 |
"/ s := s copyWith:nil. |
|
5071 |
s := s copyWith:'' "/ an empty line at the end |
|
5072 |
||
5073 |
] |
|
5074 |
] ifFalse:[ |
|
5075 |
s isStringCollection ifTrue:[ |
|
5076 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5077 |
] ifFalse:[ |
|
5078 |
(self |
|
5079 |
confirm:(resources |
|
5080 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
5081 |
with:s class name)) ifFalse:[^ self]. |
|
5082 |
s := StringCollection with:s storeString . |
|
5083 |
"/ ^ self |
|
5084 |
]. |
|
5085 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5086 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5087 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5088 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5089 |
(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
|
5090 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5091 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5092 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5093 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5094 |
startCol := c1 := cursorCol. |
3180 | 5095 |
|
5096 |
"do not expand tabs in s here - |
|
5097 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
5098 |
Some Subviews want to paste with unexpanded tabs!!" |
|
5099 |
||
5100 |
self insertLines:s withCR:false. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5101 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5102 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5103 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5104 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5105 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5106 |
"Modified: / 14.2.1996 / 11:14:14 / stefan" |
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
5107 |
"Modified: / 30.1.2000 / 02:32:42 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5108 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5109 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5110 |
pasteOrReplace |
1289 | 5111 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 5112 |
otherwise paste at cursor position. |
5113 |
Replace is not done for selections which were created by a paste, |
|
2010 | 5114 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5115 |
|
2724 | 5116 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5117 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5118 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5119 |
pasteOrReplace:someText |
1289 | 5120 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5121 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5123 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5124 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5125 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5126 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5127 |
self undoableDo:[ |
3160 | 5128 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
5129 |
self replace:someText |
|
5130 |
] ifFalse:[ |
|
5131 |
self paste:someText. |
|
5132 |
] |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5133 |
]. |
1289 | 5134 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
5135 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5136 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5137 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5138 |
replace |
1289 | 5139 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5140 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5141 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5142 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5143 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5144 |
self withSelfAndTextForPasteDo:[:me :text | |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5145 |
me undoableDo:[ |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5146 |
me replace:text |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5147 |
] |
2952 | 5148 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5149 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5150 |
|
121 | 5151 |
replace:someText |
1289 | 5152 |
"replace the selection by someText" |
121 | 5153 |
|
3160 | 5154 |
|selected selectedString |
5155 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 5156 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5157 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5158 |
|
3130 | 5159 |
self undoableDo:[ |
3160 | 5160 |
selected := self selection. |
5161 |
selected isNil ifTrue:[ |
|
5162 |
^ self paste:someText |
|
5163 |
]. |
|
5164 |
||
5165 |
self deleteSelection. |
|
5166 |
||
5167 |
"take care, if we replace a selection without space by a word selected |
|
5168 |
with one - in this case we usually do not want the space. |
|
5169 |
But, if we replace a word-selected selection by something without a |
|
5170 |
space, we DO want the space added." |
|
5171 |
||
5172 |
selected size == 1 ifTrue:[ |
|
5173 |
selectedString := selected at:1. |
|
5174 |
]. |
|
5175 |
||
5176 |
someText size == 1 ifTrue:[ |
|
5177 |
|cutOffSpace addSpace replacement replacementString| |
|
5178 |
||
5179 |
cutOffSpace := false. |
|
5180 |
addSpace := false. |
|
5181 |
replacement := someText copyFrom:1. |
|
5182 |
||
5183 |
selectedString notNil ifTrue:[ |
|
5184 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
5185 |
"selection has no space" |
|
5186 |
||
5187 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
5188 |
cutOffSpace := true |
|
5189 |
] |
|
5190 |
] ifTrue:[ |
|
5191 |
addSpace := true |
|
5192 |
] |
|
5193 |
]. |
|
5194 |
replacementString := replacement at:1. |
|
5195 |
cutOffSpace ifTrue:[ |
|
5196 |
(replacementString startsWith:' ') ifTrue:[ |
|
5197 |
replacementString := replacementString withoutSpaces |
|
5198 |
]. |
|
5199 |
] ifFalse:[ |
|
5200 |
selectStyle == #wordLeft ifTrue:[ |
|
5201 |
"want a space at left" |
|
5202 |
(replacementString startsWith:' ') ifFalse:[ |
|
5203 |
replacementString := replacementString withoutSpaces. |
|
5204 |
replacementString := ' ' , replacementString |
|
5205 |
] |
|
5206 |
]. |
|
5207 |
selectStyle == #wordRight ifTrue:[ |
|
5208 |
"want a space at right" |
|
5209 |
||
5210 |
(replacementString endsWith:' ') ifFalse:[ |
|
5211 |
replacementString := replacementString withoutSpaces. |
|
5212 |
replacementString := replacementString , ' ' |
|
5213 |
] |
|
5214 |
]. |
|
5215 |
]. |
|
5216 |
replacement at:1 put: replacementString. |
|
5217 |
self paste:replacement. |
|
5218 |
] ifFalse:[ |
|
5219 |
self paste:someText |
|
5220 |
]. |
|
5221 |
lastString := selectedString. |
|
5222 |
lastReplacement := someText. |
|
5223 |
||
5224 |
selStartLine := selectionStartLine. |
|
5225 |
selStartCol := self selectionStartCol. |
|
5226 |
selEndLine := selectionEndLine. |
|
5227 |
selEndCol := self selectionEndCol. |
|
3130 | 5228 |
] |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
5229 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5230 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5231 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 5232 |
! |
5233 |
||
5234 |
showDeleted |
|
5235 |
"open a readonly editor on all deleted text" |
|
5236 |
||
5237 |
|v| |
|
5238 |
||
5239 |
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
|
5240 |
v readOnly:true. |
121 | 5241 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5242 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5243 |
|
3221 | 5244 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
5245 |
"sort the selected lines" |
|
5246 |
||
5247 |
|lines extractor fetcher lineWise nStr n s words| |
|
5248 |
||
5249 |
lineWise := true. |
|
5250 |
||
5251 |
how == #lines ifTrue:[ |
|
5252 |
extractor := [:l | l withoutLeadingSeparators]. |
|
5253 |
] ifFalse:[ how == #linesByFirstWord ifTrue:[ |
|
3222 | 5254 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
3221 | 5255 |
] ifFalse:[ how == #linesByNthWord ifTrue:[ |
5256 |
nStr := Dialog request:'Word (1..)'. |
|
5257 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
5258 |
n := Integer readFrom:nStr onError:[^ self]. |
|
5259 |
||
3227
49b97c45652a
sort by nth word: do not skip non-alphanumeric words
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
5260 |
extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')]. |
3221 | 5261 |
] ifFalse:[ how == #words ifTrue:[ |
5262 |
lineWise := false. |
|
5263 |
extractor := [:w | w]. |
|
5264 |
] ifFalse:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5265 |
self error:'unknown sort criteria: ', how printString. |
3221 | 5266 |
]]]]. |
5267 |
||
5268 |
ignoreCase ifTrue:[ |
|
5269 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
5270 |
] ifFalse:[ |
|
5271 |
fetcher := extractor. |
|
5272 |
]. |
|
5273 |
||
5274 |
lineWise ifTrue:[ |
|
5275 |
start == end ifTrue:[^ self ]. |
|
5276 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
5277 |
lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)]. |
|
5278 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
5279 |
self textChanged. |
|
5280 |
^ self. |
|
5281 |
]. |
|
5282 |
||
5283 |
s := self selectionAsString. |
|
5284 |
words := s asCollectionOfWords. |
|
5285 |
words := words sort:[:w1 :w2 | (fetcher value:w1) < (fetcher value:w2)]. |
|
5286 |
s := words asStringCollection asStringWith:Character space. |
|
5287 |
self replace:s. |
|
5288 |
self textChanged. |
|
5289 |
! |
|
5290 |
||
5291 |
sortSelection:how ignoreCase:ignoreCase |
|
5292 |
"sort the selected lines" |
|
5293 |
||
5294 |
|start end| |
|
5295 |
||
5296 |
selectionStartLine isNil ifTrue:[^ self]. |
|
5297 |
||
5298 |
start := selectionStartLine. |
|
5299 |
end := selectionEndLine. |
|
5300 |
(selectionEndCol == 0) ifTrue:[ |
|
5301 |
end := end - 1 |
|
5302 |
]. |
|
5303 |
||
5304 |
self |
|
5305 |
undoableDo:[ |
|
5306 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end. |
|
5307 |
] |
|
5308 |
info:'sort' |
|
5309 |
! |
|
5310 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5311 |
specialCharacters |
2915 | 5312 |
CharacterSetView |
3160 | 5313 |
openAsInputFor:self |
5314 |
label:'Special Character Input' |
|
5315 |
clickLabel:'Click to Insert Character'. |
|
2866 | 5316 |
! |
5317 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5318 |
undoablePaste:someText |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5319 |
self undoableDo:[ |
3160 | 5320 |
self paste:someText. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5321 |
]. |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5322 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5323 |
|
2724 | 5324 |
withSelfAndTextForPasteDo:aBlock |
5325 |
"common code for paste/replace of the copybuffer" |
|
5326 |
||
5327 |
|sel| |
|
5328 |
||
5329 |
self checkModificationsAllowed ifFalse:[ |
|
3160 | 5330 |
self flash. |
5331 |
^ self |
|
2724 | 5332 |
]. |
5333 |
||
5334 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
5335 |
sel notNil ifTrue:[ |
|
3160 | 5336 |
aBlock value:self value:sel. |
2724 | 5337 |
] |
105 | 5338 |
! ! |
5339 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5340 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5341 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5342 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5343 |
"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
|
5344 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5345 |
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
|
5346 |
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
|
5347 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5348 |
self isReadOnly ifTrue: [ |
3160 | 5349 |
exceptionBlock isNil ifTrue:[ |
5350 |
^ false |
|
5351 |
]. |
|
5352 |
||
5353 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
5354 |
^ false |
|
5355 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5356 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5357 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5358 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5359 |
"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
|
5360 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5361 |
|
2596 | 5362 |
currentSelectionBgColor |
5363 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 5364 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 5365 |
]. |
5366 |
^ super currentSelectionBgColor |
|
5367 |
||
5368 |
" |
|
5369 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
5370 |
" |
|
5371 |
! |
|
5372 |
||
5373 |
currentSelectionFgColor |
|
5374 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 5375 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 5376 |
]. |
5377 |
^ super currentSelectionFgColor |
|
5378 |
! |
|
5379 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5380 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5381 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5382 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5383 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5384 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5385 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5386 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5387 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5388 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5389 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5390 |
textChanged |
522 | 5391 |
"my text was modified (internally). |
5392 |
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
|
5393 |
contentsChanged, which is triggered when the size has changed, and |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5394 |
is used to notify scrollers, other views etc.)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5395 |
|
641 | 5396 |
self contentsChanged. |
1015 | 5397 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5398 |
contentsWasSaved := false |
641 | 5399 |
|
1015 | 5400 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 5401 |
! |
5402 |
||
2617 | 5403 |
textChangedButNoSizeChange |
2207 | 5404 |
"my text was modified (internally). |
5405 |
Sent whenever text has been edited (not to confuse with |
|
5406 |
contentsChanged, which is triggered when the size has changed, and |
|
5407 |
is used to notify scrollers, other views etc.)" |
|
5408 |
||
5409 |
self modified:true. |
|
5410 |
contentsWasSaved := false |
|
5411 |
||
5412 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5413 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5414 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5415 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5416 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5417 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5418 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5419 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5420 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5421 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5422 |
"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
|
5423 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5424 |
|
1878 | 5425 |
isKeyboardConsumer |
5426 |
"return true, if the receiver is a keyboard consumer; |
|
5427 |
Return true here, redefined from SimpleView." |
|
5428 |
||
5429 |
^ true |
|
5430 |
||
5431 |
! |
|
5432 |
||
997 | 5433 |
specClass |
1390 | 5434 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
5435 |
||
997 | 5436 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 5437 |
^ super specClass |
5438 |
||
1390 | 5439 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 5440 |
! |
5441 |
||
324 | 5442 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5443 |
"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
|
5444 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5445 |
"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
|
5446 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5447 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 5448 |
|
5449 |
"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
|
5450 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
5451 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5452 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5453 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5454 |
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
|
5455 |
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
|
5456 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5457 |
|
697 | 5458 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5459 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5460 |
w := super widthOfContents. |
697 | 5461 |
(dev := device) isNil ifTrue:[ |
3160 | 5462 |
"/ really dont know ... |
5463 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
5464 |
]. |
697 | 5465 |
^ w + (font widthOn:dev) |
5466 |
||
5467 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5468 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5469 |
|
1588 | 5470 |
!EditTextView methodsFor:'realization'! |
5471 |
||
5472 |
realize |
|
5473 |
"make the view visible - scroll to make the cursor visible." |
|
5474 |
||
5475 |
super realize. |
|
5476 |
||
5477 |
self makeCursorVisible. |
|
1993 | 5478 |
cursorFgColor := cursorFgColor onDevice:device. |
5479 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 5480 |
|
5481 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
5482 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
5483 |
! ! |
|
5484 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5485 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5486 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5487 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5488 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5489 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5490 |
cursorShown ifTrue:[ |
3160 | 5491 |
cursorVisibleLine notNil ifTrue:[ |
5492 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
5493 |
self drawCursorCharacter |
|
5494 |
] |
|
5495 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5496 |
] |
105 | 5497 |
! |
5498 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5499 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5500 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5501 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5502 |
cursorShown ifTrue:[ |
3160 | 5503 |
(visLine == cursorVisibleLine) ifTrue:[ |
5504 |
self drawCursorCharacter |
|
5505 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5506 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5507 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5508 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5509 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5510 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5511 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5512 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5513 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5514 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5515 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5516 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5517 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5518 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5519 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5520 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5521 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5522 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5523 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5524 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5525 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5526 |
cursorShown ifTrue:[ |
3160 | 5527 |
(visLine == cursorVisibleLine) ifTrue:[ |
5528 |
(colNr == cursorCol) ifTrue:[ |
|
5529 |
self drawCursorCharacter. |
|
5530 |
^ self |
|
5531 |
] |
|
5532 |
] |
|
0 | 5533 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5534 |
super redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5535 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5537 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5538 |
"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
|
5539 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5540 |
super redrawVisibleLine:visLine from:startCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5541 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5542 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5543 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5544 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5545 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5547 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5548 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5549 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5550 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5551 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5552 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5553 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5554 |
"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
|
5555 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5556 |
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
|
5557 |
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
|
5558 |
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
|
5559 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5560 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5561 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
5562 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5563 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5564 |
"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
|
5565 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5567 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5568 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5569 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5570 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5571 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5572 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5573 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5574 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5575 |
"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
|
5576 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5579 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5580 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5581 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5582 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5583 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5584 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5585 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5586 |
"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
|
5587 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5588 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5589 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5590 |
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
|
5591 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5592 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5593 |
prevCursorState ifTrue:[ |
3160 | 5594 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5595 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5596 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5597 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5598 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5599 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5600 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5601 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5602 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5603 |
prevCursorState := cursorShown. |
1601 | 5604 |
"/ cursorShown := false. |
1591 | 5605 |
cursorShown ifTrue:[ |
3160 | 5606 |
self hideCursor |
1591 | 5607 |
] |
5608 |
||
1601 | 5609 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5610 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5611 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5612 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5613 |
"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
|
5614 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5615 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5616 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5617 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5618 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5619 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5620 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5621 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5622 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5623 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5624 |
"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
|
5625 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5626 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5628 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5629 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5631 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5633 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5635 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5636 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5638 |
|
2822 | 5639 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 5640 |
! |
5641 |
||
5642 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
5643 |
"do a backward search" |
|
5644 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5645 |
|pos startLine startCol| |
1339 | 5646 |
|
5647 |
cursorLine isNil ifTrue:[^ self]. |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5648 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5649 |
pos := self startPositionForSearchBackward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5650 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5651 |
startCol := pos x. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5652 |
|
3160 | 5653 |
self |
5654 |
searchBackwardFor:pattern |
|
5655 |
ignoreCase:ign |
|
5656 |
startingAtLine:startLine col:startCol |
|
5657 |
ifFound:[:line :col | |
|
5658 |
self cursorMovementAllowed ifTrue:[ |
|
5659 |
self cursorLine:line col:col. |
|
5660 |
]. |
|
5661 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 5662 |
"/ self makeLineVisible:cursorLine |
3160 | 5663 |
typeOfSelection := #search] |
5664 |
ifAbsent:aBlock |
|
1339 | 5665 |
|
5666 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5667 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5668 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5669 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5670 |
"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
|
5671 |
|
2554 | 5672 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5674 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5675 |
searchForMatchingParenthesis |
3160 | 5676 |
"search for a matching parenthesis starting at cursor position. |
5677 |
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
|
5678 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5679 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5680 |
|
2822 | 5681 |
self cursorMovementAllowed ifFalse:[^ self]. |
5682 |
||
3160 | 5683 |
self |
5684 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
|
5685 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
5686 |
ifNotFound:[self showNotFound] |
|
5687 |
onError:[self beep] |
|
1339 | 5688 |
|
5689 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5690 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5691 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5692 |
searchFwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5693 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5694 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5695 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5696 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5697 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5698 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5699 |
startCol := pos x. |
1339 | 5700 |
|
3160 | 5701 |
self |
5702 |
searchFwd:pattern |
|
5703 |
startingAtLine:startLine col:startCol |
|
5704 |
ifAbsent:aBlock |
|
1339 | 5705 |
|
5706 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5707 |
! |
|
5708 |
||
5709 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
5710 |
"do a forward search" |
|
5711 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5712 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5713 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5714 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5715 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5716 |
startCol := pos x. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5717 |
|
3160 | 5718 |
self |
5719 |
searchFwd:pattern |
|
5720 |
ignoreCase:ign |
|
5721 |
startingAtLine:startLine col:startCol |
|
5722 |
ifAbsent:aBlock |
|
1339 | 5723 |
|
5724 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
5725 |
"Created: 9.10.1997 / 13:04:10 / cg" |
|
5726 |
! |
|
5727 |
||
5728 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
5729 |
"do a forward search" |
|
5730 |
||
5731 |
cursorLine isNil ifTrue:[^ self]. |
|
3160 | 5732 |
self |
5733 |
searchForwardFor:pattern |
|
5734 |
ignoreCase:ign |
|
5735 |
startingAtLine:startLine col:startCol |
|
5736 |
ifFound:[:line :col | |
|
5737 |
self cursorMovementAllowed ifTrue:[ |
|
5738 |
self cursorLine:line col:col. |
|
5739 |
]. |
|
5740 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 5741 |
"/ self makeLineVisible:cursorLine |
3160 | 5742 |
typeOfSelection := #search] |
5743 |
ifAbsent:aBlock |
|
1339 | 5744 |
|
5745 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
5746 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5747 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5748 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5749 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5750 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5751 |
|
2822 | 5752 |
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
|
5753 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5754 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5755 |
setSearchPattern |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5756 |
"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
|
5757 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5759 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5760 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5761 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5762 |
"/ if the last operation was a replcae, set pattern to last |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5763 |
"/ original string (for search after again) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5764 |
"/ |
3160 | 5765 |
(lastString notNil |
565 | 5766 |
and:[lastReplacement notNil |
5767 |
and:[typeOfSelection ~~ #search]]) ifTrue:[ |
|
3160 | 5768 |
lastString isString ifTrue:[ |
5769 |
lastSearchPattern := lastString. |
|
5770 |
] ifFalse:[ |
|
5771 |
lastSearchPattern := lastString asStringWithoutFinalCR. |
|
5772 |
]. |
|
5773 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5774 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5775 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5776 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5777 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5778 |
"/ 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
|
5779 |
"/ if there was a previous search, only take the selection if |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5780 |
"/ it did not result from a paste. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5781 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5782 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5783 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5784 |
sel notNil ifTrue:[ |
3160 | 5785 |
(lastSearchPattern isNil |
5786 |
or:[typeOfSelection ~~ #paste]) ifTrue:[ |
|
5787 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
5788 |
lastSearchPattern := sel asStringWithoutFinalCR withMatchEscapes |
|
5789 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5790 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
5791 |
|
565 | 5792 |
"Modified: 20.4.1996 / 12:50:13 / cg" |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5793 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5794 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5795 |
startPositionForSearchBackward |
2822 | 5796 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
5797 |
! |
|
5798 |
||
5799 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5800 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5801 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5802 |
selectionStartLine notNil ifTrue:[ |
3160 | 5803 |
startLine := selectionStartLine. |
5804 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5805 |
] ifFalse:[ |
3160 | 5806 |
cursorLine isNil ifTrue:[ |
5807 |
startLine := list size. |
|
5808 |
startCol := self listAt:startLine size. |
|
5809 |
] ifFalse:[ |
|
5810 |
startLine := cursorLine min:list size. |
|
5811 |
startCol := cursorCol |
|
5812 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5813 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5814 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5815 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5816 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5817 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5818 |
startPositionForSearchForward |
2822 | 5819 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
5820 |
! |
|
5821 |
||
5822 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5823 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5824 |
|
3160 | 5825 |
"/ 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
|
5826 |
"/ 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
|
5827 |
startCol := cursorCol. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5828 |
self hasSelection ifFalse:[ |
3160 | 5829 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
5830 |
startCol := 0 |
|
5831 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5832 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5833 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
5834 |
^ startCol @ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5835 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5836 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5837 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5838 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5839 |
addToSelectionAfter:aBlock |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5840 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5841 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5842 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5843 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5844 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5845 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5846 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5847 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5848 |
self hasSelection ifTrue: [ |
3160 | 5849 |
startLine := selectionStartLine . |
5850 |
startCol := selectionStartCol . |
|
5851 |
endLine := selectionEndLine . |
|
5852 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5853 |
] ifFalse: [ |
3160 | 5854 |
startLine := endLine := cursorLine . |
5855 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5856 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5857 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5858 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5859 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5860 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5861 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5862 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5863 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
3160 | 5864 |
ifTrue: [ |
5865 |
startCol := cursorCol. |
|
5866 |
] ifFalse: [ |
|
5867 |
endCol := cursorCol - 1. |
|
5868 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5869 |
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
|
5870 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
5871 |
|
1850 | 5872 |
autoMoveCursorToEndOfSelection |
5873 |
"return true, if the cursor should be automatically moved to the |
|
5874 |
end of a selection. |
|
5875 |
Redefined to return false in terminaViews, where the cursor should |
|
5876 |
not be affected by selecting" |
|
5877 |
||
5878 |
^ true |
|
5879 |
! |
|
5880 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5881 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5882 |
typeOfSelection ~~ newType ifTrue:[ |
3160 | 5883 |
typeOfSelection := newType. |
5884 |
selectionStartLine notNil ifTrue:[ |
|
5885 |
self |
|
5886 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
5887 |
toLine:selectionEndLine col:selectionEndCol |
|
5888 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5889 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5890 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5891 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5892 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5893 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5894 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5895 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5896 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5897 |
list isNil ifTrue:[ |
3160 | 5898 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5899 |
] ifFalse:[ |
3160 | 5900 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
5901 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5902 |
] |
1082 | 5903 |
|
5904 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5905 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5906 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5907 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5908 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5909 |
|
3160 | 5910 |
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
|
5911 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5912 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5913 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5914 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5915 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5916 |
cursorCol > 1 ifTrue:[ |
3160 | 5917 |
self selectFromLine:cursorLine col:1 |
5918 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5919 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5920 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
5921 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5922 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5923 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5924 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5925 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5926 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5927 |
selectionStartLine isNil ifTrue:[ |
3160 | 5928 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5929 |
] ifFalse:[ |
3160 | 5930 |
self selectFromLine:selectionStartLine col:selectionStartCol |
5931 |
toLine:cursorLine+1 col:0. |
|
5932 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5933 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5934 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5935 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5936 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5937 |
"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
|
5938 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5939 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5940 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5941 |
list isNil ifTrue:[ |
3160 | 5942 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5943 |
] ifFalse:[ |
3160 | 5944 |
cursorCol == 0 ifTrue:[ |
5945 |
col := 0 |
|
5946 |
] ifFalse:[ |
|
5947 |
col := cursorCol - 1 |
|
5948 |
]. |
|
5949 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
5950 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5951 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5952 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5953 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5954 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5955 |
"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
|
5956 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5957 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5958 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 5959 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
3160 | 5960 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 5961 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5962 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5963 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5964 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5965 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5966 |
"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
|
5967 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5968 |
list isNil ifTrue:[ |
3160 | 5969 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5970 |
] ifFalse:[ |
3160 | 5971 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
5972 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5973 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5974 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5976 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5977 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5979 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5980 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5981 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5982 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5983 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5984 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5985 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5986 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5987 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5988 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5989 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5990 |
wasOn ifTrue:[self showCursor] |
105 | 5991 |
! ! |
5992 |
||
5993 |
!EditTextView methodsFor:'undo & again'! |
|
5994 |
||
2952 | 5995 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5996 |
^ undoSupport addUndo:action. |
2952 | 5997 |
! |
5998 |
||
105 | 5999 |
again |
6000 |
"repeat the last action (which was a cut or replace). |
|
6001 |
If current selection is not last string, search forward to |
|
3160 | 6002 |
next occurrence of it before repeating the last operation." |
105 | 6003 |
|
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
6004 |
|s l c sel savedSelectStyle startColForSearch| |
105 | 6005 |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6006 |
lastString isNil ifTrue:[ |
3160 | 6007 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6008 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6009 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6010 |
self undoableDo:[ |
3160 | 6011 |
s := lastString asString. |
6012 |
||
6013 |
"remove final cr" |
|
6014 |
(s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6015 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
3160 | 6016 |
savedSelectStyle := selectStyle. |
6017 |
selectStyle := nil. |
|
6018 |
||
6019 |
sel := self selection. |
|
6020 |
||
6021 |
"if we are already there (after a find), ommit search" |
|
6022 |
||
6023 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
6024 |
l := selectionStartLine "cursorLine". |
|
6025 |
c := selectionStartCol "cursorCol". |
|
6026 |
self deleteSelection. |
|
6027 |
lastReplacement notNil ifTrue:[ |
|
6028 |
self insertLines:lastReplacement asStringCollection withCR:false. |
|
6029 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
6030 |
]. |
|
6031 |
selectStyle := savedSelectStyle. |
|
6032 |
^ true |
|
6033 |
]. |
|
6034 |
startColForSearch := cursorCol. |
|
6035 |
sel isNil ifTrue:[ |
|
6036 |
startColForSearch := startColForSearch - 1 |
|
6037 |
]. |
|
6038 |
self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch |
|
6039 |
ifFound: |
|
6040 |
[ |
|
6041 |
:line :col | |
|
6042 |
||
6043 |
|repl| |
|
6044 |
||
6045 |
self selectFromLine:line col:col |
|
6046 |
toLine:line col:(col + s size - 1). |
|
6047 |
self makeLineVisible:line. |
|
6048 |
||
6049 |
self deleteSelection. |
|
6050 |
lastReplacement notNil ifTrue:[ |
|
6051 |
lastReplacement isString ifFalse:[ |
|
6052 |
repl := lastReplacement asString "withoutSpaces" |
|
6053 |
] ifTrue:[ |
|
6054 |
repl := lastReplacement "withoutSpaces". |
|
6055 |
]. |
|
6056 |
self insertLines:repl asStringCollection withCR:false. |
|
6057 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
6058 |
undoSupport actionInfo:'replace'. |
|
6059 |
]. |
|
6060 |
selectStyle := savedSelectStyle. |
|
6061 |
^ true |
|
6062 |
] |
|
6063 |
ifAbsent: |
|
6064 |
[ |
|
6065 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
6066 |
self showNotFound. |
|
6067 |
selectStyle := savedSelectStyle. |
|
6068 |
^ false |
|
6069 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6070 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6071 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6072 |
^ true. |
501 | 6073 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
6074 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 6075 |
! |
6076 |
||
2952 | 6077 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6078 |
^ undoSupport hasRedoAction. |
2952 | 6079 |
! |
6080 |
||
6081 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6082 |
^ undoSupport hasUndoAction. |
2952 | 6083 |
! |
6084 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6085 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6086 |
"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
|
6087 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6088 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6089 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6090 |
|
2952 | 6091 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6092 |
undoSupport nonUndoableDo:aBlock. |
2952 | 6093 |
! |
6094 |
||
6095 |
redo |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6096 |
undoSupport hasRedoAction ifFalse:[ |
3160 | 6097 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6098 |
] ifTrue:[ |
3160 | 6099 |
undoSupport redo. |
2952 | 6100 |
] |
6101 |
! |
|
6102 |
||
121 | 6103 |
undo |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6104 |
undoSupport hasUndoAction ifFalse:[ |
3160 | 6105 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6106 |
] ifTrue:[ |
3160 | 6107 |
undoSupport undo. |
121 | 6108 |
] |
2952 | 6109 |
! |
6110 |
||
6111 |
undoableDo:aBlock |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6112 |
self checkModificationsAllowed ifFalse:[ |
3160 | 6113 |
aBlock value. |
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6114 |
] ifTrue:[ |
3160 | 6115 |
undoSupport undoableDo:aBlock. |
2952 | 6116 |
]. |
3130 | 6117 |
! |
6118 |
||
6119 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6120 |
self checkModificationsAllowed ifFalse:[ |
3160 | 6121 |
aBlock value. |
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6122 |
] ifTrue:[ |
3160 | 6123 |
undoSupport undoableDo:aBlock info:aString. |
3130 | 6124 |
]. |
2952 | 6125 |
! ! |
6126 |
||
6127 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
6128 |
||
6129 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6130 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6131 |
! |
|
6132 |
||
3115 | 6133 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 6134 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 6135 |
! |
6136 |
||
2952 | 6137 |
line:arg1 col:arg2 character:arg3 |
6138 |
^ self new line:arg1 col:arg2 character:arg3 |
|
6139 |
! |
|
6140 |
||
3115 | 6141 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 6142 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 6143 |
! |
6144 |
||
3235 | 6145 |
line:arg1 col:arg2 characters:arg3 info:info |
6146 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
6147 |
! |
|
6148 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6149 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6150 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6151 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6152 |
|
2952 | 6153 |
line:arg1 col:arg2 string:arg3 |
6154 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 6155 |
! |
6156 |
||
6157 |
line:arg1 col:arg2 string:arg3 info:info |
|
6158 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 6159 |
! |
6160 |
||
6161 |
line:arg1 string:arg3 info:info |
|
6162 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 6163 |
! |
6164 |
||
6165 |
text:arg info:info |
|
6166 |
^ (self new text:arg) info:info |
|
3115 | 6167 |
! ! |
6168 |
||
6169 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
6170 |
||
6171 |
info |
|
6172 |
^ userFriendlyInfo |
|
6173 |
! |
|
6174 |
||
6175 |
info:aString |
|
6176 |
userFriendlyInfo := aString |
|
2952 | 6177 |
! ! |
6178 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6179 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6180 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6181 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6182 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6183 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6184 |
|
2952 | 6185 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
6186 |
||
3160 | 6187 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 6188 |
"set instance variables (automatically generated)" |
6189 |
||
6190 |
self assert:(line1Arg notNil). |
|
6191 |
self assert:(col1Arg notNil). |
|
6192 |
self assert:(line2Arg notNil). |
|
6193 |
self assert:(col2Arg notNil). |
|
6194 |
||
6195 |
line1 := line1Arg. |
|
6196 |
col1 := col1Arg. |
|
6197 |
line2 := line2Arg. |
|
6198 |
col2 := col2Arg. |
|
6199 |
! ! |
|
6200 |
||
6201 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
6202 |
||
3160 | 6203 |
executeIn:editor |
2952 | 6204 |
editor unselect. |
3160 | 6205 |
editor |
6206 |
deleteFromLine:line1 |
|
6207 |
col:col1 |
|
6208 |
toLine:line2 |
|
6209 |
col:col2. |
|
2952 | 6210 |
editor cursorLine:line1 col:col1. |
6211 |
! ! |
|
6212 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6213 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6214 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6215 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6216 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6217 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6218 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6219 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6220 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6221 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6222 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6223 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6224 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6225 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6226 |
|
3160 | 6227 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6228 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6229 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6230 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6231 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6232 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6233 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6234 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6235 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6236 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6237 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6238 |
|
3160 | 6239 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6240 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6241 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6242 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6243 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6244 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6245 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6246 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6247 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6248 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6249 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6250 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6251 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6252 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6253 |
|
3160 | 6254 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6255 |
"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
|
6256 |
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
|
6257 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6258 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6259 |
previousDeleteAction line == line ifTrue:[ |
3160 | 6260 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
6261 |
^ true |
|
6262 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6263 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6264 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6265 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6266 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6267 |
|
3160 | 6268 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6269 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6270 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6271 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6272 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6273 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6274 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6275 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6276 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6277 |
|
3160 | 6278 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6279 |
editor unselect. |
3160 | 6280 |
editor |
6281 |
deleteFromLine:line |
|
6282 |
col:col1 |
|
6283 |
toLine:line |
|
6284 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6285 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6286 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6287 |
|
3235 | 6288 |
!EditTextView::EditMode class methodsFor:'constants'! |
6289 |
||
6290 |
insertAndSelectMode |
|
6291 |
^ InsertAndSelectMode |
|
6292 |
! |
|
6293 |
||
6294 |
insertMode |
|
6295 |
^ InsertMode |
|
6296 |
! |
|
6297 |
||
6298 |
overwriteMode |
|
6299 |
^ OverwriteMode |
|
6300 |
! ! |
|
6301 |
||
6302 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
6303 |
||
6304 |
isInsertAndSelectMode |
|
6305 |
^ false |
|
6306 |
! |
|
6307 |
||
6308 |
isInsertMode |
|
6309 |
^ false |
|
6310 |
! |
|
6311 |
||
6312 |
symbolicName |
|
6313 |
self subclassResponsibility |
|
6314 |
! ! |
|
6315 |
||
6316 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
6317 |
||
6318 |
infoPrintString |
|
6319 |
^ 'IS' |
|
6320 |
! ! |
|
6321 |
||
6322 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
6323 |
||
6324 |
isInsertAndSelectMode |
|
6325 |
^ true |
|
6326 |
! |
|
6327 |
||
6328 |
isInsertMode |
|
6329 |
^ true |
|
6330 |
! ! |
|
6331 |
||
6332 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
6333 |
||
6334 |
infoPrintString |
|
6335 |
^ 'I' |
|
6336 |
! ! |
|
6337 |
||
6338 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
6339 |
||
6340 |
isInsertMode |
|
6341 |
^ true |
|
6342 |
! ! |
|
6343 |
||
6344 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
6345 |
||
6346 |
infoPrintString |
|
6347 |
^ 'O' |
|
6348 |
! ! |
|
6349 |
||
2952 | 6350 |
!EditTextView::InsertCharacter methodsFor:'accessing'! |
6351 |
||
3160 | 6352 |
line:lineArg col:colArg character:characterArg |
2952 | 6353 |
"set instance variables (automatically generated)" |
6354 |
||
6355 |
line := lineArg. |
|
6356 |
col := colArg. |
|
6357 |
character := characterArg. |
|
6358 |
! ! |
|
6359 |
||
6360 |
!EditTextView::InsertCharacter methodsFor:'execution'! |
|
6361 |
||
3160 | 6362 |
executeIn:editor |
6363 |
editor |
|
6364 |
replace:character |
|
6365 |
atLine:line |
|
6366 |
col:col. |
|
2952 | 6367 |
editor cursorLine:line col:col. |
6368 |
! ! |
|
6369 |
||
6370 |
!EditTextView::PasteString methodsFor:'accessing'! |
|
6371 |
||
3160 | 6372 |
line:lineArg col:colArg string:stringArg |
2952 | 6373 |
self assert:(lineArg notNil). |
6374 |
self assert:(colArg notNil). |
|
6375 |
self assert:(stringArg notNil). |
|
6376 |
||
6377 |
line := lineArg. |
|
6378 |
col := colArg. |
|
6379 |
string := stringArg. |
|
6380 |
! |
|
6381 |
||
6382 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
6383 |
self assert:(lineArg notNil). |
|
6384 |
self assert:(colArg notNil). |
|
6385 |
self assert:(stringArg notNil). |
|
6386 |
||
6387 |
line := lineArg. |
|
6388 |
col := colArg. |
|
6389 |
string := stringArg. |
|
6390 |
selected := selectedArg. |
|
6391 |
! ! |
|
6392 |
||
6393 |
!EditTextView::PasteString methodsFor:'execution'! |
|
6394 |
||
3160 | 6395 |
executeIn:editor |
2952 | 6396 |
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
|
6397 |
editor paste:string. |
2952 | 6398 |
selected ~~ true ifTrue:[ |
3160 | 6399 |
editor unselect |
2952 | 6400 |
]. |
6401 |
! ! |
|
6402 |
||
6403 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
6404 |
||
3235 | 6405 |
col |
6406 |
^ col |
|
6407 |
! |
|
6408 |
||
6409 |
col1 |
|
6410 |
^ col |
|
6411 |
! |
|
6412 |
||
6413 |
col2 |
|
6414 |
^ col |
|
6415 |
! |
|
6416 |
||
6417 |
line |
|
6418 |
^ line |
|
6419 |
! |
|
6420 |
||
3160 | 6421 |
line:lineArg col:colArg character:characterArg |
2952 | 6422 |
line := lineArg. |
6423 |
col := colArg. |
|
6424 |
character := characterArg. |
|
6425 |
! ! |
|
6426 |
||
6427 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
6428 |
||
3160 | 6429 |
executeIn:editor |
6430 |
editor |
|
6431 |
replace:character |
|
6432 |
atLine:line |
|
6433 |
col:col. |
|
2952 | 6434 |
editor cursorLine:line col:col. |
105 | 6435 |
! ! |
6436 |
||
3235 | 6437 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
6438 |
||
6439 |
characters |
|
6440 |
^ characters |
|
6441 |
! |
|
6442 |
||
6443 |
col1 |
|
6444 |
^ col1 |
|
6445 |
! |
|
6446 |
||
6447 |
col2 |
|
6448 |
^ col2 |
|
6449 |
! |
|
6450 |
||
6451 |
line |
|
6452 |
^ line |
|
6453 |
! |
|
6454 |
||
6455 |
line:lineArg col:colArg character:characterArg |
|
6456 |
line := lineArg. |
|
6457 |
col1 := col2 := colArg. |
|
6458 |
characters := characterArg asString. |
|
6459 |
! |
|
6460 |
||
6461 |
line:lineArg col:colArg characters:charactersArg |
|
6462 |
line := lineArg. |
|
6463 |
col1 := colArg. |
|
6464 |
characters := charactersArg asString. |
|
6465 |
col2 := col1 + charactersArg size - 1 |
|
6466 |
! ! |
|
6467 |
||
6468 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
6469 |
||
6470 |
canCombineWithNext:anotherAction |
|
6471 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
6472 |
! |
|
6473 |
||
6474 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
6475 |
"I will combine only if we both are single character deletes, |
|
6476 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
6477 |
(i.e. single-character typing)" |
|
6478 |
||
6479 |
previousReplaceAction line == line ifTrue:[ |
|
6480 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
|
6481 |
^ true |
|
6482 |
]. |
|
6483 |
]. |
|
6484 |
||
6485 |
^ false |
|
6486 |
! |
|
6487 |
||
6488 |
combineWithNext:nextReplaceAction |
|
6489 |
self assert:(line == nextReplaceAction line). |
|
6490 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
6491 |
||
6492 |
col2 := nextReplaceAction col2. |
|
6493 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
6494 |
characters := characters , nextReplaceAction characters. |
|
6495 |
! ! |
|
6496 |
||
6497 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
6498 |
||
6499 |
executeIn:editor |
|
6500 |
editor |
|
6501 |
replaceString:characters |
|
6502 |
atLine:line |
|
6503 |
col:col1. |
|
6504 |
editor cursorLine:line col:col1. |
|
6505 |
! ! |
|
6506 |
||
3131 | 6507 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
6508 |
||
6509 |
text:something |
|
6510 |
text := something. |
|
6511 |
! ! |
|
6512 |
||
6513 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
6514 |
||
3160 | 6515 |
executeIn:editor |
3131 | 6516 |
editor contents:text |
6517 |
! ! |
|
6518 |
||
3130 | 6519 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
6520 |
||
3160 | 6521 |
line:lineArg string:stringArg |
3130 | 6522 |
line := lineArg. |
6523 |
text := stringArg. |
|
6524 |
! ! |
|
6525 |
||
6526 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
6527 |
||
3160 | 6528 |
executeIn:editor |
3130 | 6529 |
editor list at:line put:text. |
6530 |
editor invalidateLine:line |
|
6531 |
! ! |
|
6532 |
||
865 | 6533 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6534 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6535 |
version |
3303 | 6536 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.394 2006-04-07 17:43:13 cg Exp $' |
0 | 6537 |
! ! |