author | Claus Gittinger <cg@exept.de> |
Thu, 28 Feb 2008 10:34:57 +0100 | |
changeset 3566 | ec70ed6b09fa |
parent 3550 | 4d8ee421926c |
child 3569 | d3eec21d0ece |
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 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
0 | 14 |
TextView subclass:#EditTextView |
2724 | 15 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
16 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
17 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
2952 | 18 |
cursorTypeNoFocus typeOfSelection lastString lastReplacement |
19 |
lastAction replacing showMatchingParenthesis hasKeyboardFocus |
|
20 |
acceptAction lockUpdates tabMeansNextField autoIndent insertMode |
|
3235 | 21 |
editMode trimBlankLines wordWrap replacementWordSelectStyle |
22 |
acceptChannel acceptEnabled st80Mode disableIfInvisible |
|
2952 | 23 |
cursorMovementWhenUpdating learnMode learnedMacro |
3241 | 24 |
cursorLineHolder cursorColHolder tabRequiresControl undoSupport' |
2724 | 25 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
26 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
27 |
DefaultCursorTypeNoFocus' |
|
28 |
poolDictionaries:'' |
|
29 |
category:'Views-Text' |
|
0 | 30 |
! |
31 |
||
2952 | 32 |
Object subclass:#EditAction |
3115 | 33 |
instanceVariableNames:'userFriendlyInfo' |
2952 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
privateIn:EditTextView |
|
37 |
! |
|
38 |
||
39 |
EditTextView::EditAction subclass:#DeleteRange |
|
40 |
instanceVariableNames:'line1 col1 line2 col2' |
|
41 |
classVariableNames:'' |
|
42 |
poolDictionaries:'' |
|
43 |
privateIn:EditTextView |
|
44 |
! |
|
45 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
46 |
EditTextView::EditAction subclass:#DeleteCharacters |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
47 |
instanceVariableNames:'line col1 col2' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
48 |
classVariableNames:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
poolDictionaries:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
50 |
privateIn:EditTextView |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
51 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
|
3235 | 53 |
Object subclass:#EditMode |
54 |
instanceVariableNames:'' |
|
55 |
classVariableNames:'' |
|
56 |
poolDictionaries:'' |
|
57 |
privateIn:EditTextView |
|
58 |
! |
|
59 |
||
60 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
61 |
instanceVariableNames:'' |
|
62 |
classVariableNames:'' |
|
63 |
poolDictionaries:'' |
|
64 |
privateIn:EditTextView::EditMode |
|
65 |
! |
|
66 |
||
67 |
EditTextView::EditMode subclass:#InsertMode |
|
68 |
instanceVariableNames:'' |
|
69 |
classVariableNames:'' |
|
70 |
poolDictionaries:'' |
|
71 |
privateIn:EditTextView::EditMode |
|
72 |
! |
|
73 |
||
74 |
EditTextView::EditMode subclass:#OverwriteMode |
|
75 |
instanceVariableNames:'' |
|
76 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
77 |
poolDictionaries:'' |
|
78 |
privateIn:EditTextView::EditMode |
|
79 |
! |
|
80 |
||
2952 | 81 |
EditTextView::EditAction subclass:#PasteString |
82 |
instanceVariableNames:'line col string selected' |
|
83 |
classVariableNames:'' |
|
84 |
poolDictionaries:'' |
|
85 |
privateIn:EditTextView |
|
86 |
! |
|
87 |
||
88 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
89 |
instanceVariableNames:'line col character' |
|
90 |
classVariableNames:'' |
|
91 |
poolDictionaries:'' |
|
92 |
privateIn:EditTextView |
|
93 |
! |
|
94 |
||
3235 | 95 |
EditTextView::EditAction subclass:#ReplaceCharacters |
96 |
instanceVariableNames:'line col1 col2 characters' |
|
97 |
classVariableNames:'' |
|
98 |
poolDictionaries:'' |
|
99 |
privateIn:EditTextView |
|
100 |
! |
|
101 |
||
3131 | 102 |
EditTextView::EditAction subclass:#ReplaceContents |
103 |
instanceVariableNames:'text' |
|
104 |
classVariableNames:'' |
|
105 |
poolDictionaries:'' |
|
106 |
privateIn:EditTextView |
|
107 |
! |
|
108 |
||
3130 | 109 |
EditTextView::EditAction subclass:#ReplaceLine |
110 |
instanceVariableNames:'line text' |
|
111 |
classVariableNames:'' |
|
112 |
poolDictionaries:'' |
|
113 |
privateIn:EditTextView |
|
114 |
! |
|
115 |
||
3402 | 116 |
EditTextView::EditAction subclass:#ReplaceLines |
117 |
instanceVariableNames:'line text' |
|
118 |
classVariableNames:'' |
|
119 |
poolDictionaries:'' |
|
120 |
privateIn:EditTextView |
|
121 |
! |
|
122 |
||
865 | 123 |
!EditTextView class methodsFor:'documentation'! |
0 | 124 |
|
33 | 125 |
copyright |
126 |
" |
|
127 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3160 | 128 |
All Rights Reserved |
33 | 129 |
|
130 |
This software is furnished under a license and may be used |
|
131 |
only in accordance with the terms of that license and with the |
|
132 |
inclusion of the above copyright notice. This software may not |
|
133 |
be provided or otherwise made available to, or used by, any |
|
134 |
other person. No title to or ownership of the software is |
|
135 |
hereby transferred. |
|
136 |
" |
|
137 |
! |
|
138 |
||
0 | 139 |
documentation |
140 |
" |
|
141 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 142 |
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
|
143 |
acceptAction to be performed for accept |
125 | 144 |
|
145 |
If used with a model, this is informed by sending it a changeMsg with |
|
146 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
147 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 148 |
|
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
|
149 |
Please read the historic notice in the ListView class. |
0 | 150 |
|
586 | 151 |
[Instance variables:] |
0 | 152 |
|
3160 | 153 |
cursorLine <Number> line where cursor sits (1..) |
154 |
||
155 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
156 |
||
157 |
cursorCol <Number> col where cursor sits (1..) |
|
158 |
||
159 |
cursorShown <Boolean> true, if cursor is currently shown |
|
160 |
||
161 |
readOnly <Boolean> true, if text may not be edited |
|
162 |
||
163 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
164 |
cleared on accept. |
|
165 |
||
166 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
167 |
||
168 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
169 |
||
170 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
171 |
if it returns true, the modification will be done anyway. |
|
172 |
if it returns anything else, the modification is not done. |
|
173 |
||
174 |
cursorFgColor <Color> color used for cursor drawing |
|
175 |
cursorBgColor <Color> color used for cursor drawing |
|
176 |
||
177 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
178 |
are #block (solid-block cursor), #ibeam |
|
179 |
(vertical bar at insertion point) |
|
180 |
and #caret (caret below insertion-point) |
|
181 |
||
182 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
183 |
nil means: hide the cursor. |
|
184 |
||
185 |
undoAction <Block> block which undoes last cut, paste or replace |
|
186 |
(not yet fully implemented) |
|
187 |
||
188 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
189 |
this affects the next keyPress: if #paste it does not |
|
190 |
replace; otherwise it replaces the selection. |
|
191 |
||
192 |
lastCut <String> last cut or replaced string |
|
193 |
||
194 |
lastReplacement <String> last replacement |
|
195 |
||
196 |
replacing <Boolean> true if entered characters replace last selection |
|
197 |
||
198 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
199 |
when entering one; this is the default. |
|
200 |
||
201 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
202 |
||
203 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
204 |
argument |
|
205 |
||
206 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
207 |
focus to the next field. For editTextViews, this is false |
|
208 |
by default (i.e. tabs can be entered into the text). |
|
209 |
For some subclasses (inputFields), this may be true. |
|
210 |
||
211 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
212 |
removed when editing. |
|
213 |
Default is true. |
|
214 |
||
215 |
wordWrap <Boolean> Currently not used. |
|
216 |
||
217 |
lockUpdates <Boolean> internal, private |
|
218 |
||
219 |
prevCursorState <Boolean> temporary, private |
|
220 |
||
221 |
cursorMovementWhenUpdating |
|
222 |
<Symbol> defines where the cursor is to be positioned if the |
|
223 |
model changes its value by some outside activity |
|
224 |
(i.e. not by user input into the field). |
|
225 |
Can be one of: |
|
226 |
#keep / nil -> stay where it was |
|
227 |
#endOfText -> cursor to the end |
|
228 |
#endOfLine -> stay in the line, but move to end |
|
229 |
#beginOfText -> cursor to the beginning |
|
230 |
#beginOfLine -> stay in the line, but move to begin |
|
231 |
The default is #beginOfText |
|
232 |
||
233 |
||
234 |
||
235 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 236 |
|
237 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
238 |
userPreference values: |
3160 | 239 |
userPreferences.st80EditMode |
240 |
<Boolean> if true, cursor positioning is |
|
241 |
done as in vi or ST80; i.e. |
|
242 |
wysiwyg mode is somewhat relaxed, |
|
243 |
in that the cursor cannot be |
|
244 |
positioned behind a lines end. |
|
245 |
This is not yet completely implemented. |
|
33 | 246 |
used globals: |
247 |
||
3160 | 248 |
DeleteHistory <Text> last 1000 lines of deleted text |
249 |
(but only if this variable exists already) |
|
586 | 250 |
|
251 |
[styleSheet parameters:] |
|
121 | 252 |
|
3160 | 253 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
254 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
255 |
textCursorNoFocusForegroundColor |
|
256 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
257 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 258 |
|
259 |
[author:] |
|
3160 | 260 |
Claus Gittinger |
586 | 261 |
|
262 |
[see also:] |
|
3160 | 263 |
CodeView Workspace TextView ListView |
264 |
EditField |
|
0 | 265 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
266 |
! |
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 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
269 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
270 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
271 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
272 |
basic setup: |
3160 | 273 |
[exBegin] |
274 |
|top textView| |
|
275 |
||
276 |
top := StandardSystemView new. |
|
277 |
top extent:300@200. |
|
278 |
||
279 |
textView := EditTextView new. |
|
280 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
281 |
top addSubView:textView. |
|
282 |
||
283 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
284 |
||
285 |
top open. |
|
286 |
[exEnd] |
|
594 | 287 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
288 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
289 |
with vertical scrollbar: |
3160 | 290 |
[exBegin] |
291 |
|top scrollView textView| |
|
292 |
||
293 |
top := StandardSystemView new. |
|
294 |
top extent:300@200. |
|
295 |
||
296 |
scrollView := ScrollableView for:EditTextView. |
|
297 |
textView := scrollView scrolledView. |
|
298 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
299 |
top addSubView:scrollView. |
|
300 |
||
301 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
302 |
||
303 |
top open. |
|
304 |
[exEnd] |
|
594 | 305 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
306 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
307 |
with horizontal & vertical scrollbars: |
3160 | 308 |
[exBegin] |
309 |
|top scrollView textView| |
|
310 |
||
311 |
top := StandardSystemView new. |
|
312 |
top extent:300@200. |
|
313 |
||
314 |
scrollView := HVScrollableView for:EditTextView. |
|
315 |
textView := scrollView scrolledView. |
|
316 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
317 |
top addSubView:scrollView. |
|
318 |
||
319 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
320 |
||
321 |
top open. |
|
322 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
323 |
|
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 |
set the action for accept: |
3160 | 326 |
[exBegin] |
327 |
|top textView| |
|
328 |
||
329 |
top := StandardSystemView new. |
|
330 |
top extent:300@200. |
|
331 |
||
332 |
textView := EditTextView new. |
|
333 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
334 |
top addSubView:textView. |
|
335 |
||
336 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
337 |
textView acceptAction:[:contents | |
|
338 |
Transcript showCR:'will not overwrite the file with:'. |
|
339 |
Transcript showCR:contents asString |
|
340 |
]. |
|
341 |
top open. |
|
342 |
[exEnd] |
|
594 | 343 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
344 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
346 |
non-string (text) items: |
3160 | 347 |
[exBegin] |
348 |
|top textView list| |
|
349 |
||
350 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
351 |
1 to:list size by:2 do:[:nr | |
|
352 |
list at:nr put:(Text string:(list at:nr) |
|
353 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
354 |
]. |
|
355 |
||
356 |
top := StandardSystemView new. |
|
357 |
top extent:300@200. |
|
358 |
||
359 |
textView := EditTextView new. |
|
360 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
361 |
top addSubView:textView. |
|
362 |
||
363 |
textView contents:list. |
|
364 |
top open. |
|
365 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
366 |
|
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 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
369 |
MVC operation: |
594 | 370 |
(the examples model here is a plug simulating a real model; |
371 |
real world applications would not use a plug ..) |
|
3160 | 372 |
[exBegin] |
373 |
|top textView model| |
|
374 |
||
375 |
model := Plug new. |
|
376 |
model respondTo:#accepted: |
|
377 |
with:[:newContents | |
|
378 |
Transcript showCR:'will not overwrite the file with:'. |
|
379 |
Transcript showCR:newContents asString |
|
380 |
]. |
|
381 |
model respondTo:#getList |
|
382 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
383 |
||
384 |
||
385 |
top := StandardSystemView new. |
|
386 |
top extent:300@200. |
|
387 |
||
388 |
textView := EditTextView new. |
|
389 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
390 |
top addSubView:textView. |
|
391 |
||
392 |
textView listMessage:#getList; |
|
393 |
model:model; |
|
394 |
changeMessage:#accepted:; |
|
395 |
aspect:#list. |
|
396 |
top open. |
|
397 |
[exEnd] |
|
594 | 398 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
399 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
400 |
two textViews on the same model: |
3160 | 401 |
[exBegin] |
402 |
|top1 textView1 top2 textView2 model currentContents| |
|
403 |
||
404 |
model := Plug new. |
|
405 |
model respondTo:#accepted: |
|
406 |
with:[:newContents | |
|
407 |
Transcript showCR:'accepted:'. |
|
408 |
Transcript showCR:newContents asString. |
|
409 |
currentContents := newContents. |
|
410 |
model changed:#contents |
|
411 |
]. |
|
412 |
model respondTo:#getList |
|
413 |
with:[Transcript showCR:'query'. |
|
414 |
currentContents]. |
|
415 |
||
416 |
||
417 |
top1 := StandardSystemView new. |
|
418 |
top1 extent:300@200. |
|
419 |
||
420 |
textView1 := EditTextView new. |
|
421 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
422 |
top1 addSubView:textView1. |
|
423 |
||
424 |
textView1 listMessage:#getList; |
|
425 |
model:model; |
|
426 |
aspect:#contents; |
|
427 |
changeMessage:#accepted:. |
|
428 |
top1 open. |
|
429 |
||
430 |
top2 := StandardSystemView new. |
|
431 |
top2 extent:300@200. |
|
432 |
||
433 |
textView2 := EditTextView new. |
|
434 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
435 |
top2 addSubView:textView2. |
|
436 |
||
437 |
textView2 listMessage:#getList; |
|
438 |
model:model; |
|
439 |
aspect:#contents; |
|
440 |
changeMessage:#accepted:. |
|
441 |
top2 open. |
|
442 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
443 |
" |
0 | 444 |
! ! |
445 |
||
865 | 446 |
!EditTextView class methodsFor:'defaults'! |
59 | 447 |
|
1419 | 448 |
st80Mode |
449 |
"return true, if the st80 editing mode is turned on. |
|
450 |
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
|
451 |
beyond the end of a line or the end of the text." |
1419 | 452 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
453 |
^ UserPreferences current st80EditMode |
1419 | 454 |
|
455 |
" |
|
456 |
EditTextView st80Mode:true |
|
457 |
EditTextView st80Mode:false |
|
458 |
" |
|
459 |
||
460 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
461 |
! |
|
462 |
||
463 |
st80Mode:aBoolean |
|
464 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 465 |
beyond the end of a line or the last line" |
1419 | 466 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
467 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 468 |
|
469 |
" |
|
470 |
EditTextView st80Mode:true |
|
471 |
EditTextView st80Mode:false |
|
472 |
" |
|
473 |
||
474 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
475 |
! |
|
476 |
||
59 | 477 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
478 |
"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
|
479 |
|
1390 | 480 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
3160 | 481 |
#'textCursor.noFocusForegroundColor' |
482 |
#'textCursor.type' |
|
483 |
#'textCursor.typeNoFocus' |
|
484 |
#'editText.st80Mode')> |
|
1355 | 485 |
|
486 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
487 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
488 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
489 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
490 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
491 |
|
1419 | 492 |
" |
493 |
self updateStyleCache |
|
494 |
" |
|
495 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
496 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 497 |
! ! |
498 |
||
3431 | 499 |
!EditTextView class methodsFor:'specs'! |
500 |
||
501 |
searchReplaceDialogSpec |
|
502 |
"This resource specification was automatically generated |
|
503 |
by the UIPainter of ST/X." |
|
504 |
||
505 |
"Do not manually edit this!! If it is corrupted, |
|
506 |
the UIPainter may not be able to read the specification." |
|
507 |
||
508 |
" |
|
509 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
510 |
" |
|
511 |
||
512 |
<resource: #canvas> |
|
513 |
||
514 |
^ |
|
515 |
#(FullSpec |
|
516 |
name: searchReplaceDialogSpec |
|
517 |
window: |
|
518 |
(WindowSpec |
|
519 |
label: 'String Search and Replace' |
|
520 |
name: 'String Search and Replace' |
|
521 |
min: (Point 283 196) |
|
522 |
max: (Point 283 196) |
|
523 |
bounds: (Rectangle 0 0 279 192) |
|
524 |
) |
|
525 |
component: |
|
526 |
(SpecCollection |
|
527 |
collection: ( |
|
528 |
(LabelSpec |
|
529 |
label: 'Search Pattern:' |
|
530 |
name: 'label' |
|
531 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
532 |
level: 0 |
|
533 |
translateLabel: true |
|
534 |
adjust: left |
|
535 |
) |
|
536 |
(ComboBoxSpec |
|
537 |
name: 'patternComboBox' |
|
538 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
539 |
tabable: true |
|
540 |
model: searchPattern |
|
541 |
immediateAccept: false |
|
542 |
acceptOnLeave: true |
|
543 |
acceptOnReturn: true |
|
544 |
acceptOnTab: true |
|
545 |
acceptOnLostFocus: true |
|
546 |
acceptOnPointerLeave: false |
|
547 |
autoSelectInitialText: true |
|
548 |
comboList: patternList |
|
549 |
) |
|
550 |
(ComboBoxSpec |
|
551 |
name: 'replaceComboBox' |
|
552 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
553 |
tabable: true |
|
554 |
model: replacePattern |
|
555 |
immediateAccept: false |
|
556 |
acceptOnLeave: true |
|
557 |
acceptOnReturn: true |
|
558 |
acceptOnTab: true |
|
559 |
acceptOnLostFocus: true |
|
560 |
acceptOnPointerLeave: false |
|
561 |
autoSelectInitialText: true |
|
562 |
comboList: patternList |
|
563 |
) |
|
564 |
(CheckBoxSpec |
|
565 |
label: 'Ignore Case' |
|
566 |
name: 'ignoreCaseCheckBox' |
|
567 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
568 |
level: 0 |
|
569 |
tabable: true |
|
570 |
model: ignoreCase |
|
571 |
translateLabel: true |
|
572 |
) |
|
573 |
(VariableVerticalPanelSpec |
|
574 |
name: 'VariableVerticalPanel1' |
|
575 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
576 |
component: |
|
577 |
(SpecCollection |
|
578 |
collection: ( |
|
579 |
(HorizontalPanelViewSpec |
|
580 |
name: 'HorizontalPanel1' |
|
581 |
level: 0 |
|
582 |
horizontalLayout: fitSpace |
|
583 |
verticalLayout: center |
|
584 |
horizontalSpace: 3 |
|
585 |
verticalSpace: 3 |
|
586 |
ignoreInvisibleComponents: true |
|
587 |
reverseOrderIfOKAtLeft: true |
|
588 |
component: |
|
589 |
(SpecCollection |
|
590 |
collection: ( |
|
591 |
(ActionButtonSpec |
|
592 |
label: 'Replace' |
|
593 |
name: 'replaceButton' |
|
594 |
level: 2 |
|
595 |
translateLabel: true |
|
596 |
tabable: true |
|
597 |
model: replaceAction |
|
598 |
extent: (Point 134 21) |
|
599 |
) |
|
600 |
(ActionButtonSpec |
|
601 |
label: 'Replace All' |
|
602 |
name: 'replaceAllButton' |
|
603 |
level: 2 |
|
604 |
borderWidth: 1 |
|
605 |
translateLabel: true |
|
606 |
tabable: true |
|
607 |
model: replaceAllAction |
|
608 |
extent: (Point 134 21) |
|
609 |
) |
|
610 |
) |
|
611 |
||
612 |
) |
|
613 |
) |
|
614 |
(HorizontalPanelViewSpec |
|
615 |
name: 'horizontalPanelView' |
|
616 |
level: 0 |
|
617 |
horizontalLayout: fitSpace |
|
618 |
verticalLayout: center |
|
619 |
horizontalSpace: 3 |
|
620 |
verticalSpace: 3 |
|
621 |
ignoreInvisibleComponents: true |
|
622 |
reverseOrderIfOKAtLeft: true |
|
623 |
component: |
|
624 |
(SpecCollection |
|
625 |
collection: ( |
|
626 |
(ActionButtonSpec |
|
627 |
label: 'Cancel' |
|
628 |
name: 'cancelButton' |
|
629 |
level: 2 |
|
630 |
translateLabel: true |
|
631 |
tabable: true |
|
632 |
model: cancel |
|
633 |
extent: (Point 88 21) |
|
634 |
) |
|
635 |
(ActionButtonSpec |
|
636 |
label: 'Prev' |
|
637 |
name: 'prevButton' |
|
638 |
level: 2 |
|
639 |
translateLabel: true |
|
640 |
tabable: true |
|
641 |
model: prevAction |
|
642 |
extent: (Point 89 21) |
|
643 |
) |
|
644 |
(ActionButtonSpec |
|
645 |
label: 'Next' |
|
646 |
name: 'nextButton' |
|
647 |
level: 2 |
|
648 |
borderWidth: 1 |
|
649 |
translateLabel: true |
|
650 |
tabable: true |
|
651 |
model: nextAction |
|
652 |
isDefault: true |
|
653 |
extent: (Point 88 21) |
|
654 |
) |
|
655 |
) |
|
656 |
||
657 |
) |
|
658 |
) |
|
659 |
) |
|
660 |
||
661 |
) |
|
662 |
handles: (Any 0.5 1.0) |
|
663 |
) |
|
664 |
(LabelSpec |
|
665 |
label: 'Replace By:' |
|
666 |
name: 'ReplaceLabel' |
|
667 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
668 |
level: 0 |
|
669 |
translateLabel: true |
|
670 |
adjust: left |
|
671 |
) |
|
672 |
) |
|
673 |
||
674 |
) |
|
675 |
) |
|
676 |
||
677 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
678 |
! ! |
|
679 |
||
2744 | 680 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
681 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
682 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
683 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
684 |
|
2019 | 685 |
"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
|
686 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
687 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
688 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
689 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
690 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
691 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
692 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
693 |
|
1390 | 694 |
cutSelection |
695 |
self cut |
|
696 |
||
697 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
698 |
! |
|
699 |
||
1590 | 700 |
deselect |
701 |
"remove the selection" |
|
702 |
||
703 |
^ self unselect |
|
704 |
||
705 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
706 |
! |
|
707 |
||
2101 | 708 |
enabled:aBoolean |
709 |
||
710 |
self readOnly:aBoolean not |
|
711 |
||
712 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
713 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
714 |
! |
|
715 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
716 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
717 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
718 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
719 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
720 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
721 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
722 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
723 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
724 |
"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
|
725 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
726 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
727 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
728 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
729 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
730 |
col < 1 ifTrue:[ |
3160 | 731 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
732 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
733 |
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
|
734 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
735 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
736 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
737 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
738 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
739 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
740 |
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
|
741 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
742 |
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
|
743 |
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
|
744 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
745 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
746 |
"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
|
747 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
748 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
749 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
750 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
751 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
752 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
753 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
754 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 755 |
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
|
756 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
757 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 758 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
759 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
760 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
761 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
762 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
763 |
v insertAndSelect:'<- hello there' at:5. |
125 | 764 |
" |
1390 | 765 |
! |
766 |
||
767 |
pasteSelection |
|
768 |
self paste |
|
769 |
||
770 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 771 |
! |
772 |
||
773 |
replaceSelectionWith:aString |
|
774 |
^ self replaceSelectionBy:aString |
|
775 |
||
776 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
777 |
! |
|
778 |
||
779 |
selectAt:pos |
|
780 |
"move the cursor before cursorPosition." |
|
781 |
||
782 |
self cursorToCharacterPosition:pos |
|
783 |
||
784 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
785 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
786 |
! |
|
787 |
||
788 |
selectFrom:startPos to:endPos |
|
789 |
"change the selection given two aCharacterPositions." |
|
790 |
||
791 |
|line1 col1 line2 col2| |
|
792 |
||
793 |
startPos > endPos ifTrue:[ |
|
3160 | 794 |
^ self unselect |
1590 | 795 |
]. |
796 |
||
797 |
line1 := self lineOfCharacterPosition:startPos. |
|
798 |
col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1. |
|
799 |
col1 < 1 ifTrue:[ |
|
3160 | 800 |
col1 := 1 |
1590 | 801 |
]. |
802 |
line2 := self lineOfCharacterPosition:endPos. |
|
803 |
col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1. |
|
804 |
col2 < 1 ifTrue:[ |
|
3160 | 805 |
col2 := 1 |
1590 | 806 |
]. |
807 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
808 |
||
809 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
2101 | 810 |
! |
811 |
||
812 |
textHasChanged |
|
813 |
^ self modified |
|
814 |
||
815 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
816 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
817 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
818 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
819 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
820 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
821 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
822 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
823 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
824 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
825 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
826 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
827 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
828 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
829 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
830 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
831 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
832 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
833 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
834 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
835 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
836 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
837 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
838 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
839 |
|
2792 | 840 |
acceptChannel |
841 |
"return the valueHolder holding true if text was accepted. |
|
842 |
By placing a true into this channel, an accept can also be forced." |
|
843 |
||
844 |
^ acceptChannel |
|
845 |
||
846 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
847 |
! |
|
848 |
||
849 |
acceptChannel:aValueHolder |
|
850 |
"set the valueHolder holding true if text was accepted. |
|
851 |
By placing a true into this channel, an accept can also be forced." |
|
852 |
||
853 |
|prev| |
|
854 |
||
855 |
prev := acceptChannel. |
|
856 |
acceptChannel := aValueHolder. |
|
857 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
858 |
||
859 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
860 |
! |
|
861 |
||
1108 | 862 |
acceptEnabled:aBoolean |
863 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
864 |
||
865 |
acceptEnabled := aBoolean |
|
866 |
||
867 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
868 |
! |
|
869 |
||
2792 | 870 |
accepted |
871 |
"return true if text was accepted" |
|
872 |
||
873 |
^ acceptChannel value |
|
874 |
||
875 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
876 |
! |
|
877 |
||
878 |
accepted:aBoolean |
|
879 |
"set/clear the accepted flag. |
|
880 |
This may force my current contents to be placed into my model." |
|
881 |
||
882 |
acceptChannel value:aBoolean. |
|
883 |
||
884 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
885 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
886 |
! |
|
887 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
888 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
889 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
890 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
891 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
892 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
893 |
|
2774 | 894 |
cursorMovementWhenUpdating |
3160 | 895 |
"return what is be done with the cursor, |
2774 | 896 |
when I get a new text (via the model or the #contents/#list) |
897 |
Allowed arguments are: |
|
3160 | 898 |
#keep / nil -> stay where it was |
899 |
#endOfText -> position cursor to the end |
|
900 |
#beginOfText -> position cursor to the beginning |
|
901 |
#endOfLine -> position cursor to the current lines end |
|
902 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 903 |
The default is #beginOfText. |
904 |
This may be useful for fields which get new values assigned from |
|
905 |
the program (i.e. not from the user)" |
|
906 |
||
907 |
^ cursorMovementWhenUpdating |
|
908 |
||
909 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
910 |
! |
|
911 |
||
2133 | 912 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 913 |
"define what should be done with the cursor, |
2133 | 914 |
when I get a new text (via the model or the #contents/#list) |
915 |
Allowed arguments are: |
|
3160 | 916 |
#keep / nil -> stay where it was |
917 |
#endOfText -> position cursor to the end |
|
918 |
#beginOfText -> position cursor to the beginning |
|
919 |
#endOfLine -> position cursor to the current lines end |
|
920 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 921 |
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
|
922 |
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
|
923 |
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
|
924 |
|
2133 | 925 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
926 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
927 |
"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
|
928 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
929 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
930 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
931 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
932 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
933 |
|
2438 | 934 |
dontReplaceSelectionOnInput |
935 |
typeOfSelection := #paste |
|
936 |
! |
|
937 |
||
3235 | 938 |
editModeHolder |
939 |
^ editMode. |
|
940 |
! |
|
941 |
||
942 |
editModeInsert |
|
943 |
editMode value:EditMode insertMode |
|
944 |
! |
|
945 |
||
946 |
editModeInsertAndSelect |
|
947 |
editMode value:EditMode insertAndSelectMode |
|
948 |
! |
|
949 |
||
950 |
editModeOverwrite |
|
951 |
editMode value:EditMode overwriteMode |
|
952 |
! |
|
953 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
954 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
"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
|
956 |
readonly text" |
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 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
959 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
960 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
961 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
962 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
963 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
964 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
965 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
966 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
967 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
968 |
readOnly == true ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
969 |
readOnly := true. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
970 |
middleButtonMenu notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
971 |
middleButtonMenu disableAll:#(cut paste replace indent) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
972 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
973 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
974 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
975 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
976 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
977 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
978 |
insertMode:aBoolean |
3235 | 979 |
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
|
980 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
981 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
982 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
983 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
984 |
insertModeHolder |
3235 | 985 |
^ BlockValue |
3465 | 986 |
with:[:m | m isInsertMode] |
3235 | 987 |
argument:(editMode). |
3465 | 988 |
|
989 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 990 |
! |
991 |
||
992 |
isInInsertMode |
|
993 |
^ editMode value isInsertMode |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
994 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
995 |
|
2792 | 996 |
isReadOnly |
997 |
"return true, if the text is readonly." |
|
998 |
||
999 |
^ readOnly value |
|
1000 |
||
1001 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1002 |
! |
|
1003 |
||
2796 | 1004 |
modeLabelHolder |
1005 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1006 |
||
3160 | 1007 |
^ BlockValue |
3235 | 1008 |
with:[:e :l | |
1009 |
self isReadOnly ifTrue:[ |
|
1010 |
'' |
|
1011 |
] ifFalse:[ |
|
3465 | 1012 |
l ifTrue:[ 'L' asText allBold colorizeAllWith:Color red] |
1013 |
ifFalse:[ e infoPrintString]]] |
|
3235 | 1014 |
argument:(self editModeHolder) |
1015 |
argument:(self learnModeHolder). |
|
3465 | 1016 |
|
1017 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1018 |
! |
1019 |
||
2792 | 1020 |
modified |
1021 |
"return true if text was modified" |
|
1022 |
||
1023 |
^ modifiedChannel value |
|
1024 |
! |
|
1025 |
||
1026 |
modified:aBoolean |
|
1027 |
"set/clear the modified flag" |
|
1028 |
||
1029 |
modifiedChannel value:aBoolean |
|
1030 |
||
1031 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1032 |
! |
|
1033 |
||
1034 |
modifiedChannel |
|
1035 |
"return the valueHolder holding true if text was modified" |
|
1036 |
||
1037 |
^ modifiedChannel |
|
1038 |
! |
|
1039 |
||
1040 |
modifiedChannel:aValueHolder |
|
1041 |
"set the valueHolder holding true if text was modified" |
|
1042 |
||
1043 |
|prev| |
|
1044 |
||
1045 |
prev := modifiedChannel. |
|
1046 |
modifiedChannel := aValueHolder. |
|
1047 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1048 |
||
1049 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1050 |
! |
|
1051 |
||
1052 |
readOnly |
|
1053 |
"make the text readonly. |
|
1054 |
Somewhat obsolete - use #readOnly:" |
|
1055 |
||
1056 |
<resource:#obsolete> |
|
1057 |
||
1058 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
1059 |
readOnly := true |
|
1060 |
||
1061 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1062 |
! |
|
1063 |
||
1064 |
readOnly:aBoolean |
|
1065 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1066 |
The argument may also be a valueHolder." |
|
1067 |
||
1068 |
readOnly := aBoolean |
|
1069 |
||
1070 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1071 |
! |
|
1072 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1073 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1074 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1075 |
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
|
1076 |
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
|
1077 |
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
|
1078 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1079 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1080 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1081 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1082 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1083 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1084 |
"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
|
1085 |
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
|
1086 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1087 |
|
3160 | 1088 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1089 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1090 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1091 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1092 |
"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
|
1093 |
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
|
1094 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1095 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1096 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1097 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1098 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1099 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1100 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1101 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1102 |
"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
|
1103 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1104 |
(self at:lineNr) = aLine ifFalse:[ |
3160 | 1105 |
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
|
1106 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1107 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1108 |
|
522 | 1109 |
at:lineNr put:aLine |
1110 |
(self at:lineNr) = aLine ifFalse:[ |
|
3160 | 1111 |
super at:lineNr put:aLine. |
1112 |
self textChanged |
|
522 | 1113 |
]. |
1114 |
! |
|
1115 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1116 |
characterBeforeCursor |
2707 | 1117 |
"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
|
1118 |
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
|
1119 |
of the insertion-bar or caret." |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1120 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1121 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1122 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1123 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1124 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1125 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1126 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1127 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1128 |
characterUnderCursor |
2707 | 1129 |
"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
|
1130 |
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
|
1131 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1132 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1133 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1134 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1135 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1136 |
contents |
2213 | 1137 |
"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
|
1138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1139 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1140 |
self removeTrailingBlankLines. |
3313 | 1141 |
^ super contents. |
1142 |
"/ ^ list asStringWithCRs |
|
1143 |
||
1144 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1145 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1146 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1147 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1148 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1149 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1150 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1151 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1152 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1153 |
keepUndoHistory ifFalse:[ |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1154 |
undoSupport resetHistories. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1155 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1156 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1157 |
|
2213 | 1158 |
contentsAsString |
1159 |
"return the contents as a String (i.e. without emphasis)" |
|
1160 |
||
1161 |
list isNil ifTrue:[^ '']. |
|
1162 |
self removeTrailingBlankLines. |
|
1163 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
3160 | 1164 |
ifFalse:[each string] |
1165 |
]) asStringWithCRs |
|
2213 | 1166 |
! |
1167 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1168 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1169 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1170 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1171 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1172 |
^ cursorCol |
125 | 1173 |
! |
1174 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1175 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1176 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1177 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1178 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1179 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1180 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1181 |
cursorLine |
3160 | 1182 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1183 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1185 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1186 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1187 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1188 |
cursorLineHolder |
3160 | 1189 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1190 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1191 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1192 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1193 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1194 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1195 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1196 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1197 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1198 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1199 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1200 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1201 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1202 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1203 |
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
|
1204 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1205 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1206 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1207 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1208 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1209 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1210 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1211 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1212 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1213 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1214 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1215 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1216 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1217 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1218 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1219 |
^ 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
|
1220 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1221 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1222 |
"/ 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
|
1223 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1224 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1225 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1226 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1227 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1228 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1229 |
undoSupport resetHistories. |
2955 | 1230 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1231 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1232 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1233 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1234 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1235 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1236 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1237 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1238 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1239 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1240 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1241 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1242 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1243 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1244 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1245 |
wasOn := self hideCursor. |
1993 | 1246 |
cursorFgColor := color1 onDevice:device. |
1247 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1248 |
wasOn ifTrue:[self showCursor] |
1333 | 1249 |
! |
1250 |
||
1899 | 1251 |
cursorType |
1252 |
"return the style of the text cursor. |
|
1253 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1254 |
#bigCaret and #bigSolidCaret" |
1899 | 1255 |
|
1256 |
^ cursorType |
|
1257 |
||
1258 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1259 |
! |
|
1260 |
||
1333 | 1261 |
cursorType:aCursorTypeSymbol |
1262 |
"set the style of the text cursor. |
|
1263 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1264 |
#bigCaret and #bigSolidCaret" |
1333 | 1265 |
|
1334 | 1266 |
cursorType := aCursorTypeSymbol. |
1333 | 1267 |
|
1268 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1269 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1270 |
! |
1271 |
||
1899 | 1272 |
cursorTypeNoFocus |
1273 |
"return the style of the text cursor when the view has no focus. |
|
1274 |
If left unspecified, this is the same as the regular cursorType." |
|
1275 |
||
1276 |
^ cursorTypeNoFocus |
|
1277 |
||
1278 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1279 |
! |
|
1280 |
||
1334 | 1281 |
cursorTypeNoFocus:aCursorTypeSymbol |
1282 |
"set the style of the text cursor when the view has no focus. |
|
1283 |
If left unspecified, this is the same as the regular cursorType." |
|
1284 |
||
1285 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1286 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1287 |
|
2119 | 1288 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1289 |
|
125 | 1290 |
accept |
1291 |
"accept the current contents by executing the accept-action and/or |
|
1292 |
changeMessage." |
|
1293 |
||
1108 | 1294 |
acceptEnabled == false ifTrue:[ |
3160 | 1295 |
self beep. |
1296 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1297 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1298 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3160 | 1299 |
^ self |
1108 | 1300 |
]. |
1301 |
||
125 | 1302 |
lockUpdates := true. |
1013 | 1303 |
|
1304 |
"/ |
|
1305 |
"/ ST-80 way of doing it |
|
1306 |
"/ |
|
1307 |
model notNil ifTrue:[ |
|
3160 | 1308 |
self sendChangeMessageWith:self argForChangeMessage. |
1013 | 1309 |
]. |
1310 |
||
2999 | 1311 |
model notNil ifTrue:[ |
3160 | 1312 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1313 |
]. |
1314 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1315 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1316 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1317 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1318 |
"/ 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
|
1319 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1320 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1321 |
acceptAction notNil ifTrue:[ |
3160 | 1322 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1323 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1324 |
|
125 | 1325 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1326 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1327 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1328 |
! |
1329 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1330 |
argForChangeMessage |
597 | 1331 |
"return the argument to be passed with the change notification. |
1332 |
Defined as separate method for easier subclassability." |
|
1333 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1334 |
^ self contents |
597 | 1335 |
|
1336 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1337 |
! |
1338 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1339 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1340 |
"get my contents from the model. |
597 | 1341 |
Redefined to ignore updates resulting from my own changes |
1342 |
(i.e. if lockUpdates is true)." |
|
121 | 1343 |
|
1344 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1345 |
ignore updates from my own change |
121 | 1346 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1347 |
lockUpdates ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1348 |
lockUpdates := false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1349 |
^ self |
121 | 1350 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1351 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1352 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1353 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1354 |
"/ validate the cursorLine |
3160 | 1355 |
(cursorLine notNil |
2310 | 1356 |
and:[ cursorLine > list size ]) ifTrue:[ |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1357 |
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
|
1358 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1359 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1360 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1361 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1362 |
changedObject == acceptChannel ifTrue:[ |
3160 | 1363 |
acceptChannel value == true ifTrue:[ |
1364 |
self accept. |
|
1365 |
]. |
|
1366 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1367 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1368 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1369 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1370 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1371 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1372 |
! ! |
1373 |
||
1374 |
!EditTextView methodsFor:'cursor handling'! |
|
1375 |
||
2406 | 1376 |
characterPositionOfCursor |
1377 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1378 |
! |
|
1379 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1380 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1381 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1383 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1384 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1385 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1386 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1387 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1388 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1389 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1390 |
|
2822 | 1391 |
(cursorCol == newCol) ifTrue:[^ self]. |
1392 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1393 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1394 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1395 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1396 |
|
1397 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1398 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1399 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1400 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1401 |
"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
|
1402 |
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
|
1403 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1404 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1405 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1406 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1407 |
|
2707 | 1408 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1409 |
cursorLine > list size ifTrue:[ |
3160 | 1410 |
wasOn := self hideCursor. |
1411 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1412 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1413 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1414 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1415 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1416 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1417 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1419 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1420 |
"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
|
1421 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1422 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1423 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1424 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1425 |
wasOn := self hideCursor. |
1426 |
nv := cursorVisibleLine + n - 1. |
|
1427 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1428 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1429 |
]. |
|
1430 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1431 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1432 |
] ifFalse:[ |
3160 | 1433 |
(nL := cursorLine) isNil ifTrue:[ |
1434 |
nL := firstLineShown |
|
1435 |
]. |
|
1436 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
|
1437 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1438 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1439 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1440 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
|
121 | 1443 |
cursorHome |
597 | 1444 |
"scroll to top AND move cursor to first line of text." |
121 | 1445 |
|
674 | 1446 |
self cursorLine:1 col:1 |
1447 |
||
1448 |
"/ |wasOn| |
|
1449 |
"/ |
|
1450 |
"/ wasOn := self hideCursor. |
|
1451 |
"/ self scrollToTop. |
|
1452 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1453 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1454 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1455 |
||
1456 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1457 |
! |
1458 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1459 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1460 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1461 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1462 |
(cursorCol ~~ 1) ifTrue:[ |
3160 | 1463 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1464 |
] ifFalse:[ |
3160 | 1465 |
cursorLine ~~ 1 ifTrue:[ |
1466 |
self st80EditMode ifTrue:[ |
|
1467 |
self cursorUp. |
|
1468 |
self cursorToEndOfLine. |
|
1469 |
] |
|
1470 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1471 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1472 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1473 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1474 |
! |
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 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1477 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1478 |
|
676 | 1479 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1480 |
|
2822 | 1481 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1482 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1483 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1484 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1485 |
|
672 | 1486 |
(col < 1) ifTrue:[ |
3160 | 1487 |
newCol := 1 |
672 | 1488 |
] ifFalse:[ |
3160 | 1489 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1490 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1491 |
self st80EditMode ifTrue:[ |
3160 | 1492 |
(cursorLine == list size |
1493 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1494 |
newCol := (self listAt:(list size)) size + 1. |
|
1495 |
] |
|
1419 | 1496 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1497 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1498 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1499 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1500 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1501 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1502 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1503 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1504 |
"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
|
1505 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1506 |
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
|
1507 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1508 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1509 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1510 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1511 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1512 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1513 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1514 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1515 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1516 |
"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
|
1517 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1518 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1519 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1520 |
self checkForExistingLine:(cursorLine + 1). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1521 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1522 |
nFullLinesShown notNil ifTrue:[ |
1523 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1524 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1525 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1526 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1527 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1528 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1529 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1530 |
|
674 | 1531 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1532 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1533 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1534 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1535 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1536 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1537 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1538 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1539 |
self st80EditMode ifTrue:[ |
3160 | 1540 |
l := (self listAt:cursorLine). |
1541 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1542 |
cursorLine < list size ifTrue:[ |
|
1543 |
self cursorReturn. |
|
1544 |
]. |
|
1545 |
^ self |
|
1546 |
] |
|
1547 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1548 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1549 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1550 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1551 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1552 |
|
1833 | 1553 |
cursorShown:aBoolean |
1554 |
"change cursor visibility |
|
1555 |
return true if cursor was visible before." |
|
1556 |
||
1557 |
|oldState| |
|
1558 |
||
1559 |
oldState := cursorShown. |
|
1560 |
||
1561 |
aBoolean ifTrue:[ |
|
3160 | 1562 |
self drawCursor. |
1833 | 1563 |
] ifFalse:[ |
3160 | 1564 |
(cursorShown and:[shown]) ifTrue: [ |
1565 |
self undrawCursor. |
|
1566 |
]. |
|
1833 | 1567 |
]. |
1568 |
cursorShown := aBoolean. |
|
1569 |
||
1570 |
^ oldState |
|
1571 |
||
1572 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1573 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1574 |
! |
|
1575 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1576 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1577 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1578 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1579 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1580 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1581 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1582 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1583 |
"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
|
1584 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1585 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1586 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1587 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1588 |
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
|
1589 |
cursorCol > textStart ifTrue:[ |
3160 | 1590 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1591 |
] ifFalse:[ |
3160 | 1592 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1593 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1594 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1595 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1596 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1597 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1598 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1599 |
"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
|
1600 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1601 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1602 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1603 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1604 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1605 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1606 |
(newTop < 1) ifTrue:[ |
3160 | 1607 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1608 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1610 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1611 |
self setValidatedCursorLine:(list size) col:1. |
259
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 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1614 |
|
674 | 1615 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
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 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1618 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1619 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1620 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1621 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1622 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1623 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1624 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1625 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1626 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1627 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1628 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1629 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1630 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1631 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1632 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1633 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1634 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1635 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1636 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1637 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1638 |
cursorLine >= lineNr ifTrue:[ |
3238
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1639 |
line := self listAt:cursorLine. |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1640 |
(line isEmptyOrNil) ifTrue:[ |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1641 |
^ self |
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1642 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1643 |
]. |
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 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1646 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1647 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1648 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1649 |
(newTop < 1) ifTrue:[ |
3238
7b868226a0c0
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
3236
diff
changeset
|
1650 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1651 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1652 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1653 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1654 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1655 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1656 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1657 |
|
674 | 1658 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1659 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1660 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1661 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1662 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1663 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1664 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1665 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1666 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1667 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1668 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1669 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1670 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1671 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1672 |
cursorToEndOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1673 |
"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
|
1674 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1675 |
|wasOn newTop| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1676 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1677 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1678 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1679 |
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
|
1680 |
(newTop < 1) ifTrue:[ |
3160 | 1681 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1682 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1683 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1684 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1685 |
self setValidatedCursorLine:list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1686 |
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
|
1687 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1688 |
self makeCursorVisibleAndShowCursor:wasOn. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1689 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1690 |
|
3310 | 1691 |
cursorToEndOfWord |
1692 |
"move the cursor to the end of the word" |
|
1693 |
||
1694 |
(cursorLine > list size) ifTrue:[^ self]. |
|
1695 |
||
1696 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
1697 |
:beginLine :beginCol :endLine :endCol :style | |
|
1698 |
||
1699 |
self cursorLine:endLine col:endCol+1 |
|
1700 |
] |
|
1701 |
||
1702 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
1703 |
! |
|
1704 |
||
131 | 1705 |
cursorToFirstVisibleLine |
1706 |
"place cursor into the first visible line; do not scroll." |
|
1707 |
||
1708 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1709 |
! |
|
1710 |
||
1711 |
cursorToLastVisibleLine |
|
1712 |
"place cursor into the first visible line; do not scroll." |
|
1713 |
||
1714 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1715 |
! |
|
1716 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1717 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1718 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1720 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1721 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1722 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1723 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1724 |
self wordAtLine:cursorLine col:cursorCol do:[ |
3160 | 1725 |
:beginLine :beginCol :endLine :endCol :style | |
1726 |
||
1727 |
line := endLine. |
|
1728 |
col := endCol + 1. |
|
1729 |
searching := true. |
|
1730 |
[searching |
|
1731 |
and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
1732 |
self wordAtLine:line col:col do:[ |
|
1733 |
:beginLine :beginCol :endLine :endCol :style | |
|
1734 |
||
1735 |
(line > list size) ifTrue:[ |
|
1736 |
"break out" |
|
1737 |
searching := false |
|
1738 |
] ifFalse:[ |
|
1739 |
line := endLine. |
|
1740 |
col := endCol + 1. |
|
1741 |
] |
|
1742 |
] |
|
1743 |
]. |
|
1744 |
self cursorLine:line col:col |
|
121 | 1745 |
] |
1746 |
! |
|
1747 |
||
499 | 1748 |
cursorToPreviousWord |
1749 |
"move the cursor to the beginning of this or the previous word" |
|
1750 |
||
1751 |
|col line searching l| |
|
1752 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1753 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1754 |
|
1755 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
3160 | 1756 |
:beginLine :beginCol :endLine :endCol :style | |
1757 |
||
1758 |
line := beginLine. |
|
1759 |
col := beginCol. |
|
1760 |
style == #wordLeft ifTrue:[ |
|
1761 |
col := col + 1 |
|
1762 |
]. |
|
1763 |
||
1764 |
(cursorLine == line |
|
1765 |
and:[cursorCol == col]) ifTrue:[ |
|
1766 |
searching := true. |
|
1767 |
||
1768 |
col > 1 ifTrue:[ |
|
1769 |
col := col - 1. |
|
1770 |
]. |
|
1771 |
||
1772 |
[searching] whileTrue:[ |
|
1773 |
(col == 1) ifTrue:[ |
|
1774 |
line == 1 ifTrue:[ |
|
1775 |
searching := false |
|
1776 |
] ifFalse:[ |
|
1777 |
line := line - 1. |
|
1778 |
l := list at:line. |
|
1779 |
col := l size + 1. |
|
1780 |
] |
|
1781 |
] ifFalse:[ |
|
1782 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
1783 |
self wordAtLine:line col:col do:[ |
|
1784 |
:beginLine :beginCol :endLine :endCol :style | |
|
1785 |
||
1786 |
line := beginLine. |
|
1787 |
col := beginCol. |
|
1788 |
style == #wordLeft ifTrue:[ |
|
1789 |
col := col + 1 |
|
1790 |
]. |
|
1791 |
searching := false. |
|
1792 |
] |
|
1793 |
] ifTrue:[ |
|
1794 |
col := col - 1 |
|
1795 |
] |
|
1796 |
] |
|
1797 |
] |
|
1798 |
]. |
|
1799 |
self cursorLine:line col:col |
|
499 | 1800 |
] |
1801 |
||
1802 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
1803 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
1804 |
! |
|
1805 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1806 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1807 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1808 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1809 |
self cursorLine:1 col:1 |
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 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1813 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1814 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1815 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1816 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1817 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1818 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1819 |
"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
|
1820 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1821 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1822 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1823 |
cursorLine isNil ifTrue:[ |
3160 | 1824 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1825 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1826 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1827 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1828 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1829 |
(nl ~~ cursorLine) ifTrue: [ |
3160 | 1830 |
wasOn := self hideCursor. |
1831 |
cursorVisibleLine notNil ifTrue:[ |
|
1832 |
nv := cursorVisibleLine - n. |
|
1833 |
nv < 1 ifTrue:[ |
|
1834 |
self scrollUp:(nv negated + 1) |
|
1835 |
]. |
|
1836 |
]. |
|
1837 |
self setValidatedCursorLine:nl col:cursorCol. |
|
1838 |
wasOn ifTrue:[self showCursor]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1839 |
] |
672 | 1840 |
|
674 | 1841 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
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 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1846 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1847 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1848 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1850 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1851 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1852 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1853 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1854 |
|
676 | 1855 |
newCol := colNr. |
1856 |
(newCol < 1) ifTrue:[ |
|
3160 | 1857 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1858 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1859 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1860 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1861 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1862 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
1863 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1864 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1865 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1866 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1867 |
"put cursor to position next to x/y coordinate in view" |
121 | 1868 |
|
1869 |
|line col| |
|
1870 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1871 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1872 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1873 |
self cursorVisibleLine:line col:col. |
121 | 1874 |
! |
1875 |
||
1876 |
drawCursor |
|
1877 |
"draw the cursor if shown and cursor is visible. |
|
1878 |
(but not, if there is a selection - to avoid confusion)" |
|
1879 |
||
1880 |
shown ifTrue:[ |
|
3160 | 1881 |
cursorVisibleLine notNil ifTrue:[ |
1882 |
self hasSelection ifFalse:[ |
|
1883 |
self drawCursorCharacter |
|
1884 |
] |
|
1885 |
] |
|
121 | 1886 |
] |
1887 |
! |
|
1888 |
||
1889 |
drawCursor:cursorType with:fgColor and:bgColor |
|
1890 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 1891 |
of cursor should be drawn. |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
1892 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
3160 | 1893 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
1894 |
|
2570 | 1895 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 1896 |
|
1897 |
self hasSelection ifTrue:[ |
|
3160 | 1898 |
" |
1899 |
hide cursor, if there is a selection |
|
1900 |
" |
|
1901 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 1902 |
]. |
1903 |
||
1334 | 1904 |
cursorType == #none ifTrue:[ |
3160 | 1905 |
^ self |
1334 | 1906 |
]. |
1907 |
||
121 | 1908 |
cursorType == #block ifTrue:[ |
3160 | 1909 |
super drawVisibleLine:cursorVisibleLine |
1910 |
col:cursorCol |
|
1911 |
with:fgColor |
|
1912 |
and:bgColor. |
|
1913 |
^ self |
|
121 | 1914 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
1915 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 1916 |
y := self yOfVisibleLine:cursorVisibleLine. |
1917 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
1918 |
oldPaint := self paint. "/ do not clobber GC |
121 | 1919 |
cursorType == #frame ifTrue:[ |
3160 | 1920 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1921 |
||
1922 |
char := self characterUnderCursor asString. |
|
1923 |
self paint:bgColor. |
|
1924 |
self displayRectangleX:x y:y |
|
1925 |
width:(font widthOf:char) height:fontHeight. |
|
133 | 1926 |
] ifFalse:[ |
3160 | 1927 |
self paint:bgColor. |
1928 |
cursorType == #ibeam ifTrue:[ |
|
1929 |
x1 := x - 1. |
|
1930 |
y2 := y + fontHeight - 1. |
|
1931 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
1932 |
self displayLineFromX:x y:y toX:x y:y2. |
|
1933 |
^ self |
|
1934 |
]. |
|
1935 |
||
1936 |
cursorType == #Ibeam ifTrue:[ |
|
1937 |
x1 := x - 1. |
|
1938 |
y := y + 1. |
|
1939 |
y2 := y + fontHeight - 1. |
|
1940 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
1941 |
self displayLineFromX:x y:y toX:x y:y2. |
|
1942 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
1943 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
1944 |
^ self |
|
1945 |
]. |
|
1946 |
||
1947 |
y := y + fontHeight - 3. |
|
1948 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
1949 |
w := (fontWidth * 2 // 3) max:4. |
|
1950 |
y2 := y + w + (w//2). |
|
1951 |
] ifFalse:[ |
|
1952 |
w := (fontWidth // 2) max:4. |
|
1953 |
y2 := y + w. |
|
1954 |
]. |
|
1955 |
x1 := x - w. |
|
1956 |
x2 := x + w. |
|
1957 |
||
1958 |
oldClip := self clippingRectangleOrNil. |
|
1959 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
1960 |
||
1961 |
cursorType == #caret ifTrue:[ |
|
1962 |
self lineWidth:2. |
|
1963 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
1964 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
1965 |
] ifFalse:[ |
|
1966 |
"anything else: solidCaret" |
|
1967 |
||
1968 |
self fillPolygon:(Array with:(x1 @ y2) |
|
1969 |
with:(x @ y) |
|
1970 |
with:(x2 @ y2)) |
|
1971 |
]. |
|
1972 |
||
1973 |
self clippingRectangle:oldClip |
|
121 | 1974 |
]. |
133 | 1975 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
1976 |
|
2088 | 1977 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 1978 |
! |
1979 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1980 |
drawCursorCharacter |
3160 | 1981 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1984 |
|
3160 | 1985 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1986 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1987 |
and:[self isReadOnly not]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1988 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1989 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1990 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1992 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
1993 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1996 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1997 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1998 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1999 |
self hasSelection ifTrue:[ |
3160 | 2000 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 2001 |
]. |
2002 |
cursorType == #none ifTrue:[ |
|
3160 | 2003 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2004 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2005 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2006 |
|
2007 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2008 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2009 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2010 |
drawNoFocusCursor |
3160 | 2011 |
"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
|
2012 |
|
1334 | 2013 |
|cType| |
2014 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2015 |
self hasSelection ifTrue:[ |
3160 | 2016 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2017 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2018 |
|
1334 | 2019 |
cType := cursorTypeNoFocus ? cursorType. |
2020 |
cType == #none ifTrue:[ |
|
3160 | 2021 |
^ self undrawCursor |
1334 | 2022 |
]. |
2023 |
||
2024 |
cType == #block ifTrue:[ |
|
3160 | 2025 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2026 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2027 |
|
1334 | 2028 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2029 |
||
2030 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2031 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2032 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2033 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2034 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2035 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2036 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2037 |
self makeLineVisible:aLineNumber. |
2951 | 2038 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2039 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2040 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2041 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2042 |
hideCursor |
1833 | 2043 |
"make cursor invisible if currently invisible" |
2044 |
||
2045 |
^ self cursorShown:false |
|
2046 |
||
2047 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2048 |
! |
2049 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2050 |
makeCursorVisible |
3160 | 2051 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2052 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2053 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2054 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2055 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2056 |
cursorLine notNil ifTrue:[ |
3160 | 2057 |
line := cursorLine. |
2058 |
col := cursorCol. |
|
2059 |
" |
|
2060 |
if there is a selection, its better to |
|
2061 |
have its start being visible, instead of the end |
|
2062 |
" |
|
2063 |
(selectionStartLine notNil |
|
2064 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2065 |
expandingTop ~~ false ifTrue:[ |
|
2066 |
line := selectionStartLine. |
|
2067 |
col := selectionStartCol. |
|
2068 |
] ifFalse:[ |
|
2069 |
line := selectionEndLine. |
|
2070 |
col := selectionEndCol |
|
2071 |
] |
|
2072 |
]. |
|
2073 |
self makeLineVisible:line. |
|
2074 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2075 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2076 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2077 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2078 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2079 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2080 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2081 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2082 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2083 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2084 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
flag ifTrue:[self showCursor] |
121 | 2086 |
! |
2087 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2088 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2089 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2090 |
|
2815 | 2091 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2092 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2093 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2094 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2095 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2096 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2097 |
|
3303 | 2098 |
"/ self assert:(lineNr notNil). |
2099 |
||
2100 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2101 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2102 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2103 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2104 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2105 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2106 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2107 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2108 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2109 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2110 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2111 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2112 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2113 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2114 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2115 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2116 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2117 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2118 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2119 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2120 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2121 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2122 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2123 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2124 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2125 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2126 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2127 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2128 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2129 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2130 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2131 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2132 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
|
1833 | 2134 |
^ self cursorShown:true |
2135 |
||
2136 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
"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
|
2141 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2142 |
|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
|
2143 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2144 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 2145 |
prevCol := cursorCol - 1. |
2146 |
||
2147 |
"/ if there is any italic stuff in the cursor line, |
|
2148 |
"/ redraw it completely (because characters overlap). |
|
2149 |
cursorCol > 1 ifTrue:[ |
|
2150 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2151 |
line hasChangeOfEmphasis ifTrue:[ |
|
2152 |
line size >= (cursorCol-1) ifTrue:[ |
|
2153 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2154 |
line size >= (cursorCol) ifTrue:[ |
|
2155 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2156 |
line size >= (cursorCol+1) ifTrue:[ |
|
2157 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2158 |
]. |
|
2159 |
]. |
|
2160 |
]. |
|
2161 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2162 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2163 |
] |
|
2164 |
] |
|
2165 |
] |
|
2166 |
]. |
|
2167 |
||
2168 |
((cursorType == #caret) |
|
2169 |
or:[cursorType == #solidCaret |
|
2170 |
or:[cursorType == #bigSolidCaret |
|
2171 |
or:[cursorType == #bigCaret |
|
2172 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2173 |
"caret-cursor touches 4 characters" |
|
2174 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2175 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2176 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2177 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2178 |
] ifFalse:[ |
|
2179 |
"care for left margin" |
|
2180 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2181 |
]. |
|
2182 |
^ self |
|
2183 |
]. |
|
2184 |
||
2185 |
cursorType == #ibeam ifTrue:[ |
|
2186 |
"ibeam-cursor touches 2 characters" |
|
2187 |
cursorCol > 1 ifTrue:[ |
|
2188 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2189 |
] ifFalse:[ |
|
2190 |
"care for left margin" |
|
2191 |
super redrawVisibleLine:cursorVisibleLine. |
|
2192 |
]. |
|
2193 |
^ self |
|
2194 |
]. |
|
2195 |
||
2196 |
"block cursor is simple - just one character under cursor" |
|
2197 |
||
2198 |
"/ however, if italic characters are involved, we must care |
|
2199 |
"/ for the chars before/after the cursor. |
|
2200 |
"/ We redraw the part of the previous character which got |
|
2201 |
"/ detroyed by the block cursor. |
|
2202 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2203 |
||
2204 |
line := self visibleAt:cursorVisibleLine. |
|
2205 |
(line notNil and:[line isText]) ifTrue:[ |
|
2206 |
cursorCol > 1 ifTrue:[ |
|
2207 |
oldClip := self clippingRectangleOrNil. |
|
2208 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2209 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2210 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
2211 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2212 |
self clippingRectangle:oldClip. |
|
2213 |
^ self. |
|
2214 |
]. |
|
2215 |
]. |
|
2216 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2218 |
|
2088 | 2219 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2220 |
! |
2221 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2222 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2223 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2224 |
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
|
2225 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2226 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2227 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2228 |
|
672 | 2229 |
validateCursorCol:col inLine:line |
674 | 2230 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2231 |
Here, no limits are enforced (and col is returned), |
2232 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2233 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2234 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2235 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2236 |
|
1419 | 2237 |
"/ in ST80 mode, |
2707 | 2238 |
"/ the cursor may not be positioned beyond the |
2239 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2240 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2241 |
self st80EditMode ifTrue:[ |
3160 | 2242 |
l := (self listAt:line). |
2243 |
max := l size + 1. |
|
2244 |
col > max ifTrue:[ |
|
2245 |
^ max |
|
2246 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2247 |
]. |
672 | 2248 |
^ col |
2249 |
||
1419 | 2250 |
"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
|
2251 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2252 |
! |
2253 |
||
2254 |
validateCursorLine:line |
|
2255 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2256 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2257 |
redefined in views which dont like the cursor to be positioned |
2258 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2259 |
skip reserved regions" |
|
2260 |
||
1419 | 2261 |
"/ |
2262 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2263 |
"/ beyond the last line |
1419 | 2264 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2265 |
self st80EditMode ifTrue:[ |
3160 | 2266 |
^ (line min:(list size)) max:1 |
1419 | 2267 |
]. |
674 | 2268 |
^ line |
2269 |
||
1419 | 2270 |
"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
|
2271 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2272 |
! |
2273 |
||
121 | 2274 |
withCursorOffDo:aBlock |
2275 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2276 |
||
2277 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
3160 | 2278 |
^ aBlock value |
121 | 2279 |
]. |
2280 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2281 |
aBlock ensure:[ |
3160 | 2282 |
self showCursor |
121 | 2283 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2284 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2285 |
|
2589 | 2286 |
!EditTextView methodsFor:'drag & drop'! |
2287 |
||
2288 |
allowDrop:aBoolean |
|
3236 | 2289 |
"enable/disable drop support" |
2290 |
||
2589 | 2291 |
aBoolean ifFalse:[ |
3236 | 2292 |
dropTarget := nil. |
2589 | 2293 |
] ifTrue:[ |
3439 | 2294 |
dropTarget isNil ifTrue:[ |
3236 | 2295 |
dropTarget := DropTarget receiver:self |
2296 |
argument:nil |
|
2297 |
dropSelector:#'drop:' |
|
2298 |
canDropSelector:#'canDrop:' |
|
2299 |
] |
|
2300 |
]. |
|
2301 |
! |
|
2302 |
||
3412 | 2303 |
canDrop:aDropContext |
2304 |
"public from d&d. |
|
2305 |
I accept textObjects and fileObjects only." |
|
2306 |
||
2307 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
|
2308 |
^ self canDropObjects:aDropContext dropObjects |
|
2309 |
||
2310 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2311 |
! |
|
2312 |
||
2313 |
canDropObjects:aCollectionOfDropObjects |
|
2314 |
"public from d&d. |
|
2315 |
I accept textObjects and fileObjects only." |
|
2589 | 2316 |
|
2317 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2318 |
||
3412 | 2319 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2320 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2321 |
||
2322 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2323 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2324 |
! |
|
2325 |
||
2326 |
drop:aDropContext |
|
2327 |
"public from d&d. |
|
2328 |
drop objects (new API)" |
|
2329 |
||
2330 |
self dropObjects:(aDropContext dropObjects) |
|
2331 |
||
2332 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2333 |
! |
|
2334 |
||
2335 |
dropFileObject:aDropObject |
|
2589 | 2336 |
"drop objects |
3236 | 2337 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2338 |
||
3412 | 2339 |
|obj answer text fn| |
2340 |
||
2341 |
fn := aDropObject asFilename. |
|
2342 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
2343 |
answer := Dialog |
|
3416 | 2344 |
confirmWithCancel:(resources |
2345 |
string:'Drop the Filename (%1) or its Contents ?' |
|
2346 |
with:fn name allBold) |
|
3412 | 2347 |
labels:#( 'Cancel' 'Name' 'Contents'). |
2348 |
answer isNil ifTrue:[ ^ self ]. |
|
2349 |
answer ifTrue:[ |
|
2350 |
text := fn contentsOfEntireFile |
|
2351 |
] ifFalse:[ |
|
2352 |
text := fn pathName |
|
2353 |
]. |
|
3236 | 2354 |
] ifFalse:[ |
3412 | 2355 |
text := obj asString |
2356 |
]. |
|
3495 | 2357 |
self undoablePaste:text info:'drop file'. |
3412 | 2358 |
|
2359 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2360 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2361 |
! |
2362 |
||
2363 |
dropObject:aDropObject |
|
2364 |
"drop objects |
|
2365 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2366 |
||
3415 | 2367 |
|text| |
2368 |
||
3412 | 2369 |
(aDropObject isFileObject) ifTrue:[ |
2370 |
self dropFileObject:aDropObject |
|
2371 |
] ifFalse:[ |
|
3415 | 2372 |
aDropObject isTextObject ifTrue:[ |
2373 |
text := aDropObject theObject asStringWithoutFinalCR |
|
2374 |
] ifFalse:[ |
|
2375 |
text := aDropObject theObject asString |
|
2376 |
]. |
|
3495 | 2377 |
self undoablePaste:text info:'drop'. |
3412 | 2378 |
]. |
2379 |
||
2380 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2381 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2382 |
! |
2383 |
||
2384 |
dropObjects:aCollectionOfDropObjects |
|
2385 |
"public from d&d. |
|
2386 |
drop objects (old API)" |
|
2387 |
||
2388 |
aCollectionOfDropObjects do:[:el| |
|
2389 |
self dropObject:el |
|
2390 |
]. |
|
2391 |
||
2392 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2393 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2394 |
! ! |
2395 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2397 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2398 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2399 |
"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
|
2400 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2401 |
selectionStartLine notNil ifTrue:[ |
3160 | 2402 |
self setClipboardText:(self selection). |
2403 |
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
|
2404 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2405 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2406 |
"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
|
2407 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2408 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2409 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2410 |
"delete single character under cursor; does not merge lines" |
121 | 2411 |
|
2412 |
|wasOn| |
|
2413 |
||
2414 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2415 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2416 |
wasOn ifTrue:[self showCursor] |
2417 |
! |
|
2418 |
||
827 | 2419 |
deleteCharAtLine:lineNr col:colNr |
2420 |
"delete a single character at colNr in line lineNr" |
|
2421 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2422 |
self st80EditMode ifTrue:[ |
3160 | 2423 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2424 |
| wasOn | |
|
2425 |
wasOn := self hideCursor. |
|
2426 |
self |
|
2427 |
cursorReturn; |
|
2428 |
cursorCol:1; |
|
2429 |
deleteCharBeforeCursor. |
|
2430 |
wasOn ifTrue:[ self showCursor]. |
|
2431 |
^ self. |
|
2432 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2433 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2434 |
|
827 | 2435 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2436 |
! |
|
2437 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2438 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2439 |
"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
|
2440 |
|
2491 | 2441 |
|soCol wasOn lineNrAboveCursor ln prevTab| |
121 | 2442 |
|
2443 |
wasOn := self hideCursor. |
|
2491 | 2444 |
autoIndent ifTrue:[ |
3160 | 2445 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
2446 |
ln := (list at:cursorLine) ? ''. |
|
2447 |
ln size < prevTab ifTrue:[ |
|
2448 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2449 |
]. |
|
2450 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2451 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2452 |
cursorCol > prevTab ifTrue:[ |
|
2453 |
self cursorLine:cursorLine col:prevTab. |
|
2454 |
wasOn ifTrue:[ self showCursor ]. |
|
2455 |
^ self |
|
2456 |
]. |
|
2457 |
] ifFalse:[ |
|
2458 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2459 |
self cursorLine:cursorLine col:prevTab. |
|
2460 |
wasOn ifTrue:[ self showCursor ]. |
|
2461 |
^ self. |
|
2462 |
] |
|
2463 |
]. |
|
827 | 2464 |
]. |
2465 |
||
2491 | 2466 |
"/ (autoIndent |
2467 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2468 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2469 |
"/ ifTrue:[ |
2470 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2471 |
"/ |
|
2472 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2473 |
"/ ln := list at:cursorLine. |
|
2474 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2475 |
"/ soCol := 1 |
|
2476 |
"/ ] |
|
2477 |
"/ ] |
|
2478 |
"/ ] ifFalse:[ |
|
3160 | 2479 |
soCol := 1. |
2491 | 2480 |
"/ ]. |
2481 |
||
1419 | 2482 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
3160 | 2483 |
" |
2484 |
somewhere in the middle of a line |
|
2485 |
" |
|
2486 |
self cursorLeft. |
|
2487 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2488 |
] ifFalse:[ |
3160 | 2489 |
" |
2490 |
at begin of line - merge with previous line; |
|
2491 |
except for the very first line. |
|
2492 |
" |
|
2493 |
(cursorLine == 1) ifFalse:[ |
|
2494 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2495 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2496 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2497 |
"/ we are beyond the end of the text. |
|
2498 |
"/ move the cursor to the previous line. |
|
2499 |
self cursorLine:lineNrAboveCursor col:1. |
|
2500 |
] ifFalse:[ |
|
2501 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2502 |
] |
|
2503 |
] |
|
2504 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2505 |
]. |
827 | 2506 |
wasOn ifTrue:[ self showCursor ] |
2507 |
||
1419 | 2508 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2509 |
! |
2510 |
||
2511 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2512 |
"delete characters from colNr up to the end in line lineNr" |
|
2513 |
||
2514 |
|line| |
|
2515 |
||
2516 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
3160 | 2517 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2518 |
] |
2519 |
||
2520 |
! |
|
2521 |
||
2522 |
deleteCharsAtLine:lineNr toCol:colNr |
|
2523 |
"delete characters from start up to colNr in line lineNr" |
|
2524 |
||
2525 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2526 |
||
2527 |
||
121 | 2528 |
! |
2529 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2530 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2531 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
self deleteLine:cursorLine |
121 | 2534 |
! |
2535 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2536 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2537 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2538 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2539 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2540 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2541 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2542 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2543 |
col1 == 0 ifTrue:[ |
3160 | 2544 |
line1 := line1 - 1. |
2545 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2546 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2547 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2548 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2549 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2550 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2551 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2552 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2553 |
|
2954 | 2554 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2555 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2556 |
joining lines if nescessary" |
|
2557 |
||
2558 |
|line newLine lineSize nMore| |
|
2559 |
||
2560 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2561 |
list isNil ifTrue:[^ self]. |
|
2562 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2563 |
||
2564 |
(startLine == endLine) ifTrue:[ |
|
3160 | 2565 |
"/ delete chars within a line |
2566 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2567 |
^ self |
|
2954 | 2568 |
]. |
2569 |
||
2570 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
3160 | 2571 |
"/ delete full lines only |
2572 |
endLine > startLine ifTrue:[ |
|
2573 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2574 |
]. |
|
2575 |
^ self |
|
2954 | 2576 |
]. |
2577 |
||
2578 |
"/ delete right rest of 1st line |
|
2579 |
self deleteCharsAtLine:startLine fromCol:startCol. |
|
2580 |
||
2581 |
"/ delete the inner lines ... |
|
2582 |
endLine > (startLine + 1) ifTrue:[ |
|
3160 | 2583 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 2584 |
]. |
2585 |
||
2586 |
(endCol ~~ 0) ifTrue:[ |
|
3160 | 2587 |
"/ delete the left rest of the last line |
2588 |
||
2589 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2590 |
||
2591 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2592 |
||
2593 |
line := list at:startLine. |
|
2594 |
lineSize := line size. |
|
2595 |
(startCol > lineSize) ifTrue:[ |
|
2596 |
newLine := line. |
|
2597 |
line isNil ifTrue:[ |
|
2598 |
newLine := String new:(startCol - 1) |
|
2599 |
] ifFalse:[ |
|
2600 |
nMore := startCol - 1 - lineSize. |
|
2601 |
nMore > 0 ifTrue:[ |
|
2602 |
newLine := line , (line species new:nMore) |
|
2603 |
] |
|
2604 |
]. |
|
2605 |
newLine ~~ line ifTrue:[ |
|
2606 |
list at:startLine put:newLine. |
|
2607 |
]. |
|
2608 |
"/ TODO: remember old maxwidth of linerange, |
|
2609 |
"/ only clear widthOfWidestLine, if this max |
|
2610 |
"/ length was (one of) the longest. |
|
2611 |
"/ avoids slow delete with huge texts. |
|
2612 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2613 |
self textChanged. |
|
2614 |
] |
|
2954 | 2615 |
]. |
2616 |
||
2617 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
2618 |
self mergeLine:startLine removeBlanks:false |
|
2619 |
||
2620 |
"Modified: / 10.11.1998 / 23:52:59 / cg" |
|
2621 |
! |
|
2622 |
||
827 | 2623 |
deleteLine:lineNr |
2624 |
"delete line" |
|
2625 |
||
2626 |
self deleteFromLine:lineNr toLine:lineNr |
|
2627 |
||
2628 |
||
2629 |
! |
|
2630 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2631 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2632 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2633 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2635 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2636 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2637 |
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
|
2638 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2639 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2640 |
(endLine > list size) ifTrue:[ |
3160 | 2641 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
] ifFalse:[ |
3160 | 2643 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2644 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2645 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2646 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2647 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2648 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2649 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2650 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2651 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2652 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2653 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2654 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2655 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2657 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2658 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2659 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2660 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2661 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2662 |
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
|
2663 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2664 |
selectionStartLine notNil ifTrue:[ |
3160 | 2665 |
wasOn := self hideCursor. |
2666 |
||
2667 |
startLine := selectionStartLine. |
|
2668 |
startCol := selectionStartCol. |
|
2669 |
endLine := selectionEndLine. |
|
2670 |
endCol := selectionEndCol. |
|
2671 |
self unselectWithoutRedraw. |
|
2672 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
2673 |
self setCursorLine:startLine col:startCol. |
|
2674 |
||
2675 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2676 |
] |
121 | 2677 |
! |
2678 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2679 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2680 |
"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
|
2681 |
|
2952 | 2682 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2683 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2684 |
wasOn := self hideCursor. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2685 |
endCol := cursorCol-1. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2686 |
endLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2687 |
self cursorToPreviousWord. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2688 |
beginCol := cursorCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2689 |
beginLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2690 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2691 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2692 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2693 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2694 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2695 |
|
121 | 2696 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2697 |
"insert a single character at cursor-position - advance cursor." |
121 | 2698 |
|
2699 |
|wasOn| |
|
2700 |
||
2701 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2702 |
aCharacter == Character tab ifTrue:[ |
3160 | 2703 |
"/ needs special care to advance cursor correctly |
2704 |
self insertTabAtCursor |
|
121 | 2705 |
] ifFalse:[ |
3160 | 2706 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
2707 |
aCharacter == (Character cr) ifTrue:[ |
|
2708 |
self cursorReturn |
|
2709 |
] ifFalse:[ |
|
2710 |
self cursorRight. |
|
2711 |
]. |
|
121 | 2712 |
]. |
2713 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2714 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2715 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 2716 |
! |
2717 |
||
641 | 2718 |
insertLine:aString before:lineNr |
2719 |
"insert the line aString before line lineNr" |
|
2720 |
||
2721 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
2722 |
||
2723 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
2724 |
! |
|
2725 |
||
155 | 2726 |
insertLines:aStringCollection before:lineNr |
2727 |
"insert a bunch before line lineNr" |
|
2728 |
||
2729 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
2730 |
||
2731 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
2732 |
! |
|
2733 |
||
654 | 2734 |
insertLines:lines withCR:withCr |
3160 | 2735 |
"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
|
2736 |
Cursor is moved behind insertion. |
641 | 2737 |
If withCr is true, append cr after last line" |
2738 |
||
2739 |
|start end nLines wasOn| |
|
2740 |
||
2741 |
lines notNil ifTrue:[ |
|
3160 | 2742 |
nLines := lines size. |
2743 |
(nLines == 1) ifTrue:[ |
|
2744 |
self insertStringAtCursor:(lines at:1). |
|
2745 |
withCr ifTrue:[ |
|
2746 |
self insertCharAtCursor:(Character cr) |
|
2747 |
] |
|
2748 |
] ifFalse:[ |
|
2749 |
(cursorCol ~~ 1) ifTrue:[ |
|
2750 |
self insertStringAtCursor:(lines at:1). |
|
2751 |
self insertCharAtCursor:(Character cr). |
|
2752 |
start := 2 |
|
2753 |
] ifFalse:[ |
|
2754 |
start := 1 |
|
2755 |
]. |
|
2756 |
withCr ifTrue:[ |
|
2757 |
end := nLines |
|
2758 |
] ifFalse:[ |
|
2759 |
end := nLines - 1 |
|
2760 |
]. |
|
2761 |
(start < nLines) ifTrue:[ |
|
2762 |
(end >= start) ifTrue:[ |
|
2763 |
wasOn := self hideCursor. |
|
2764 |
self insertLines:lines from:start to:end before:cursorLine. |
|
2765 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
2766 |
wasOn ifTrue:[self showCursor]. |
|
2767 |
] |
|
2768 |
]. |
|
2769 |
withCr ifFalse:[ |
|
2770 |
"last line without cr" |
|
2771 |
self insertStringAtCursor:(lines at:nLines) |
|
2772 |
] |
|
2773 |
] |
|
641 | 2774 |
] |
654 | 2775 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2776 |
"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
|
2777 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 2778 |
! |
2779 |
||
2780 |
insertLines:lines withCr:withCr |
|
2781 |
"insert a bunch of lines at cursor position. Cursor |
|
2782 |
is moved behind insertion. |
|
2783 |
If withCr is true, append cr after last line" |
|
2784 |
||
2363 | 2785 |
<resource:#obsolete> |
2786 |
||
1292 | 2787 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
2788 |
self insertLines:lines withCR:withCr. |
|
2789 |
||
2790 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 2791 |
! |
2792 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2793 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2794 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2795 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2796 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2797 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2798 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2799 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2800 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
self selectFromLine:startLine col:startCol |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
2802 |
toLine:cursorLine col:(cursorCol - 1). |
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
2803 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2804 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2805 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2806 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2807 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2808 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2809 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2810 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2811 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2812 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2813 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2814 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2815 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2816 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2817 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2818 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2819 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2820 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2821 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2822 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2823 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2824 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2825 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2826 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2827 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2828 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 2829 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2830 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2831 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2832 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2833 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2834 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2835 |
[start <= end] whileTrue:[ |
3160 | 2836 |
stop := aString indexOf:(Character cr) startingAt:start. |
2837 |
stop == 0 ifTrue:[ |
|
2838 |
stop := end + 1 |
|
2839 |
]. |
|
2840 |
subString := aString copyFrom:start to:(stop - 1). |
|
2841 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
2842 |
(stop <= end) ifTrue:[ |
|
2843 |
c := c + subString size. |
|
2844 |
self insert:(Character cr) atLine:l col:c. |
|
2845 |
l := l + 1. |
|
2846 |
c := 1 |
|
2847 |
]. |
|
2848 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2849 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2850 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2851 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 2852 |
! |
2853 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2854 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2855 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2856 |
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
|
2857 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2858 |
aString isNil ifTrue:[ |
3160 | 2859 |
"new:" |
2860 |
self insertCharAtCursor:(Character cr). |
|
2861 |
^ self |
|
105 | 2862 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2863 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2864 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 2865 |
]. |
2866 |
||
654 | 2867 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2868 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2869 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 2870 |
! |
2871 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2872 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2873 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2874 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2875 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2876 |
shown ifTrue:[self redrawLine:lineNr from:colNr] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2877 |
|
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2878 |
"Modified: / 5.4.1998 / 16:51:14 / cg" |
105 | 2879 |
! |
2880 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2881 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2882 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2883 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2884 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2885 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2886 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2887 |
aString size > 0 ifTrue:[ |
3160 | 2888 |
wasOn := self hideCursor. |
2889 |
(aString includes:Character tab) ifTrue:[ |
|
2890 |
self checkForExistingLine:cursorLine. |
|
2891 |
oldLen := (list at:cursorLine) size. |
|
2892 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
2893 |
newLen := (list at:cursorLine) size. |
|
2894 |
deltaLen := newLen - oldLen. |
|
2895 |
] ifFalse:[ |
|
2896 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
2897 |
deltaLen := aString size. |
|
2898 |
]. |
|
2899 |
self setCursorCol:(cursorCol + deltaLen). |
|
2900 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2901 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2902 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2903 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2904 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2905 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2906 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2907 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2908 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2909 |
|wasOn nextTab| |
105 | 2910 |
|
121 | 2911 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2912 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2913 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2914 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 2915 |
! |
2916 |
||
3542 | 2917 |
joinLines |
2918 |
self |
|
2919 |
undoableDo:[ |
|
3549 | 2920 |
|line col lineLen| |
2921 |
||
2922 |
line := cursorLine. |
|
2923 |
col := cursorCol. |
|
2924 |
lineLen := (list at:line) size. |
|
2925 |
col > lineLen ifTrue:[ |
|
2926 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
2927 |
] ifFalse:[ |
|
2928 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
2929 |
]. |
|
2930 |
self mergeLine:line removeBlanks:true. |
|
2931 |
self cursorLine:line col:col. |
|
3542 | 2932 |
] |
2933 |
info:'Join' |
|
2934 |
! |
|
2935 |
||
2952 | 2936 |
mergeLine:lineNr |
2937 |
"merge line lineNr with line lineNr+1" |
|
2938 |
||
2939 |
self mergeLine:lineNr removeBlanks:true |
|
2940 |
||
2941 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
2942 |
! |
|
2943 |
||
2506 | 2944 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2945 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2946 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2947 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2948 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2949 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2950 |
|
2506 | 2951 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
3160 | 2952 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
2953 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
2954 |
newSelectionEnd := newSelectionEnd-1. |
|
2955 |
]. |
|
2956 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
2957 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2958 |
newSelectionEnd := newSelectionEnd-1. |
|
2959 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2960 |
] ifFalse:[ |
3160 | 2961 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
2962 |
newSelectionEnd := newSelectionEnd+1. |
|
2963 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
2964 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2965 |
newSelectionEnd := newSelectionEnd+1. |
|
2966 |
] |
|
2967 |
]. |
|
2968 |
self |
|
2969 |
selectFromLine:selectionStartLine col:selectionStartCol |
|
2970 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2971 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2972 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2973 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2974 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2976 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2977 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2979 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2980 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2981 |
[finished] whileFalse:[ |
3160 | 2982 |
(lastLine <= 1) ifTrue:[ |
2983 |
finished := true |
|
2984 |
] ifFalse:[ |
|
2985 |
line := list at:lastLine. |
|
2986 |
line notNil ifTrue:[ |
|
2987 |
line isBlank ifTrue:[ |
|
2988 |
list at:lastLine put:nil. |
|
2989 |
line := nil |
|
2990 |
] |
|
2991 |
]. |
|
2992 |
line notNil ifTrue:[ |
|
2993 |
finished := true |
|
2994 |
] ifFalse:[ |
|
2995 |
lastLine := lastLine - 1 |
|
2996 |
] |
|
2997 |
] |
|
118 | 2998 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2999 |
(lastLine ~~ list size) ifTrue:[ |
3160 | 3000 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3001 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3002 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3003 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3004 |
|
3430 | 3005 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ign |
3006 |
|pattern replacePattern| |
|
3007 |
||
3008 |
pattern := patternArg string. |
|
3009 |
replacePattern := replacePatternArg string. |
|
3010 |
^ (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
|
3011 |
self rememberSearchPattern:pattern. |
|
3012 |
self rememberSearchPattern:replacePattern. |
|
3013 |
LastSearchIgnoredCase := ign. |
|
3014 |
self |
|
3015 |
undoableDo:[ |
|
3016 |
all ifTrue:[ |
|
3017 |
self |
|
3018 |
replaceString:pattern |
|
3019 |
to:replacePattern |
|
3020 |
ignoreCase:ign |
|
3021 |
] ifFalse:[ |
|
3022 |
(self selectionAsString notNil |
|
3023 |
and:[ self selectionAsString sameAs:pattern ignoreCase:ign ]) |
|
3024 |
ifTrue:[ |
|
3025 |
self replaceSelectionWith:replacePattern. |
|
3026 |
self |
|
3027 |
search:pattern |
|
3028 |
ignoreCase:ign |
|
3029 |
forward:(lastSearchDirection = #forward). |
|
3030 |
]. |
|
3031 |
] |
|
3032 |
] |
|
3542 | 3033 |
info:'Replace' |
3430 | 3034 |
] |
3035 |
||
3036 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3037 |
! |
|
3038 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3039 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3040 |
"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
|
3041 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3042 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3043 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3044 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3045 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3046 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3047 |
] ifFalse:[ |
3160 | 3048 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3049 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3050 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3051 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3052 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3053 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3054 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3055 |
|
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3056 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3057 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3058 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3059 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3060 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3061 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3062 |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3063 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3064 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3065 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3066 |
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
|
3067 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3068 |
|
1809 | 3069 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3070 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3071 |
lines notNil ifTrue:[ |
3160 | 3072 |
wasOn := self hideCursor. |
3073 |
nLines := lines size. |
|
3074 |
line := cursorLine. |
|
3075 |
col := cursorCol. |
|
3076 |
lines keysAndValuesDo:[:i :l | |
|
3077 |
self replaceString:l atLine:line col:col. |
|
3078 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3079 |
line := line + 1. |
|
3080 |
col := 1. |
|
3081 |
] ifFalse:[ |
|
3082 |
col := col + (l size). |
|
3083 |
] |
|
3084 |
]. |
|
3085 |
self cursorLine:line col:col. |
|
3086 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3087 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3088 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3089 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3090 |
"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
|
3091 |
"Modified: / 12.6.1998 / 22:05:51 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3092 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3093 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3094 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3095 |
"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
|
3096 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3097 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3098 |
self replaceSelectionBy:something keepCursor:false |
105 | 3099 |
! |
3100 |
||
3101 |
replaceSelectionBy:something keepCursor:keep |
|
3102 |
"delete the selection (if any) and insert something, a character or string; |
|
3103 |
leave cursor after insertion or leave it, depending on keep" |
|
3104 |
||
3105 |
|sel l c| |
|
3106 |
||
3107 |
l := cursorLine. |
|
3108 |
c := cursorCol. |
|
3109 |
||
3110 |
sel := self selection. |
|
3111 |
sel notNil ifTrue:[ |
|
3161 | 3112 |
lastString := sel. |
3113 |
self deleteSelection. |
|
3114 |
replacing := true. |
|
3115 |
lastReplacement := ''. |
|
3116 |
undoSupport actionInfo:'replace'. |
|
3117 |
]. |
|
3118 |
||
3119 |
something isCharacter ifTrue:[ |
|
3120 |
lastReplacement notNil ifTrue:[ |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3121 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3122 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3123 |
"/ lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3124 |
"/ lastReplacement := lastReplacement copyWith:something. |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3125 |
"/ lastReplacement := lastReplacement copyWith:Character space |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3126 |
"/ ] ifFalse:[ |
3161 | 3127 |
lastReplacement := lastReplacement copyWith:something. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3128 |
"/ ] |
3161 | 3129 |
]. |
3235 | 3130 |
self isInInsertMode ifTrue:[ |
3161 | 3131 |
self insertCharAtCursor:something |
3132 |
] ifFalse:[ |
|
3133 |
self replaceCharAtCursor:something |
|
3134 |
] |
|
105 | 3135 |
] ifFalse:[ |
3161 | 3136 |
something isString ifTrue:[ |
3137 |
lastReplacement := something. |
|
3235 | 3138 |
self isInInsertMode ifTrue:[ |
3161 | 3139 |
self insertStringAtCursor:something |
3140 |
] ifFalse:[ |
|
3141 |
self replaceStringAtCursor:something |
|
3142 |
] |
|
3143 |
] ifFalse:[ |
|
3144 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3145 |
]. |
|
105 | 3146 |
]. |
3147 |
keep ifTrue:[ |
|
3161 | 3148 |
self cursorLine:l col:c |
105 | 3149 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3150 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3151 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3152 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3153 |
|
3549 | 3154 |
replaceString:aString to:aNewString ignoreCase:ign |
3155 |
|continue count| |
|
3156 |
||
3157 |
self cursorToTop. |
|
3158 |
self selectFromBeginning. |
|
3159 |
count := 0. |
|
3160 |
continue := true. |
|
3161 |
[ continue ] whileTrue:[ |
|
3162 |
(self selectionAsString notNil |
|
3163 |
and:[ self selectionAsString sameAs:aString ignoreCase:ign ]) |
|
3164 |
ifTrue:[ |
|
3165 |
self replaceSelectionWith:aNewString. |
|
3166 |
count := count + 1. |
|
3167 |
]. |
|
3168 |
self |
|
3169 |
searchFwd:aString |
|
3170 |
ignoreCase:ign |
|
3171 |
ifAbsent:[ |
|
3172 |
Dialog |
|
3173 |
information:aString , ' has been replaced to ' , aNewString , ' ' |
|
3174 |
, count printString , ' times'. |
|
3175 |
continue := false. |
|
3176 |
]. |
|
3177 |
]. |
|
3430 | 3178 |
|
3179 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3180 |
! |
|
3181 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3182 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3183 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3184 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3185 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3186 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3187 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3188 |
(aString includes:Character tab) ifTrue:[ |
3160 | 3189 |
"/ need special care for TAB (to move cursor correctly) |
3190 |
i1 := 1. |
|
3191 |
[i1 ~~ 0] whileTrue:[ |
|
3192 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3193 |
i2 ~~ 0 ifTrue:[ |
|
3194 |
i1 ~~ i2 ifTrue:[ |
|
3195 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3196 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3197 |
]. |
|
3198 |
self replaceTABAtCursor. |
|
3199 |
i2 := i2 + 1. |
|
3200 |
] ifFalse:[ |
|
3201 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3202 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3203 |
]. |
|
3204 |
i1 := i2. |
|
3205 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3206 |
] ifFalse:[ |
3160 | 3207 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3208 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3209 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3210 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3211 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3212 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3213 |
"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
|
3214 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3215 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3216 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3217 |
"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
|
3218 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3219 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3220 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3221 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3222 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3223 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3224 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3225 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3226 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3227 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3228 |
|
2752 | 3229 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3230 |
|
2952 | 3231 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3232 |
"delete characters from startCol to endCol in line lineNr" |
3233 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
3234 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3235 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3236 |
line := self listAt:lineNr. |
827 | 3237 |
|
3160 | 3238 |
(self checkModificationsAllowed and:[line notNil]) ifTrue:[ |
3549 | 3239 |
lineSize := line size. |
3240 |
||
3241 |
startCol == 0 ifFalse:[ start := startCol ] |
|
3242 |
ifTrue:[ start := 1 ]. |
|
3243 |
||
3244 |
endCol > lineSize ifFalse:[ stop := endCol ] |
|
3245 |
ifTrue:[ stop := lineSize ]. |
|
3246 |
||
3247 |
stop >= start ifTrue:[ |
|
3248 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
3249 |
ifFalse:[ newLine := '' ]. |
|
3250 |
||
3251 |
stop == lineSize ifFalse:[ |
|
3252 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
3253 |
newLine := line string species fromString:newLine. |
|
3254 |
]. |
|
3255 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
3256 |
]. |
|
3257 |
||
3258 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
3259 |
newLine := nil |
|
3260 |
]. |
|
3261 |
||
3262 |
prevWidth := self widthOfLine:lineNr. |
|
3263 |
||
3264 |
list at:lineNr put:newLine. |
|
3265 |
||
3266 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
3267 |
"/ remember old width of this line, |
|
3268 |
"/ only clear widthOfWidestLine, if this lines |
|
3269 |
"/ length was (one of) the longest. |
|
3270 |
"/ avoids slow delete with huge texts. |
|
3271 |
widthOfWidestLine := nil. "i.e. unknown" |
|
3272 |
||
3273 |
"/ scroll left if reqiured |
|
3274 |
viewOrigin x > 0 ifTrue:[ |
|
3275 |
newWidth := self widthOfLine:lineNr. |
|
3276 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
3277 |
self scrollHorizontalTo:(newWidth |
|
3278 |
- width |
|
3279 |
+ margin + margin |
|
3280 |
+ (font widthOf:' ')) |
|
3281 |
] |
|
3282 |
]. |
|
3283 |
self textChanged. |
|
3284 |
] ifFalse:[ |
|
3285 |
self textChanged "/ textChangedButNoSizeChange |
|
3286 |
]. |
|
3287 |
self redrawLine:lineNr from:start. |
|
3288 |
||
3289 |
] |
|
827 | 3290 |
] |
3291 |
||
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3292 |
"Modified: / 11.11.1998 / 00:01:09 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3293 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3294 |
|
2952 | 3295 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3296 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3297 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3298 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3299 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3300 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3301 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3302 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3303 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3304 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3305 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3306 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3307 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3308 |
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
|
3309 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3310 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3311 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3312 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3313 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3314 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3315 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3316 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3317 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3318 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3319 |
(firstLineShown >= nLines) ifTrue:[ |
3160 | 3320 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3321 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3322 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3323 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3324 |
"Modified: / 10.11.1998 / 23:55:05 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3325 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3326 |
|
2952 | 3327 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3328 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3329 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3330 |
|
2952 | 3331 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3332 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3333 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3334 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3335 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3336 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3337 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3338 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3339 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3340 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3341 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3342 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3343 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3344 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3345 |
|
2952 | 3346 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 3347 |
"insert a single character at lineNr/colNr; |
827 | 3348 |
set emphasis to character at current position" |
3349 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
3350 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3351 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3352 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3353 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3354 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3355 |
self splitLine:lineNr before:colNr. |
3356 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3357 |
]. |
827 | 3358 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3359 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3360 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3361 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3362 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3363 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3364 |
self st80EditMode ifFalse:[ |
3160 | 3365 |
(trimBlankLines |
3366 |
and:[colNr > lineSize |
|
3367 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
3368 |
^ self |
|
3369 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3370 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3371 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3372 |
(lineSize == 0) ifTrue:[ |
3160 | 3373 |
newLine := aCharacter asString species new:colNr. |
3374 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3375 |
] ifFalse: [ |
3160 | 3376 |
(colNr > lineSize) ifTrue: [ |
3377 |
colNr == (lineSize +1) ifTrue:[ |
|
3378 |
attribute := line emphasisAt:lineSize |
|
3379 |
]. |
|
3380 |
newLine := line species new:colNr. |
|
3381 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3382 |
drawCharacterOnly := true |
|
3383 |
] ifFalse: [ |
|
3384 |
attribute := line emphasisAt:colNr. |
|
3385 |
newLine := line species new:(lineSize + 1). |
|
3386 |
||
3387 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
3388 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
3389 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3390 |
]. |
827 | 3391 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3392 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
3160 | 3393 |
newLine := aCharacter asString species fromString:newLine. |
3394 |
line isText ifTrue:[ |
|
3395 |
newLine := newLine asText |
|
3396 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3397 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3398 |
newLine at:colNr put:aCharacter. |
827 | 3399 |
|
3400 |
attribute notNil ifTrue:[ |
|
3160 | 3401 |
newLine emphasisAt:colNr put:attribute |
827 | 3402 |
]. |
3403 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3404 |
aCharacter == (Character tab) ifTrue:[ |
3160 | 3405 |
newLine := self withTabsExpanded:newLine. |
3406 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3407 |
]. |
827 | 3408 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3409 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3410 |
widthOfWidestLine notNil ifTrue:[ |
3160 | 3411 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3412 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3413 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3414 |
shown ifTrue:[ |
3160 | 3415 |
"/ care for italic text - in this case, we must also |
3416 |
"/ redraw the character before the insertion in order |
|
3417 |
"/ to fix the slanted piece of the character. |
|
3418 |
"/ (but we must clip, to avoid destoying the character before) |
|
3419 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
3420 |
colNr > 1 ifTrue:[ |
|
3421 |
cursorVisibleLine notNil ifTrue:[ |
|
3422 |
oldClip := self clippingRectangleOrNil. |
|
3423 |
x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
3424 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
3425 |
drawCharacterOnly ifTrue:[ |
|
3426 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
3427 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
3428 |
] ifFalse:[ |
|
3429 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
3430 |
self redrawLine:lineNr from:colNr-1 |
|
3431 |
]. |
|
3432 |
self clippingRectangle:oldClip. |
|
3433 |
]. |
|
3434 |
^ self. |
|
3435 |
]. |
|
3436 |
]. |
|
3437 |
drawCharacterOnly ifTrue:[ |
|
3438 |
self redrawLine:lineNr col:colNr |
|
3439 |
] ifFalse:[ |
|
3440 |
self redrawLine:lineNr from:colNr |
|
3441 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3442 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3443 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
3444 |
"Modified: / 20.6.1998 / 18:19:22 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3445 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3446 |
|
2952 | 3447 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 3448 |
"merge line lineNr with line lineNr+1" |
3449 |
||
827 | 3450 |
|leftPart rightPart bothParts nextLineNr i| |
3451 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3452 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
3160 | 3453 |
"/ empty list or beyond end of text |
3454 |
^ self |
|
827 | 3455 |
]. |
3456 |
leftPart := self listAt:lineNr. |
|
3457 |
||
3458 |
leftPart isNil ifTrue:[ |
|
3160 | 3459 |
leftPart := ''. |
3460 |
autoIndent ifTrue:[ |
|
3461 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
3462 |
leftPart := String new:i |
|
3463 |
] |
|
3464 |
] |
|
827 | 3465 |
]. |
3466 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
3467 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
3468 |
||
3469 |
nextLineNr > (list size) ifFalse:[ |
|
3160 | 3470 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
3471 |
rightPart := '' |
|
3472 |
] ifFalse:[ |
|
3473 |
removeBlanks ifTrue:[ |
|
3474 |
rightPart := rightPart withoutLeadingSeparators. |
|
3475 |
] |
|
3476 |
]. |
|
3477 |
||
3478 |
bothParts := leftPart , rightPart. |
|
3479 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
3480 |
list at:lineNr put:bothParts. |
|
3481 |
self redrawLine:lineNr. |
|
3482 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3483 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3484 |
|
1319 | 3485 |
"Created: 9.9.1997 / 09:27:38 / cg" |
3486 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3487 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3488 |
|
2952 | 3489 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3490 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3491 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3492 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3493 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3494 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3495 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3496 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3497 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3498 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3499 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3500 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3501 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3502 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3503 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3504 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3505 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3506 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3507 |
and:[aCharacter == Character space]]) ifTrue:[ |
3160 | 3508 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3509 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3510 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3511 |
(lineSize == 0) ifTrue:[ |
3160 | 3512 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3513 |
] ifFalse: [ |
3160 | 3514 |
(colNr > lineSize) ifTrue: [ |
3515 |
newLine := line species new:colNr. |
|
3516 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3517 |
] ifFalse: [ |
|
3518 |
newLine := line copy. |
|
3519 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3520 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3521 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3522 |
aCharacter == (Character tab) ifTrue:[ |
3160 | 3523 |
newLine := self withTabsExpanded:newLine. |
3524 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3525 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3526 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3527 |
widthOfWidestLine notNil ifTrue:[ |
3160 | 3528 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3529 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3530 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3531 |
shown ifTrue:[ |
3160 | 3532 |
drawCharacterOnly ifTrue:[ |
3533 |
self redrawLine:lineNr col:colNr |
|
3534 |
] ifFalse:[ |
|
3535 |
self redrawLine:lineNr from:colNr |
|
3536 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3537 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3538 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3539 |
"Created: / 6.3.1996 / 12:29:20 / cg" |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3540 |
"Modified: / 10.6.1998 / 18:50:18 / cg" |
105 | 3541 |
! |
3542 |
||
3235 | 3543 |
basicReplaceString:aString atLine:lineNr col:colNr |
3544 |
"replace multiple characters starting at lineNr/colNr. |
|
3545 |
This is not prepared to encounter special chars (except TAB) |
|
3546 |
in the string." |
|
3547 |
||
3548 |
|line lineSize newLine endCol| |
|
3549 |
||
3550 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3551 |
||
3552 |
self checkForExistingLine:lineNr. |
|
3553 |
line := list at:lineNr. |
|
3554 |
lineSize := line size. |
|
3555 |
||
3556 |
endCol := colNr + aString size - 1. |
|
3557 |
(lineSize == 0) ifTrue:[ |
|
3558 |
newLine := aString species new:endCol. |
|
3559 |
] ifFalse: [ |
|
3560 |
(endCol > lineSize) ifTrue: [ |
|
3561 |
aString isText ifTrue:[ |
|
3562 |
newLine := aString species new:endCol. |
|
3563 |
] ifFalse:[ |
|
3564 |
newLine := line species new:endCol. |
|
3565 |
]. |
|
3566 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3567 |
] ifFalse: [ |
|
3568 |
aString isText ifTrue:[ |
|
3569 |
newLine := aString species new:line size. |
|
3570 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3571 |
] ifFalse:[ |
|
3572 |
newLine := line copy. |
|
3573 |
] |
|
3574 |
] |
|
3575 |
]. |
|
3576 |
newLine replaceFrom:colNr with:aString. |
|
3577 |
(aString includes:(Character tab)) ifTrue:[ |
|
3578 |
newLine := self withTabsExpanded:newLine. |
|
3579 |
]. |
|
3580 |
list at:lineNr put:newLine. |
|
3581 |
widthOfWidestLine notNil ifTrue:[ |
|
3582 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3583 |
]. |
|
3584 |
self textChanged. |
|
3585 |
shown ifTrue:[ |
|
3586 |
self redrawLine:lineNr from:colNr |
|
3587 |
] |
|
3588 |
||
3589 |
"Created: / 11.6.1998 / 10:38:32 / cg" |
|
3590 |
"Modified: / 20.6.1998 / 20:23:50 / cg" |
|
3591 |
! |
|
3592 |
||
2952 | 3593 |
basicSplitLine:lineNr before:colNr |
3594 |
"split the line linNr before colNr; the right part (from colNr) |
|
3595 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3596 |
||
3160 | 3597 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 3598 |
srcY "{ Class: SmallInteger }" | |
3599 |
||
3027 | 3600 |
list isNil ifTrue:[ ^ self ]. |
3601 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
3602 |
||
3603 |
(colNr == 1) ifTrue:[ |
|
3160 | 3604 |
self nonUndoableDo:[ |
3605 |
self insertLine:nil before:lineNr. |
|
3606 |
]. |
|
3607 |
^ self |
|
3027 | 3608 |
]. |
3609 |
||
3610 |
line := list at:lineNr. |
|
3611 |
line isNil ifFalse:[ |
|
3160 | 3612 |
lineSize := line size. |
3613 |
(colNr <= lineSize) ifTrue:[ |
|
3614 |
rightRest := line copyFrom:colNr to:lineSize. |
|
3615 |
(colNr > 1) ifTrue:[ |
|
3616 |
leftRest := line copyTo:(colNr - 1) |
|
3617 |
] |
|
3618 |
] ifFalse:[ |
|
3619 |
leftRest := line |
|
3620 |
] |
|
3027 | 3621 |
]. |
3622 |
leftRest notNil ifTrue:[ |
|
3160 | 3623 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 3624 |
]. |
3625 |
list at:lineNr put:leftRest. |
|
3626 |
self nonUndoableDo:[ |
|
3160 | 3627 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 3628 |
]. |
3629 |
visLine := self listLineToVisibleLine:(lineNr). |
|
3630 |
visLine notNil ifTrue:[ |
|
3160 | 3631 |
w := self widthForScrollBetween:lineNr |
3632 |
and:(firstLineShown + nLinesShown). |
|
3633 |
srcY := topMargin + (visLine * fontHeight). |
|
3634 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
3635 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
3636 |
self catchExpose. |
|
3637 |
self |
|
3638 |
copyFrom:self |
|
3639 |
x:textStartLeft y:srcY |
|
3640 |
toX:textStartLeft y:(srcY + fontHeight) |
|
3641 |
width:w |
|
3642 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
3643 |
async:true. |
|
3644 |
]. |
|
3645 |
self redrawLine:lineNr. |
|
3646 |
self redrawLine:(lineNr + 1). |
|
3647 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 3648 |
]. |
3649 |
widthOfWidestLine := nil. "/ unknown |
|
3650 |
self textChanged. |
|
2952 | 3651 |
|
3652 |
"Modified: 29.1.1997 / 13:03:22 / cg" |
|
3653 |
! |
|
3654 |
||
3655 |
basicWithoutRedrawInsertLine:aString before:lineNr |
|
3656 |
"insert the argument, aString before line lineNr; the string |
|
3657 |
becomes line nileNr; everything else is moved down; the view |
|
3658 |
is not redrawn" |
|
3659 |
||
3660 |
|line| |
|
3661 |
||
3662 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3663 |
||
3664 |
line := aString. |
|
3665 |
line notNil ifTrue:[ |
|
3160 | 3666 |
line isString ifTrue:[ |
3667 |
line isBlank ifTrue:[ |
|
3668 |
line := nil |
|
3669 |
] ifFalse:[ |
|
3670 |
(line includes:(Character tab)) ifTrue:[ |
|
3671 |
line := self withTabsExpanded:line |
|
3672 |
] |
|
3673 |
] |
|
3674 |
] |
|
2952 | 3675 |
]. |
3676 |
list isNil ifTrue: [ |
|
3160 | 3677 |
list := StringCollection new:lineNr |
2952 | 3678 |
] ifFalse: [ |
3160 | 3679 |
list grow:((list size + 1) max:lineNr) |
3680 |
]. |
|
3681 |
||
3682 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2952 | 3683 |
overlapping copy - if it didn't, we had to use:" |
3684 |
" |
|
3685 |
index := list size. |
|
3686 |
[index > lineNr] whileTrue: [ |
|
3160 | 3687 |
pIndex := index - 1. |
3688 |
list at:index put:(list at:pIndex). |
|
3689 |
index := pIndex |
|
2952 | 3690 |
]. |
3691 |
" |
|
3692 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
|
3693 |
list at:lineNr put:line. |
|
3694 |
self contentsChanged |
|
3695 |
||
3696 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
|
3697 |
! |
|
3698 |
||
2954 | 3699 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
3700 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3701 |
||
3702 |
|newLine newLines nLines| |
|
3703 |
||
3704 |
nLines := end - start + 1. |
|
3705 |
newLines := Array new:(lines size). |
|
3706 |
start to:end do:[:index | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3707 |
newLine := lines at:index. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3708 |
newLine notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3709 |
newLine isString ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3710 |
newLine isBlank ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3711 |
newLine := nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3712 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3713 |
(newLine includes:(Character tab)) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3714 |
newLine := self withTabsExpanded:newLine |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3715 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3716 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3717 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3718 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3719 |
newLines at:index put:newLine |
2954 | 3720 |
]. |
3721 |
list isNil ifTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3722 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 3723 |
] ifFalse: [ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3724 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 3725 |
]. |
3726 |
||
3727 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 3728 |
overlapping copy - if it didn't, we had to use:" |
3729 |
" |
|
3730 |
index := list size. |
|
3731 |
[index > lineNr] whileTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3732 |
pIndex := index - 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3733 |
list at:index put:(list at:pIndex). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3734 |
index := pIndex |
2954 | 3735 |
]. |
3736 |
" |
|
3737 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
3738 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
3739 |
self contentsChanged |
|
3740 |
||
3741 |
"Modified: / 10.6.1998 / 19:01:16 / cg" |
|
3742 |
! |
|
3743 |
||
3744 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3745 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3746 |
||
3747 |
|isText strLen line lineSize newLine stringType sz| |
|
3748 |
||
3749 |
(aString notNil) ifFalse:[ ^ self]. |
|
3750 |
||
3751 |
strLen := aString size. |
|
3752 |
self checkForExistingLine:lineNr. |
|
3753 |
||
3754 |
stringType := aString string species. |
|
3755 |
isText := aString isText. |
|
3756 |
line := list at:lineNr. |
|
3757 |
||
3758 |
line notNil ifTrue:[ |
|
3160 | 3759 |
lineSize := line size. |
3760 |
line isString ifFalse:[ |
|
3761 |
stringType := line species |
|
3762 |
] ifTrue:[ |
|
3763 |
line bitsPerCharacter > aString bitsPerCharacter ifTrue:[ |
|
3764 |
stringType := line string species |
|
3765 |
]. |
|
3766 |
line isText ifTrue:[ isText := true ] |
|
3767 |
]. |
|
2954 | 3768 |
] ifFalse:[ |
3160 | 3769 |
lineSize := 0 |
2954 | 3770 |
]. |
3771 |
||
3772 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
3160 | 3773 |
newLine := aString |
2954 | 3774 |
] ifFalse:[ |
3160 | 3775 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
3776 |
sz := colNr + strLen - 1 |
|
3777 |
] ifFalse:[ |
|
3778 |
sz := lineSize + strLen |
|
3779 |
]. |
|
3780 |
||
3781 |
isText ifFalse:[ |
|
3782 |
newLine := stringType new:sz |
|
3783 |
] ifTrue:[ |
|
3784 |
newLine := Text string:(stringType new:sz) |
|
3785 |
]. |
|
3786 |
||
3787 |
(lineSize ~~ 0) ifTrue: [ |
|
3788 |
(colNr > lineSize) ifTrue: [ |
|
3789 |
newLine replaceFrom:1 to:lineSize |
|
3790 |
with:line startingAt:1 |
|
3791 |
] ifFalse: [ |
|
3792 |
newLine replaceFrom:1 to:(colNr - 1) |
|
3793 |
with:line startingAt:1. |
|
3794 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) |
|
3795 |
with:line startingAt:colNr |
|
3796 |
] |
|
3797 |
]. |
|
3798 |
newLine replaceFrom:colNr to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 3799 |
]. |
3800 |
||
3801 |
(aString includes:(Character tab)) ifTrue:[ |
|
3160 | 3802 |
newLine := self withTabsExpanded:newLine |
2954 | 3803 |
]. |
3804 |
||
3805 |
list at:lineNr put:newLine. |
|
3806 |
widthOfWidestLine notNil ifTrue:[ |
|
3160 | 3807 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 3808 |
]. |
3809 |
self textChanged. |
|
3810 |
||
3811 |
"Modified: / 10.6.1998 / 19:01:52 / cg" |
|
3812 |
! |
|
3813 |
||
2952 | 3814 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3815 |
"delete characters from startCol to endCol in line lineNr" |
3816 |
||
2952 | 3817 |
|deleted| |
3818 |
||
3819 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3820 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3115 | 3821 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
2952 | 3822 |
! |
3823 |
||
3824 |
deleteFromLine:startLineNr toLine:endLineNr |
|
3825 |
"delete some lines" |
|
3826 |
||
3827 |
|deleted| |
|
3828 |
||
3829 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3830 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3115 | 3831 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
2952 | 3832 |
! |
3833 |
||
3834 |
deleteLineWithoutRedraw:lineNr |
|
3835 |
"delete line - no redraw; |
|
3836 |
return true, if something was really deleted" |
|
3837 |
||
3838 |
|deleted ret| |
|
3839 |
||
3840 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3841 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3115 | 3842 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
2952 | 3843 |
^ ret. |
3844 |
! |
|
3845 |
||
3846 |
insert:aCharacter atLine:lineNr col:colNr |
|
3160 | 3847 |
"insert a single character at lineNr/colNr; |
2952 | 3848 |
set emphasis to character at current position" |
3849 |
||
3850 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3851 |
aCharacter ~~ Character cr ifTrue:[ |
|
3160 | 3852 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
2952 | 3853 |
] |
3854 |
! |
|
3855 |
||
3856 |
insertLines:someText from:start to:end before:lineNr |
|
3857 |
"insert a bunch of lines before line lineNr" |
|
3858 |
||
2954 | 3859 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
3860 |
srcY "{ Class: SmallInteger }" |
|
3861 |
dstY "{ Class: SmallInteger }" | |
|
3862 |
||
3863 |
autoIndent ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3864 |
indent := self leftIndentForLine:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3865 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3866 |
text := someText collect:[:ln||line| |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3867 |
ln notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3868 |
line := ln withoutLeadingSeparators. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3869 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3870 |
line := (String new:indent), line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3871 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3872 |
line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3873 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3874 |
nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3875 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3876 |
]. |
2954 | 3877 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3878 |
text := someText |
2954 | 3879 |
]. |
3880 |
||
3881 |
visLine := self listLineToVisibleLine:lineNr. |
|
3882 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3883 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3884 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3885 |
before:lineNr. |
2954 | 3886 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3887 |
nLines := end - start + 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3888 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3889 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3890 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3891 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3892 |
self redrawFromVisibleLine:visLine to:nLinesShown |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3893 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3894 |
w := self widthForScrollBetween:(lineNr + nLines) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3895 |
and:(firstLineShown + nLines + nLinesShown). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3896 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3897 |
dstY := srcY + (nLines * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3898 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3899 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3900 |
"/ scroll ... |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3901 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3902 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3903 |
stupid: must catchExpose before inserting new |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3904 |
stuff - since catchExpose may perform redraws |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3905 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3906 |
self catchExpose. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3907 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3908 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3909 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3910 |
self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3911 |
copyFrom:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3912 |
x:textStartLeft y:srcY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3913 |
toX:textStartLeft y:dstY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3914 |
width:w |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3915 |
height:(height - dstY) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3916 |
async:true. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3917 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3918 |
self waitForExpose |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3919 |
]. |
2954 | 3920 |
]. |
3921 |
widthOfWidestLine notNil ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3922 |
text do:[:line | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3923 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3924 |
] |
2954 | 3925 |
]. |
3926 |
self textChanged. |
|
3927 |
||
3928 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
2952 | 3929 |
! |
3930 |
||
3931 |
mergeLine:lineNr removeBlanks:removeBlanks |
|
3932 |
"merge line lineNr with line lineNr+1" |
|
3933 |
||
3934 |
|len| |
|
3935 |
||
3936 |
len := (self listAt:lineNr) size. |
|
3937 |
self nonUndoableDo:[ |
|
3542 | 3938 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
2952 | 3939 |
]. |
3940 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3941 |
! |
|
3942 |
||
3943 |
replace:aCharacter atLine:lineNr col:colNr |
|
3944 |
"replace a single character at lineNr/colNr" |
|
3945 |
||
3946 |
|originalChar| |
|
3947 |
||
3948 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3949 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3235 | 3950 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
2952 | 3951 |
! |
3952 |
||
3131 | 3953 |
replaceContentsWith:newContents |
3954 |
"replace everything" |
|
3955 |
||
3956 |
|originalContents| |
|
3957 |
||
3958 |
originalContents := self contents. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
3959 |
self contents:newContents keepUndoHistory:true. |
3131 | 3960 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
3961 |
! |
|
3962 |
||
3130 | 3963 |
replaceLine:lineNr with:newText |
3964 |
"replace a line at lineNr" |
|
3965 |
||
3966 |
|originalLine| |
|
3967 |
||
3968 |
originalLine := self listAt:lineNr. |
|
3479
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3969 |
originalLine isNil ifTrue:[ |
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3970 |
self checkForExistingLine:lineNr |
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3971 |
]. |
3130 | 3972 |
self list at:lineNr put:newText. |
3973 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3974 |
self invalidateLine:lineNr. |
|
3479
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3975 |
|
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3976 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
3130 | 3977 |
! |
3978 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3979 |
replaceString:aString atLine:lineNr col:colNr |
1557 | 3980 |
"replace multiple characters starting at lineNr/colNr. |
3235 | 3981 |
This is not prepared to encounter special chars (except TAB) in the string." |
3982 |
||
3983 |
|originalString| |
|
1557 | 3984 |
|
3985 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3986 |
||
3235 | 3987 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
3988 |
||
3989 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3990 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
1557 | 3991 |
! |
3992 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3993 |
splitLine:lineNr before:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3994 |
"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
|
3995 |
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
|
3996 |
|
2952 | 3997 |
self basicSplitLine:lineNr before:colNr. |
3115 | 3998 |
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
|
3999 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4000 |
|
3130 | 4001 |
withoutRedrawAt:lineNr put:aString |
4002 |
"replace a line at lineNr" |
|
4003 |
||
4004 |
|originalLine| |
|
4005 |
||
4006 |
originalLine := self listAt:lineNr. |
|
4007 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4008 |
super withoutRedrawAt:lineNr put:aString. |
|
4009 |
! |
|
4010 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4011 |
withoutRedrawInsertLine:aString before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4012 |
"insert the argument, aString before line lineNr; the string |
2954 | 4013 |
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
|
4014 |
is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4015 |
|
2952 | 4016 |
self basicWithoutRedrawInsertLine:aString before:lineNr. |
3115 | 4017 |
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
|
4018 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4019 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
"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
|
4022 |
|
2954 | 4023 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4024 |
self isReadOnly ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4025 |
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
|
4026 |
]. |
121 | 4027 |
! |
4028 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4029 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4030 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4031 |
|
2954 | 4032 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
3115 | 4033 |
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
|
4034 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4035 |
|
2752 | 4036 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4037 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4038 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4039 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4040 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4041 |
hasKeyboardFocus := true. |
2589 | 4042 |
dragIsActive := false. |
4043 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4044 |
cursorShown ifTrue: [ |
3160 | 4045 |
self drawCursor |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4046 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4047 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4048 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 4049 |
self hideCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4050 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4051 |
(button == #paste) ifTrue:[ |
3160 | 4052 |
self pasteOrReplace. |
4053 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4054 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4055 |
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
|
4056 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4057 |
"Modified: / 23.3.1999 / 13:51:40 / cg" |
121 | 4058 |
! |
4059 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4060 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4061 |
"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
|
4062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4063 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 4064 |
typeOfSelection := nil. |
4065 |
||
4066 |
dragIsActive ifTrue:[ |
|
4067 |
self unselect |
|
4068 |
]. |
|
4069 |
selectionStartLine isNil ifTrue:[ |
|
4070 |
clickCol notNil ifTrue:[ |
|
4071 |
self cursorMovementAllowed ifTrue:[ |
|
4072 |
self cursorLine:clickLine col:clickCol |
|
4073 |
] |
|
4074 |
] |
|
4075 |
] ifFalse:[ |
|
4076 |
lastString := nil. "new selection invalidates remembered string" |
|
4077 |
]. |
|
4078 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4079 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4080 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4081 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4082 |
"Modified: / 18.6.1998 / 14:14:05 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4083 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4084 |
|
2580 | 4085 |
cursorKeyPress:key shifted:shifted |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4086 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4087 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4088 |
self changeTypeOfSelectionTo:nil. |
2580 | 4089 |
|
4090 |
(key == #CursorRight) ifTrue:[ |
|
3232 | 4091 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4092 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
4093 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
4094 |
expandingTop := false. |
|
4095 |
self validateNewSelection. |
|
4096 |
self redrawLine:selectionStartLine. |
|
4097 |
^ self. |
|
4098 |
]. |
|
4099 |
||
4100 |
selectionStartLine notNil ifTrue:[ |
|
4101 |
self cursorMovementAllowed ifTrue:[ |
|
4102 |
"/ |
|
4103 |
"/ treat the whole selection as cursor |
|
4104 |
"/ |
|
3303 | 4105 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 4106 |
selectionEndCol == 0 ifTrue:[ |
4107 |
selectionEndCol := 1. |
|
4108 |
]. |
|
4109 |
self setCursorCol:selectionEndCol. |
|
4110 |
shifted ifTrue:[ |
|
4111 |
self expandSelectionRight. |
|
4112 |
^ self |
|
4113 |
]. |
|
4114 |
self unselect; makeCursorVisible. |
|
4115 |
cursorCol == 1 ifTrue:[^ self]. |
|
4116 |
]. |
|
4117 |
]. |
|
4118 |
self cursorRight. |
|
4119 |
^ self |
|
2580 | 4120 |
]. |
4121 |
(key == #CursorDown) ifTrue:[ |
|
3232 | 4122 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4123 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
4124 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
4125 |
selectionEndCol == 1 ifTrue:[ |
|
4126 |
selectionEndCol := 0. |
|
4127 |
]. |
|
4128 |
self validateNewSelection. |
|
4129 |
self redrawLine:selectionStartLine. |
|
4130 |
expandingTop := false. |
|
4131 |
self redrawLine:selectionEndLine. |
|
4132 |
^ self |
|
4133 |
]. |
|
4134 |
||
4135 |
selectionStartLine notNil ifTrue:[ |
|
4136 |
self cursorMovementAllowed ifTrue:[ |
|
4137 |
"/ |
|
4138 |
"/ treat the whole selection as cursor |
|
4139 |
"/ |
|
3303 | 4140 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 4141 |
self setCursorCol:selectionStartCol. |
4142 |
cursorCol == 0 ifTrue:[ |
|
4143 |
self setCursorCol:1. |
|
4144 |
self setCursorLine:(cursorLine - 1). |
|
4145 |
]. |
|
4146 |
self makeCursorVisible. |
|
4147 |
||
4148 |
shifted ifTrue:[ |
|
4149 |
clickLine := cursorLine. |
|
4150 |
clickCol := cursorCol. |
|
4151 |
self expandSelectionDown. |
|
4152 |
^ self |
|
4153 |
]. |
|
4154 |
self unselect. |
|
4155 |
]. |
|
4156 |
]. |
|
4157 |
||
4158 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
4159 |
self cursorDown:n. |
|
4160 |
"/ |
|
4161 |
"/ flush keyboard to avoid runaway cursor |
|
4162 |
"/ |
|
4163 |
self sensor flushKeyboardFor:self. |
|
4164 |
^ self |
|
2580 | 4165 |
]. |
4166 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
3232 | 4167 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4168 |
expandingTop := true. |
|
4169 |
key == #CursorLeft ifTrue:[ |
|
4170 |
cursorCol > 1 ifTrue:[ |
|
4171 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
4172 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
4173 |
selectionStartCol := cursorCol-1. |
|
4174 |
self validateNewSelection. |
|
4175 |
self redrawLine:selectionStartLine. |
|
4176 |
^ self |
|
4177 |
] |
|
4178 |
] ifFalse:[ |
|
4179 |
cursorLine > 1 ifTrue:[ |
|
4180 |
selectionEndLine := clickStartLine := cursorLine. |
|
4181 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
4182 |
selectionStartLine := cursorLine - 1. |
|
4183 |
selectionEndCol == 1 ifTrue:[ |
|
4184 |
selectionEndCol := 0. |
|
4185 |
]. |
|
4186 |
self validateNewSelection. |
|
4187 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
4188 |
^ self |
|
4189 |
] |
|
4190 |
] |
|
4191 |
]. |
|
4192 |
||
4193 |
selectionStartLine notNil ifTrue:[ |
|
4194 |
self cursorMovementAllowed ifTrue:[ |
|
4195 |
"/ |
|
4196 |
"/ treat the whole selection as cursor |
|
4197 |
"/ |
|
4198 |
self setCursorLine:selectionStartLine. |
|
4199 |
self setCursorCol:selectionStartCol. |
|
4200 |
(key == #CursorLeft) ifTrue:[ |
|
4201 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
4202 |
]. |
|
4203 |
self makeCursorVisible. |
|
4204 |
||
4205 |
shifted ifTrue:[ |
|
4206 |
(key == #CursorUp) ifTrue:[ |
|
4207 |
clickLine := cursorLine. |
|
4208 |
self expandSelectionUp. |
|
4209 |
] ifFalse:[ |
|
4210 |
self expandSelectionLeft. |
|
4211 |
]. |
|
4212 |
^ self |
|
4213 |
]. |
|
4214 |
self unselect. |
|
4215 |
]. |
|
4216 |
]. |
|
4217 |
(key == #CursorLeft) ifTrue:[ |
|
4218 |
self cursorLeft. ^self |
|
4219 |
]. |
|
4220 |
(key == #CursorUp) ifTrue:[ |
|
4221 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
4222 |
self cursorUp:n. |
|
4223 |
"/ |
|
4224 |
"/ flush keyboard to avoid runaway cursor |
|
4225 |
"/ |
|
4226 |
self sensor flushKeyboardFor:self. |
|
4227 |
^ self |
|
4228 |
]. |
|
2580 | 4229 |
]. |
4230 |
! |
|
4231 |
||
2952 | 4232 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4233 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4234 |
|
2978 | 4235 |
<resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept |
3235 | 4236 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
3542 | 4237 |
#SelectWord #DeleteSpaces #Join |
3235 | 4238 |
#SearchMatchingParent #SelectMatchingParents |
4239 |
#SelectToEnd #SelectFromBeginning |
|
4240 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
4241 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4242 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4243 |
#GotoLine #BeginOfText #EndOfText |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4244 |
#SelectLine #ExpandSelectionByLine |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4245 |
#InsertLine #DeleteLine |
3235 | 4246 |
#SelectLineFromBeginning |
4247 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
4248 |
#'F*' #'f*')> |
|
2017 | 4249 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4250 |
|fKeyMacros shiftPressed ctrlPressed i event cmdMacro| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4251 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4252 |
event := WindowGroup lastEventQuerySignal query. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4253 |
shiftPressed := event hasShift. |
3024 | 4254 |
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
|
4255 |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4256 |
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
|
4257 |
cmdMacro notNil ifTrue:[ |
3235 | 4258 |
self |
4259 |
undoableDo: |
|
4260 |
[ self executeKeyboardMacro:cmdMacro ] |
|
4261 |
info: key. |
|
4262 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4263 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4264 |
|
3257 | 4265 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3235 | 4266 |
selectionStartLine notNil ifTrue:[ |
3326 | 4267 |
((key == #BasicBackspace) |
4268 |
or:[ UserPreferences current deleteSetsClipboardText not ]) |
|
4269 |
ifTrue:[ |
|
3235 | 4270 |
self deleteSelection. |
4271 |
] ifFalse: [ |
|
4272 |
self copyAndDeleteSelection. |
|
4273 |
]. |
|
4274 |
^ self |
|
4275 |
]. |
|
4276 |
||
4277 |
self makeCursorVisible. |
|
4278 |
shiftPressed ifTrue:[ |
|
4279 |
self deleteWordBeforeCursor. |
|
4280 |
] ifFalse:[ |
|
4281 |
self deleteCharBeforeCursor. |
|
4282 |
]. |
|
4283 |
||
4284 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4285 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4286 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4287 |
(key == #LearnKeyboardMacro) ifTrue:[ |
3235 | 4288 |
self toggleLearnMode. |
4289 |
^ self |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4290 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4291 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
3235 | 4292 |
self executeLearnedKeyboardMacro. |
4293 |
^ self. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4294 |
]. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4295 |
self learnMode ifTrue:[ |
3235 | 4296 |
learnedMacro add:event. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4297 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4298 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4299 |
(key isMemberOf:Character) ifTrue:[ |
3235 | 4300 |
self handleNonCommandKey:key. |
4301 |
^ self |
|
4302 |
]. |
|
4303 |
||
4304 |
key == #ToggleInsertMode ifTrue:[ |
|
4305 |
editMode value == EditMode insertMode ifTrue:[ |
|
4306 |
editMode value:(EditMode overwriteMode). |
|
4307 |
^ self. |
|
4308 |
]. |
|
4309 |
editMode value == EditMode overwriteMode ifTrue:[ |
|
4310 |
editMode value:(EditMode insertAndSelectMode). |
|
4311 |
^ self. |
|
4312 |
]. |
|
4313 |
editMode value == EditMode insertAndSelectMode ifTrue:[ |
|
4314 |
editMode value:(EditMode insertMode). |
|
4315 |
^ self. |
|
4316 |
]. |
|
4317 |
^ self. |
|
3160 | 4318 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4319 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4320 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4321 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4322 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4323 |
Fn pastes a key-sequence (but only if not overlayed with |
3235 | 4324 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4325 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4326 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4327 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4328 |
(key at:1) asLowercase == $f ifTrue:[ |
3235 | 4329 |
(('[fF][0-9]' match:key) |
4330 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4331 |
shiftPressed ifFalse:[ |
|
4332 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
4333 |
fKeyMacros notNil ifTrue:[ |
|
4334 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4335 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4336 |
^ self |
|
4337 |
] |
|
4338 |
] |
|
4339 |
] |
|
4340 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4341 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4342 |
|
2506 | 4343 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3235 | 4344 |
self parenthizeSelectionWith:$( and:$). |
4345 |
^ self. |
|
2506 | 4346 |
]. |
4347 |
(key == #'Ctrl2') ifTrue:[ |
|
3235 | 4348 |
self parenthizeSelectionWith:$" and:$". |
4349 |
^ self. |
|
2506 | 4350 |
]. |
4351 |
(key == #'Ctrl#') ifTrue:[ |
|
3235 | 4352 |
self parenthizeSelectionWith:$' and:$'. |
4353 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4354 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4355 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4356 |
(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
|
4357 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4358 |
((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4359 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4360 |
(key == #Again) ifTrue:[self again. ^self]. |
2978 | 4361 |
(key == #Undo) ifTrue:[self undo. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4362 |
|
3542 | 4363 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4364 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4365 |
(key == #SelectWord) ifTrue:[ |
3235 | 4366 |
self makeCursorVisible. |
4367 |
self selectWordUnderCursor. |
|
4368 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4369 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4370 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4371 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4372 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4373 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4374 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4376 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4377 |
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
|
4378 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
4379 |
(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
|
4380 |
(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
|
4381 |
(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
|
4382 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4383 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4384 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4385 |
(key == #BeginOfLine) ifTrue:[ |
3235 | 4386 |
shiftPressed ifTrue: [ |
4387 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4388 |
"/ self unselect. |
|
4389 |
"/ self cursorHome. |
|
4390 |
"Jan's modification" |
|
4391 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
4392 |
] ifFalse: [ |
|
4393 |
self unselect. |
|
4394 |
ctrlPressed ifTrue:[ |
|
4395 |
self cursorHome. |
|
4396 |
] ifFalse:[ |
|
4397 |
self cursorToBeginOfLine. |
|
4398 |
] |
|
4399 |
]. |
|
4400 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4401 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4402 |
(key == #EndOfLine) ifTrue:[ |
3235 | 4403 |
shiftPressed ifTrue:[ |
4404 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4405 |
"/ self unselect. |
|
4406 |
"/ self cursorToBottom |
|
4407 |
"Jan's modification" |
|
4408 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
4409 |
] ifFalse:[ |
|
4410 |
self unselect. |
|
4411 |
ctrlPressed ifTrue:[ |
|
4412 |
self cursorToBottom |
|
4413 |
] ifFalse:[ |
|
4414 |
self cursorToEndOfLine. |
|
4415 |
] |
|
4416 |
]. |
|
4417 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4418 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4419 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 4420 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 4421 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4422 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4423 |
|
2580 | 4424 |
(key == #CursorRight |
4425 |
or:[key == #CursorDown |
|
4426 |
or:[key == #CursorLeft |
|
4427 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3235 | 4428 |
self cursorKeyPress:key shifted:shiftPressed. |
4429 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4430 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4431 |
|
3257 | 4432 |
(key == #NonInsertingReturn) ifTrue:[ |
4433 |
self unselect. self cursorReturn. |
|
4434 |
^ self |
|
4435 |
]. |
|
4436 |
||
4437 |
(key == #Return) ifTrue:[ |
|
3235 | 4438 |
shiftPressed ifTrue:[ |
4439 |
self unselect. self cursorReturn. |
|
4440 |
^ self |
|
4441 |
]. |
|
4442 |
self isReadOnly ifTrue:[ |
|
4443 |
self unselect; makeCursorVisible. |
|
4444 |
self cursorReturn |
|
4445 |
] ifFalse:[ |
|
4446 |
self isInInsertMode ifFalse:[ |
|
4447 |
self cursorReturn. |
|
4448 |
autoIndent == true ifTrue:[ |
|
4449 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4450 |
self cursorCol:(i+1 max:1) |
|
4451 |
] |
|
4452 |
] ifTrue:[ |
|
4453 |
"/ old version just unselected ... |
|
4454 |
"/ self unselect; makeCursorVisible. |
|
4455 |
||
4456 |
"/ new version deletes ... |
|
4457 |
typeOfSelection == #paste ifTrue:[ |
|
4458 |
self unselect; makeCursorVisible. |
|
4459 |
] ifFalse:[ |
|
4460 |
self copyAndDeleteSelection. |
|
4461 |
]. |
|
4462 |
self insertCharAtCursor:(Character cr). |
|
4463 |
autoIndent == true ifTrue:[ |
|
4464 |
i := self leftIndentForLine:cursorLine. |
|
4465 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
4466 |
self cursorCol:(i+1 max:1) |
|
4467 |
]. |
|
4468 |
]. |
|
4469 |
]. |
|
4470 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4471 |
]. |
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
|
4472 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4473 |
(key == #NonInsertingTab) ifTrue:[ |
3235 | 4474 |
self unselect. self cursorTab. |
4475 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4476 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4477 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3235 | 4478 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4479 |
|
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4480 |
self hasSelection ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4481 |
selectStyle == #line ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4482 |
fKeyMacros := UserPreferences current functionKeySequences. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4483 |
fKeyMacros notNil ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4484 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4485 |
cmdMacro := fKeyMacros at:#IndentBy4 ifAbsent:nil. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4486 |
] ifFalse:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4487 |
cmdMacro := fKeyMacros at:#UndentBy4 ifAbsent:nil. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4488 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4489 |
cmdMacro notNil ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4490 |
self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4491 |
undoableDo: |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4492 |
[ self executeKeyboardMacro:cmdMacro ] |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4493 |
info:'IndentBy4'. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4494 |
^ self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4495 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4496 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4497 |
] |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4498 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4499 |
|
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4500 |
self unselect. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4501 |
(key == #Tab) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4502 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4503 |
self cursorTab. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4504 |
^ self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4505 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4506 |
self insertTabAtCursor. |
3257 | 4507 |
^ self |
3235 | 4508 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4509 |
self cursorBacktab. |
3235 | 4510 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4511 |
]. |
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
|
4512 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4513 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4514 |
(key == #Delete) ifTrue:[ |
3235 | 4515 |
shiftPressed ifTrue:[ |
4516 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
4517 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4518 |
self makeCursorVisible. |
3235 | 4519 |
self deleteCharAtCursor. |
4520 |
]. |
|
4521 |
^ self |
|
4522 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4523 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4524 |
|
870 | 4525 |
(key == #Delete |
4526 |
or:[key == #BasicDelete]) ifTrue:[ |
|
3235 | 4527 |
selectionStartLine notNil ifTrue:[ |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4528 |
((key == #BasicDelete) |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4529 |
or:[UserPreferences current deleteSetsClipboardText not]) ifTrue:[ |
3235 | 4530 |
self deleteSelection. |
4531 |
] ifFalse:[ |
|
4532 |
self copyAndDeleteSelection. |
|
4533 |
]. |
|
4534 |
^ self |
|
4535 |
]. |
|
4536 |
self makeCursorVisible. |
|
4537 |
self deleteCharAtCursor. |
|
4538 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4539 |
]. |
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
|
4540 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4541 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3235 | 4542 |
self unselect. |
4543 |
cursorVisibleLine == 1 ifTrue:[ |
|
4544 |
self cursorHome. |
|
4545 |
] ifFalse:[ |
|
4546 |
self cursorToFirstVisibleLine |
|
4547 |
]. |
|
4548 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4549 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4550 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3235 | 4551 |
self unselect. |
4552 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
4553 |
self cursorToBottom. |
|
4554 |
] ifFalse:[ |
|
4555 |
self cursorToLastVisibleLine |
|
4556 |
]. |
|
4557 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4558 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4559 |
((key == #Escape) |
3257 | 4560 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3235 | 4561 |
self makeCursorVisible. |
4562 |
self unselect. self selectCursorLineFromBeginning. |
|
4563 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4564 |
]. |
3257 | 4565 |
(key == #SelectLine) ifTrue:[ |
3235 | 4566 |
self makeCursorVisible. |
4567 |
self unselect. self selectCursorLine. |
|
4568 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4569 |
]. |
3257 | 4570 |
(key == #ExpandSelectionByLine) ifTrue:[ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4571 |
"/ self makeCursorVisible. |
3235 | 4572 |
self selectExpandCursorLine. |
4573 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4574 |
]. |
3257 | 4575 |
(key == #DeleteLine) ifTrue:[ |
3235 | 4576 |
self makeCursorVisible. |
4577 |
self unselect. self deleteCursorLine. |
|
4578 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4579 |
]. |
3257 | 4580 |
(key == #InsertLine) ifTrue:[ |
3235 | 4581 |
self makeCursorVisible. |
4582 |
self unselect. self insertLine:nil before:cursorLine. |
|
4583 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4584 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4585 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4586 |
|
3310 | 4587 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4588 |
"Modified: / 28-10-2006 / 15:37:47 / cg" |
121 | 4589 |
! |
4590 |
||
2952 | 4591 |
executeKeyboardMacro:cmdMacro |
4592 |
Error handle:[:ex | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4593 |
self warn:'Error in keyboard macro: ' , ex description. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4594 |
ex return. |
2952 | 4595 |
] do:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4596 |
AbortOperationRequest handle:[:ex | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4597 |
self warn:'Keyboard macro aborted'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4598 |
ex return. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4599 |
] do:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4600 |
Parser |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4601 |
evaluate:cmdMacro asString |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4602 |
receiver:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4603 |
notifying:nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4604 |
compile:false. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4605 |
]. |
2952 | 4606 |
]. |
4607 |
! |
|
4608 |
||
4609 |
handleNonCommandKey:keyArg |
|
4610 |
|selStartLine selStartCol selEndLine selEndCol sel key| |
|
4611 |
||
4612 |
self isReadOnly ifTrue:[ |
|
3235 | 4613 |
self flash. |
4614 |
^ self. |
|
2952 | 4615 |
]. |
4616 |
||
4617 |
key := keyArg. |
|
4618 |
||
4619 |
typeOfSelection == #paste ifTrue:[ |
|
3235 | 4620 |
"pasted selection will NOT be replaced by keystroke" |
4621 |
self unselect |
|
2952 | 4622 |
]. |
4623 |
||
4624 |
selStartLine := selectionStartLine. |
|
4625 |
selStartCol := self selectionStartCol. |
|
4626 |
selEndLine := selectionEndLine. |
|
4627 |
selEndCol := self selectionEndCol. |
|
4628 |
sel := self selection. |
|
4629 |
||
4630 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
|
3235 | 4631 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
2952 | 4632 |
]. |
4633 |
||
4634 |
"replace selection by what is typed in - |
|
3235 | 4635 |
if word was selected with a space, keep it. |
4636 |
if there was no selection, the keys character is inserted" |
|
4637 |
||
4638 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4639 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
|
4640 |
]. |
|
2952 | 4641 |
|
4642 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3235 | 4643 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 4644 |
] ifFalse:[ |
3235 | 4645 |
(selectStyle == #wordRight) ifTrue:[ |
4646 |
self replaceSelectionBy:(key asString , ' '). |
|
4647 |
self cursorLeft |
|
4648 |
] ifFalse:[ |
|
4649 |
self replaceSelectionBy:key |
|
4650 |
] |
|
3160 | 4651 |
]. |
2952 | 4652 |
selectStyle := nil. |
4653 |
||
3235 | 4654 |
editMode value isInsertAndSelectMode ifTrue:[ |
4655 |
selectionStartLine := selStartLine. |
|
4656 |
selectionStartCol := selStartCol. |
|
4657 |
selectionEndLine := selEndLine. |
|
4658 |
selectionEndCol := selEndCol. |
|
4659 |
]. |
|
4660 |
||
2952 | 4661 |
showMatchingParenthesis ifTrue:[ |
3235 | 4662 |
"emacs style parenthesis shower" |
4663 |
||
4664 |
"claus: only do it for closing parenthesis - |
|
4665 |
otherwise its too anoying. |
|
4666 |
" |
|
2952 | 4667 |
" |
3235 | 4668 |
(#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[ |
2952 | 4669 |
" |
3235 | 4670 |
(#( $) $] $} ) includes:key) ifTrue:[ |
4671 |
self |
|
4672 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
4673 |
ifFound:[:line :col | |
|
4674 |
|savLine savCol sensor| |
|
4675 |
||
4676 |
self withCursor:Cursor eye do:[ |
|
4677 |
savLine := cursorLine. |
|
4678 |
savCol := cursorCol. |
|
4679 |
self cursorLine:line col:col. |
|
4680 |
device flush. |
|
4681 |
||
4682 |
"/ want to wait 200ms, but not if another keyPress |
|
4683 |
"/ arrives in the meantime ... |
|
4684 |
||
4685 |
sensor := self sensor. |
|
4686 |
5 timesRepeat:[ |
|
4687 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
4688 |
Processor activeProcess millisecondDelay:40. |
|
4689 |
] |
|
4690 |
]. |
|
4691 |
self cursorLine:savLine col:savCol |
|
4692 |
] |
|
4693 |
] |
|
4694 |
ifNotFound:[self showNotFound] |
|
4695 |
onError:[self beep] |
|
4696 |
]. |
|
2952 | 4697 |
]. |
4698 |
||
4699 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
4700 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
4701 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
4702 |
"/ |
|
4703 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4704 |
"/ self selection. |
|
4705 |
"/ typeOfSelection := #paste. |
|
3160 | 4706 |
"/ ]. |
3235 | 4707 |
"/ ]. |
4708 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4709 |
selectionStartLine isNil ifTrue:[ |
|
4710 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
4711 |
] ifFalse:[ |
|
4712 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
4713 |
]. |
|
4714 |
]. |
|
2952 | 4715 |
! |
4716 |
||
4717 |
keyPress:key x:x y:y |
|
4718 |
"handle keyboard input" |
|
4719 |
||
4720 |
self undoableDo:[ |
|
3160 | 4721 |
self doKeyPress:key x:x y:y |
2952 | 4722 |
]. |
4723 |
! |
|
4724 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4725 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4726 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4727 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4728 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4729 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4730 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4731 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4732 |
requestAutoAccept |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4733 |
"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
|
4734 |
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
|
4735 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4736 |
acceptEnabled == false ifTrue:[ |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4737 |
"/ nope - |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4738 |
^ false |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4739 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4740 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4741 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4742 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4743 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4744 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4745 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4746 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4747 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4748 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4749 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4750 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4751 |
cv notNil ifTrue:[ |
3160 | 4752 |
self makeLineVisible:cursorLine |
259
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 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4755 |
|
1807 | 4756 |
!EditTextView methodsFor:'focus handling'! |
4757 |
||
4758 |
hasKeyboardFocus:aBoolean |
|
4759 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
4760 |
(otherwise, I would not know about this)" |
|
4761 |
||
4762 |
hasKeyboardFocus := aBoolean. |
|
3160 | 4763 |
(cursorShown |
4764 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4765 |
and:[self isReadOnly not]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4766 |
self drawCursor |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4767 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4768 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4769 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 4770 |
! |
4771 |
||
4772 |
showFocus:explicit |
|
4773 |
"in addition to however my superclass thinks how a focusView is to be |
|
4774 |
displayed, show the cursor when I got the focus" |
|
4775 |
||
4776 |
self showCursor. |
|
4777 |
self hasKeyboardFocus:true. |
|
4778 |
super showFocus:explicit |
|
4779 |
||
4780 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4781 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4782 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4783 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4784 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4785 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4786 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4787 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4788 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4789 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4790 |
and:[self isReadOnly not]]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4791 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4792 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4793 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4794 |
^ false |
1807 | 4795 |
! ! |
4796 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4797 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4798 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4799 |
indent |
3221 | 4800 |
"indent a line-range - this is done by searching for the |
4801 |
last non-empty line before the selection, and changing the indent |
|
4802 |
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
|
4803 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4804 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4805 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4806 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 4807 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4808 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4809 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4810 |
(selectionEndCol == 0) ifTrue:[ |
3221 | 4811 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4812 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4813 |
self unselect. |
3160 | 4814 |
self |
3221 | 4815 |
undoableDo:[ |
4816 |
self indentFromLine:start toLine:end |
|
4817 |
] |
|
4818 |
info:'indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4819 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4820 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4821 |
indentFromLine:start toLine:end |
3221 | 4822 |
"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
|
4823 |
last non-empty line before start, and change the indent |
3221 | 4824 |
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
|
4825 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4826 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4827 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4828 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4829 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4830 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4831 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4832 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4833 |
(delta > 0) ifTrue:[ |
3221 | 4834 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4835 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4836 |
start to:end do:[:lineNr | |
3221 | 4837 |
line := self listAt:lineNr. |
4838 |
line notNil ifTrue:[ |
|
4839 |
line isBlank ifTrue:[ |
|
4840 |
list at:lineNr put:nil |
|
4841 |
] ifFalse:[ |
|
4842 |
(delta > 0) ifTrue:[ |
|
4843 |
line := spaces , line. |
|
4844 |
widthOfWidestLine notNil ifTrue:[ |
|
4845 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4846 |
] |
|
4847 |
] ifFalse:[ |
|
4848 |
"check if deletion is ok" |
|
4849 |
d := delta negated + 1. |
|
4850 |
||
4851 |
line size > d ifTrue:[ |
|
4852 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
4853 |
line := line copyFrom:d |
|
4854 |
] |
|
4855 |
]. |
|
4856 |
widthOfWidestLine := nil |
|
4857 |
]. |
|
4858 |
self replaceLine:lineNr with:line. |
|
4859 |
self textChanged. |
|
4860 |
] |
|
4861 |
] |
|
4862 |
]. |
|
4863 |
"/ self redrawFromLine:start to:end |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4864 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4865 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4866 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4867 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4868 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4869 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4870 |
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
|
4871 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4872 |
|
827 | 4873 |
"SHOULD GO TO ListView" |
4874 |
||
4875 |
|line lnr indent| |
|
4876 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4877 |
lnr := lineNr. |
827 | 4878 |
|
4879 |
[lnr ~~ 1] whileTrue:[ |
|
3160 | 4880 |
lnr := lnr - 1. |
4881 |
line := self listAt:lnr. |
|
4882 |
||
4883 |
line notNil ifTrue:[ |
|
4884 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
4885 |
indent ~~ 0 ifTrue:[ |
|
4886 |
^ indent - 1 |
|
4887 |
] |
|
4888 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4889 |
]. |
827 | 4890 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4891 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4892 |
"Created: 5.3.1996 / 14:58:53 / cg" |
105 | 4893 |
! ! |
4894 |
||
0 | 4895 |
!EditTextView methodsFor:'initialization'! |
4896 |
||
941 | 4897 |
fetchDeviceResources |
4898 |
"fetch device colors, to avoid reallocation at redraw time" |
|
4899 |
||
4900 |
super fetchDeviceResources. |
|
4901 |
||
1993 | 4902 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
4903 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
4904 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 4905 |
|
4906 |
"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
|
4907 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 4908 |
! |
4909 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4910 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4911 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4912 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4913 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4914 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4915 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4916 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4917 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4918 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4919 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4920 |
super initStyle. |
2088 | 4921 |
lineSpacing := 1. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4922 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4923 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4924 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4925 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4926 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4927 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 4928 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4929 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
3160 | 4930 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4931 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4932 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4933 |
cursorNoFocusFgColor isNil ifTrue:[ |
3160 | 4934 |
cursorType ~~ #block ifTrue:[ |
4935 |
cursorNoFocusFgColor := cursorBgColor |
|
4936 |
] ifFalse:[ |
|
4937 |
cursorNoFocusFgColor := cursorFgColor |
|
4938 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4939 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4940 |
|
2088 | 4941 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4942 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4944 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4945 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4946 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4947 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4948 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4949 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4950 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4951 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4952 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4953 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4954 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4955 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4956 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4957 |
cursorCol := 1. |
2815 | 4958 |
cursorLineHolder := 1 asValue. |
4959 |
cursorColHolder := 1 asValue. |
|
2119 | 4960 |
modifiedChannel := ValueHolder with:false. |
4961 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
4962 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4963 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4964 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4965 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4966 |
autoIndent := false. |
3235 | 4967 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4968 |
learnMode := false asValue. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4969 |
trimBlankLines := self st80EditMode not. |
2131 | 4970 |
cursorMovementWhenUpdating := #beginOfText. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
4971 |
|
3236 | 4972 |
"/ enable drop by default |
2589 | 4973 |
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
|
4974 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4975 |
undoSupport := UndoSupport for:self. |
0 | 4976 |
! ! |
4977 |
||
2580 | 4978 |
!EditTextView methodsFor:'macros'! |
4979 |
||
4980 |
executeLearnedKeyboardMacro |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4981 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3160 | 4982 |
learnedMacro do:[:event | |
4983 |
WindowGroup lastEventQuerySignal answer:event |
|
4984 |
do:[ |
|
4985 |
self |
|
4986 |
dispatchEvent:event |
|
4987 |
withFocusOn:nil |
|
4988 |
delegate:false |
|
4989 |
] |
|
4990 |
]. |
|
2580 | 4991 |
] ifFalse:[ |
3160 | 4992 |
self flash. |
2580 | 4993 |
]. |
4994 |
! |
|
4995 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4996 |
learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4997 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4998 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4999 |
|
2580 | 5000 |
learnMode:aBoolean |
5001 |
|fg bg| |
|
5002 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5003 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5004 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5005 |
aBoolean ifTrue:[ |
3160 | 5006 |
learnedMacro := OrderedCollection new. |
5007 |
fg := Color white. |
|
5008 |
bg := Color black. |
|
2580 | 5009 |
] ifFalse:[ |
3160 | 5010 |
cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor. |
5011 |
cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor. |
|
2580 | 5012 |
]. |
5013 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5014 |
! |
|
5015 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5016 |
learnModeHolder |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5017 |
learnMode isNil ifTrue:[ |
3160 | 5018 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5019 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5020 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5021 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5022 |
|
2580 | 5023 |
toggleLearnMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5024 |
self learnMode: self learnMode not. |
2580 | 5025 |
! ! |
5026 |
||
121 | 5027 |
!EditTextView methodsFor:'menu actions'! |
5028 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5029 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5030 |
"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
|
5031 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5032 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5033 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5034 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5035 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5036 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5037 |
self withWaitCursorDo:[ |
3495 | 5038 |
SOAP::SoapImplError handle:[:ex | |
5039 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
5040 |
] do:[ |
|
5041 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5042 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5043 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5044 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5045 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5046 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5047 |
self unselect. |
3495 | 5048 |
self undoablePaste:translated info:'translate' |
5049 |
||
5050 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5051 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5052 |
|
3517 | 5053 |
compareWithClipboard |
5054 |
"compare the selection against the clipboard contents" |
|
5055 |
||
5056 |
|t1 t2| |
|
5057 |
||
5058 |
t2 := self getClipboardText. |
|
5059 |
t2 isEmptyOrNil ifTrue:[ |
|
5060 |
Dialog information:'Clipboard is empty.'. |
|
5061 |
^ self. |
|
5062 |
]. |
|
5063 |
||
5064 |
self hasSelection ifTrue:[ |
|
5065 |
t1 := self selectionAsString. |
|
5066 |
] ifFalse:[ |
|
5067 |
t1 := self contents asString |
|
5068 |
]. |
|
5069 |
t1 := t1 string. |
|
5070 |
||
5071 |
t1 = t2 ifTrue:[ |
|
5072 |
Dialog information:'Strings are equal.'. |
|
5073 |
^ self. |
|
5074 |
]. |
|
5075 |
DiffTextView |
|
5076 |
openOn:t1 label:'Editor' |
|
5077 |
and:t2 label:'Clipboard' |
|
5078 |
! |
|
5079 |
||
121 | 5080 |
cut |
5081 |
"cut selection into copybuffer" |
|
5082 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5083 |
self deleteCopyToClipboard:true |
121 | 5084 |
! |
5085 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5086 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5087 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5088 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5089 |
cursorLine notNil ifTrue:[ |
3160 | 5090 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5091 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5092 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5093 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5094 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5095 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5096 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5097 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5098 |
|line col history sel s| |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5099 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5100 |
(self checkModificationsAllowed) ifFalse:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5101 |
self flash. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5102 |
^ self |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5103 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5104 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5105 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5106 |
sel notNil ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5107 |
lastString := s := sel asStringWithCRs. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5108 |
line := selectionStartLine. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5109 |
col := selectionStartCol. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5110 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5111 |
toClipboard ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5112 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5113 |
remember in CopyBuffer |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5114 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5115 |
self setClipboardText:sel. "/ lastString. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5116 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5117 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5118 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5119 |
append to DeleteHistory (if there is one) |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5120 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5121 |
history := Smalltalk at:#DeleteHistory. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5122 |
history notNil ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5123 |
history addAll:(sel asStringCollection). |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5124 |
history size > 1000 ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5125 |
history := history copyFrom:(history size - 1000) |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5126 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5127 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5128 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5129 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5130 |
now, delete it |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5131 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5132 |
self undoableDo:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5133 |
self deleteSelection. |
3542 | 5134 |
] info:'Delete'. |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5135 |
lastReplacement := nil |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5136 |
] ifFalse:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5137 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5138 |
a cut without selection will search&cut again |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5139 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5140 |
self undoableDo:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5141 |
self again |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5142 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5143 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5144 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5145 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5146 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5147 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5148 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5149 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5150 |
|
3566 | 5151 |
<resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print |
5152 |
#PasteFromHistory #Join #Undo)> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
5153 |
<resource: #programMenu> |
1054 | 5154 |
|
3495 | 5155 |
|items m sub translateItems sortItems miscItems toolItems subSub toolSub |
5156 |
transSub sortSub what undoIdx sensor main mainItems| |
|
1515 | 5157 |
|
2460 | 5158 |
items := #( |
3221 | 5159 |
('Redo' redo ) |
5160 |
('Again (for All)' multipleAgain ) |
|
5161 |
('-' ) |
|
5162 |
('Search...' search Find ) |
|
5163 |
('Goto Line...' gotoLine GotoLine ) |
|
5164 |
('-' ) |
|
5165 |
('Tools' tools ) |
|
5166 |
('-' ) |
|
5167 |
('Save As...' save SaveAs ) |
|
5168 |
('Print' doPrint Print ) |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5169 |
('=' ) |
3495 | 5170 |
('Misc' misc ShiftCtrl) |
3221 | 5171 |
). |
2460 | 5172 |
|
2866 | 5173 |
miscItems := #( |
3221 | 5174 |
('AutoIndent \c' autoIndent: ) |
5175 |
('InsertMode \c' insertMode: ) |
|
5176 |
('-' ) |
|
3566 | 5177 |
('Paste Previous' pasteOrReplaceFromHistory PasteFromHistory ) |
3550 | 5178 |
('Join Lines' joinLines Join ) |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5179 |
('-' ) |
3550 | 5180 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
3221 | 5181 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
5182 |
('-' ) |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5183 |
('Insert File...' insertFile ) |
3495 | 5184 |
('Insert new UUID' insertUUID ) |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5185 |
('-' ) |
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5186 |
). |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5187 |
CharacterSetView notNil ifTrue:[ |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5188 |
miscItems := miscItems , |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5189 |
#( |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5190 |
('Special Characters...' specialCharacters ) |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5191 |
). |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5192 |
]. |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5193 |
miscItems := miscItems , |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5194 |
#( |
3223 | 5195 |
('Font...' changeFont ) |
2870 | 5196 |
"/ ('Encoding...' changeEncoding ) |
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5197 |
). |
2866 | 5198 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5199 |
translateItems := #( |
3221 | 5200 |
('English -> German' (babelFishTranslate: 'en_de') ) |
5201 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
5202 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
5203 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
5204 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
5205 |
('-' ) |
|
5206 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
5207 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
5208 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
5209 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
5210 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
5211 |
). |
|
5212 |
||
5213 |
sortItems := #( |
|
5214 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
|
5215 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
5216 |
('Lines by nth Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
5217 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
5218 |
('-' ) |
|
5219 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
5220 |
('Lines by First Word (ignore case)'(sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
5221 |
('Lines by nth Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
5222 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
5223 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5224 |
|
2762 | 5225 |
toolItems := #( |
3221 | 5226 |
('Indent' indent ) |
5227 |
('Sort' sort ) |
|
5228 |
('-' ) |
|
5229 |
('Google Spell' googleSpellingSuggestion ) |
|
5230 |
('Translate' babelFishTranslate ) |
|
3517 | 5231 |
('Compare with Clipboard...' compareWithClipboard ) |
3221 | 5232 |
('-' ) |
5233 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5234 |
('Open Workspace with It' openWorkspaceWithIt ) |
3221 | 5235 |
). |
2762 | 5236 |
|
2460 | 5237 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 5238 |
sub receiver:self. |
2460 | 5239 |
|
2919 | 5240 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
5241 |
toolSub receiver:self. |
|
5242 |
sub subMenuAt:#tools put:toolSub. |
|
5243 |
||
3495 | 5244 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
5245 |
transSub receiver:self. |
|
5246 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
5247 |
||
5248 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
5249 |
sortSub receiver:self. |
|
5250 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 5251 |
|
2866 | 5252 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
5253 |
subSub receiver:self. |
|
2952 | 5254 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 5255 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 5256 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
2866 | 5257 |
sub subMenuAt:#misc put:subSub. |
5258 |
||
3495 | 5259 |
mainItems := #( |
5260 |
('Undo' undo Undo ) |
|
5261 |
('Again' again Again ) |
|
5262 |
('-' ) |
|
5263 |
('Cut' cut Cut ) |
|
5264 |
('Copy' copySelection Copy ) |
|
5265 |
('Paste' pasteOrReplace Paste ) |
|
5266 |
('-' ) |
|
5267 |
('Accept' accept Accept ) |
|
5268 |
('=' ) |
|
5269 |
('More' others Ctrl ) |
|
5270 |
). |
|
5271 |
main := PopUpMenu itemList:mainItems resources:resources. |
|
5272 |
main subMenuAt:#others put:sub. |
|
5273 |
||
5274 |
sensor := self sensor. |
|
5275 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
5276 |
sensor shiftDown ifTrue:[ |
|
5277 |
m := subSub |
|
5278 |
] ifFalse:[ |
|
5279 |
m := sub |
|
5280 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5281 |
] ifFalse:[ |
3495 | 5282 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5283 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5284 |
|
2676 | 5285 |
SOAP::GoogleClient isNil ifTrue:[ |
3221 | 5286 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
5287 |
m disable:#googleSpellingSuggestion |
|
2676 | 5288 |
]. |
5289 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5290 |
self isReadOnly ifTrue:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5291 |
m disableAll:#(undo again multipleAgain redo paste pasteOrReplace cut indent autoIndent: insertMode: |
3223 | 5292 |
insertFile babelFishTranslate googleSpellingSuggestion sort) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5293 |
]. |
2817 | 5294 |
self hasSelectionForCopy ifFalse:[ |
3221 | 5295 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5296 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5297 |
self hasSelection ifFalse:[ |
3223 | 5298 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt sort indent). |
2762 | 5299 |
] ifTrue:[ |
3221 | 5300 |
(Error handle:[:ex | |
5301 |
ex return:false |
|
5302 |
] do:[ |
|
5303 |
self selectionAsString asSingleByteString asFilename exists |
|
5304 |
]) ifFalse:[ |
|
5305 |
m disableAll:#(openFileBrowserOnIt). |
|
5306 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5307 |
]. |
2569 | 5308 |
self hasUndoAction ifFalse:[ |
3221 | 5309 |
m disable:#undo. |
3115 | 5310 |
] ifTrue:[ |
3221 | 5311 |
what := undoSupport undoActionInfo. |
5312 |
what notNil ifTrue:[ |
|
5313 |
undoIdx := m indexOf:#undo. |
|
5314 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
5315 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
5316 |
]. |
2952 | 5317 |
self hasRedoAction ifFalse:[ |
3221 | 5318 |
m disable:#redo. |
2952 | 5319 |
]. |
1108 | 5320 |
acceptEnabled == false ifTrue:[ |
3221 | 5321 |
m disable:#accept |
1108 | 5322 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5323 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5324 |
|
3495 | 5325 |
"Modified: / 28-07-2007 / 13:15:38 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5326 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5327 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5328 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5329 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5330 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5331 |
history := device getCopyBufferHistory copy. |
3160 | 5332 |
list := history collect:[:entry | |
3473 | 5333 |
|text shown| |
5334 |
||
5335 |
text := entry asString string asCollectionOfLines. |
|
5336 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
5337 |
text size > 1 ifTrue:[ |
|
5338 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
|
5339 |
]. |
|
5340 |
shown |
|
5341 |
]. |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5342 |
box := ListSelectionBox |
3473 | 5343 |
title:'CopyBuffer History' |
5344 |
okText:'Paste' |
|
5345 |
abortText:'Cancel' |
|
5346 |
list:list |
|
5347 |
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
|
5348 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5349 |
box show. |
3160 | 5350 |
^ sel. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5351 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5352 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5353 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5354 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5355 |
self sensor shiftDown ifTrue:[ |
3160 | 5356 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5357 |
]. |
2724 | 5358 |
|
5359 |
"/ return either the (xterm-) selection or the clipBoard |
|
3160 | 5360 |
^ self |
5361 |
getClipboardText:(self sensor ctrlDown |
|
5362 |
ifTrue:#selection |
|
5363 |
ifFalse:#clipboard) |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5364 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5365 |
|
2676 | 5366 |
googleSpellingSuggestion |
5367 |
"insert the google-spelling suggestion for the selected text. |
|
5368 |
Requires that the SOAP stuff is loaded and working." |
|
5369 |
||
2677 | 5370 |
|text suggestion| |
2676 | 5371 |
|
5372 |
self withWaitCursorDo:[ |
|
3495 | 5373 |
text := self selection asString string withoutSeparators. |
5374 |
text size == 0 ifTrue:[^ self]. |
|
5375 |
||
5376 |
SOAP::SoapImplError handle:[:ex | |
|
5377 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
5378 |
^ self. |
|
5379 |
] do:[ |
|
5380 |
suggestion := SOAP::GoogleClient new spellingSuggestionOf:text. |
|
5381 |
]. |
|
5382 |
suggestion size == 0 ifTrue:[ |
|
5383 |
Transcript showCR:'No SpellingSuggestion from Google for: ' , text. |
|
5384 |
^ self. |
|
5385 |
]. |
|
5386 |
]. |
|
5387 |
self undoablePaste:suggestion info:'spelling suggestion'. |
|
5388 |
||
5389 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 5390 |
! |
5391 |
||
5392 |
insertFile |
|
3160 | 5393 |
"insert contents of a file |
2676 | 5394 |
- ask user for filename using a fileSelectionBox." |
5395 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5396 |
|sel selFn file text ok initial| |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5397 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5398 |
((sel := self selectionAsString) notEmptyOrNil |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5399 |
and:[ (selFn := sel asFilename) exists |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5400 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5401 |
ifTrue:[ |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5402 |
initial := selFn pathName. |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5403 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5404 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5405 |
[ |
3190 | 5406 |
|why| |
5407 |
||
5408 |
file := Dialog |
|
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5409 |
requestFileName:(resources string:'Insert Contents Of:') |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5410 |
default:initial |
3190 | 5411 |
ok:(resources string:'Insert') |
5412 |
abort:(resources string:'Cancel') |
|
5413 |
pattern:nil |
|
5414 |
fromDirectory:directoryForFileDialog. |
|
5415 |
file isNil ifTrue:[ |
|
5416 |
"cancel" |
|
5417 |
^ self. |
|
5418 |
]. |
|
5419 |
file := file asFilename. |
|
5420 |
directoryForFileDialog := file. |
|
5421 |
||
5422 |
ok := file isReadable and:[file isDirectory not]. |
|
5423 |
ok ifFalse:[ |
|
5424 |
file isReadable ifFalse:[ |
|
5425 |
why := '%1 is unreadable.\\Please try again.' |
|
5426 |
] ifTrue:[ |
|
5427 |
why := '%1 is a directory.\\Please try again.' |
|
5428 |
]. |
|
5429 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
5430 |
]. |
|
2909 | 5431 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5432 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5433 |
text := file contentsOfEntireFile. |
3495 | 5434 |
self |
5435 |
undoableDo:[ |
|
5436 |
self paste:text |
|
5437 |
] |
|
5438 |
info:'paste file' |
|
5439 |
||
5440 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
5441 |
! |
|
5442 |
||
5443 |
insertUUID |
|
5444 |
"insert a new UUID's string" |
|
5445 |
||
5446 |
typeOfSelection := nil. |
|
5447 |
self |
|
5448 |
undoableDo:[ |
|
5449 |
self pasteOrReplace:(UUID genUUID printString). |
|
5450 |
] |
|
5451 |
info:'paste new uuid' |
|
5452 |
||
5453 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 5454 |
! |
5455 |
||
2762 | 5456 |
openFileBrowserOnIt |
5457 |
"open a fileBrowser on the selected fileName" |
|
5458 |
||
5459 |
|fn dir| |
|
5460 |
||
5461 |
fn := self selectionAsString asFilename. |
|
5462 |
fn exists ifFalse:[ |
|
3160 | 5463 |
^ self warn:'Oops - file is gone'. |
2762 | 5464 |
]. |
5465 |
(dir := fn) isDirectory ifFalse:[ |
|
3160 | 5466 |
dir := fn directory |
2762 | 5467 |
]. |
5468 |
UserPreferences fileBrowserClass openOn:dir |
|
5469 |
! |
|
5470 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5471 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5472 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5473 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5474 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5475 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5476 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5477 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5478 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5479 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5480 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5481 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5482 |
paste |
1289 | 5483 |
"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
|
5484 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5485 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5486 |
self checkModificationsAllowed ifTrue:[ |
3160 | 5487 |
self withSelfAndTextForPasteDo:[:me :text | |
5488 |
me unselect. |
|
5489 |
me undoablePaste:text |
|
5490 |
] |
|
2952 | 5491 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5492 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5493 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5494 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5495 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5496 |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5497 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5498 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5499 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5500 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5501 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5502 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5503 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5504 |
CharacterEncoderError handle:[:ex | |
3180 | 5505 |
|code msg| |
5506 |
||
5507 |
code := ex parameter. |
|
5508 |
codingErrorReported ifFalse:[ |
|
5509 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
|
5510 |
code notNil ifTrue:[ |
|
5511 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
5512 |
]. |
|
3190 | 5513 |
Dialog warn:(resources stringWithCRs:msg). |
3180 | 5514 |
codingErrorReported := true. |
5515 |
]. |
|
3482
485fb4d1f464
CharacterEncoderError handling (take defaultValue from target encoding)
Stefan Vogel <sv@exept.de>
parents:
3479
diff
changeset
|
5516 |
ex proceedWith:ex defaultValue |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5517 |
] do:[ |
3180 | 5518 |
s isString ifTrue:[ |
5519 |
s encoding ~~ characterEncoding ifTrue:[ |
|
5520 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5521 |
]. |
|
5522 |
||
5523 |
s := s asStringCollection. |
|
5524 |
(someText endsWith:Character cr) ifTrue:[ |
|
5525 |
"/ s := s copyWith:nil. |
|
5526 |
s := s copyWith:'' "/ an empty line at the end |
|
5527 |
||
5528 |
] |
|
5529 |
] ifFalse:[ |
|
5530 |
s isStringCollection ifTrue:[ |
|
5531 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5532 |
] ifFalse:[ |
|
5533 |
(self |
|
5534 |
confirm:(resources |
|
5535 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
5536 |
with:s class name)) ifFalse:[^ self]. |
|
5537 |
s := StringCollection with:s storeString . |
|
5538 |
"/ ^ self |
|
5539 |
]. |
|
5540 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5541 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5542 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5543 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5544 |
(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
|
5545 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5546 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5547 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5548 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5549 |
startCol := c1 := cursorCol. |
3180 | 5550 |
|
5551 |
"do not expand tabs in s here - |
|
5552 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
5553 |
Some Subviews want to paste with unexpanded tabs!!" |
|
5554 |
||
5555 |
self insertLines:s withCR:false. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5556 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5557 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5558 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5559 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5560 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5561 |
"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
|
5562 |
"Modified: / 30.1.2000 / 02:32:42 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5563 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5564 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5565 |
pasteOrReplace |
1289 | 5566 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 5567 |
otherwise paste at cursor position. |
5568 |
Replace is not done for selections which were created by a paste, |
|
2010 | 5569 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5570 |
|
2724 | 5571 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
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 |
pasteOrReplace:someText |
1289 | 5575 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5576 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5577 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5579 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5580 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5581 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5582 |
self undoableDo:[ |
3542 | 5583 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
5584 |
self replace:someText |
|
5585 |
] ifFalse:[ |
|
5586 |
self paste:someText. |
|
5587 |
] |
|
5588 |
] info:'Paste/Replace'. |
|
1289 | 5589 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
5590 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5591 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5593 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5594 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5595 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5596 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5597 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5598 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5599 |
self checkModificationsAllowed ifFalse:[ |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5600 |
self flash. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5601 |
^ self |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5602 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5603 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5604 |
text notNil ifTrue:[ |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5605 |
self pasteOrReplace:text |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5606 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5607 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5608 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5609 |
replace |
1289 | 5610 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5611 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5612 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5613 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5614 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5615 |
self withSelfAndTextForPasteDo:[:me :text | |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5616 |
me undoableDo:[ |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5617 |
me replace:text |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5618 |
] |
3542 | 5619 |
info:'Replace' |
2952 | 5620 |
] |
259
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 |
|
121 | 5623 |
replace:someText |
1289 | 5624 |
"replace the selection by someText" |
121 | 5625 |
|
3160 | 5626 |
|selected selectedString |
5627 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 5628 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5629 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5630 |
|
3130 | 5631 |
self undoableDo:[ |
3542 | 5632 |
selected := self selection. |
5633 |
selected isNil ifTrue:[ |
|
5634 |
^ self paste:someText |
|
5635 |
]. |
|
5636 |
||
5637 |
self deleteSelection. |
|
5638 |
||
5639 |
"take care, if we replace a selection without space by a word selected |
|
5640 |
with one - in this case we usually do not want the space. |
|
5641 |
But, if we replace a word-selected selection by something without a |
|
5642 |
space, we DO want the space added." |
|
5643 |
||
5644 |
selected size == 1 ifTrue:[ |
|
5645 |
selectedString := selected at:1. |
|
5646 |
]. |
|
5647 |
||
5648 |
someText size == 1 ifTrue:[ |
|
5649 |
|cutOffSpace addSpace replacement replacementString| |
|
5650 |
||
5651 |
cutOffSpace := false. |
|
5652 |
addSpace := false. |
|
5653 |
replacement := someText copyFrom:1. |
|
5654 |
||
5655 |
selectedString notNil ifTrue:[ |
|
5656 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
5657 |
"selection has no space" |
|
5658 |
||
5659 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
5660 |
cutOffSpace := true |
|
5661 |
] |
|
5662 |
] ifTrue:[ |
|
5663 |
addSpace := true |
|
5664 |
] |
|
5665 |
]. |
|
5666 |
replacementString := replacement at:1. |
|
5667 |
cutOffSpace ifTrue:[ |
|
5668 |
(replacementString startsWith:' ') ifTrue:[ |
|
5669 |
replacementString := replacementString withoutSpaces |
|
5670 |
]. |
|
5671 |
] ifFalse:[ |
|
5672 |
selectStyle == #wordLeft ifTrue:[ |
|
5673 |
"want a space at left" |
|
5674 |
(replacementString startsWith:' ') ifFalse:[ |
|
5675 |
replacementString := replacementString withoutSpaces. |
|
5676 |
replacementString := ' ' , replacementString |
|
5677 |
] |
|
5678 |
]. |
|
5679 |
selectStyle == #wordRight ifTrue:[ |
|
5680 |
"want a space at right" |
|
5681 |
||
5682 |
(replacementString endsWith:' ') ifFalse:[ |
|
5683 |
replacementString := replacementString withoutSpaces. |
|
5684 |
replacementString := replacementString , ' ' |
|
5685 |
] |
|
5686 |
]. |
|
5687 |
]. |
|
5688 |
replacement at:1 put: replacementString. |
|
5689 |
self paste:replacement. |
|
5690 |
] ifFalse:[ |
|
5691 |
self paste:someText |
|
5692 |
]. |
|
5693 |
lastString := selectedString. |
|
5694 |
lastReplacement := someText. |
|
5695 |
||
5696 |
selStartLine := selectionStartLine. |
|
5697 |
selStartCol := self selectionStartCol. |
|
5698 |
selEndLine := selectionEndLine. |
|
5699 |
selEndCol := self selectionEndCol. |
|
3130 | 5700 |
] |
3542 | 5701 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
5702 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5703 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5704 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 5705 |
! |
5706 |
||
3430 | 5707 |
searchReplace |
5708 |
"search for a string - show a box to enter searchpattern |
|
5709 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
|
5710 |
- currently no regular expressions are handled." |
|
5711 |
||
5712 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
|
5713 |
||
5714 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
5715 |
lastSearchDirection := #forward. |
|
5716 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5717 |
caseHolder := ign asValue. |
|
5718 |
patternHolder := '' asValue. |
|
5719 |
replacePatternHolder := '' asValue. |
|
5720 |
lastSearchPattern notNil ifTrue:[ |
|
5721 |
initialString := lastSearchPattern |
|
5722 |
]. |
|
5723 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
5724 |
initialString := self selectionAsString |
|
5725 |
]. |
|
5726 |
initialString isNil ifTrue:[ |
|
5727 |
LastSearchPatterns size > 0 ifTrue:[ |
|
5728 |
initialString := LastSearchPatterns first |
|
5729 |
] |
|
5730 |
]. |
|
5731 |
initialString notNil ifTrue:[ |
|
5732 |
patternHolder value:initialString. |
|
5733 |
replacePatternHolder value:initialString. |
|
5734 |
]. |
|
5735 |
flag := true. |
|
5736 |
search := [:fwd | |
|
5737 |
self |
|
5738 |
search:patternHolder value |
|
5739 |
ignoreCase:caseHolder value |
|
5740 |
forward:fwd. |
|
5741 |
]. |
|
5742 |
replace := [:all | |
|
5743 |
self |
|
5744 |
replace:patternHolder value |
|
5745 |
by:replacePatternHolder value |
|
5746 |
all:all |
|
5747 |
ignoreCase:caseHolder value |
|
5748 |
]. |
|
5749 |
bindings := IdentityDictionary new. |
|
5750 |
bindings at:#searchPattern put:patternHolder. |
|
5751 |
bindings at:#replacePattern put:replacePatternHolder. |
|
5752 |
modal ifTrue:[ |
|
5753 |
bindings at:#nextAction |
|
5754 |
put:[ |
|
5755 |
flag := true. |
|
5756 |
action := search. |
|
5757 |
searchBox doAccept. |
|
5758 |
]. |
|
5759 |
bindings at:#prevAction |
|
5760 |
put:[ |
|
5761 |
flag := false. |
|
5762 |
action := search. |
|
5763 |
searchBox doAccept. |
|
5764 |
]. |
|
5765 |
bindings at:#replaceAction |
|
5766 |
put:[ |
|
5767 |
flag := false. |
|
5768 |
action := replace. |
|
5769 |
searchBox doAccept. |
|
5770 |
]. |
|
5771 |
bindings at:#replaceAllAction |
|
5772 |
put:[ |
|
5773 |
flag := true. |
|
5774 |
action := replace. |
|
5775 |
searchBox doAccept. |
|
5776 |
]. |
|
5777 |
] ifFalse:[ |
|
5778 |
bindings at:#nextAction put:[ search value:true. ]. |
|
5779 |
bindings at:#prevAction put:[ search value:false. ]. |
|
5780 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
5781 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
5782 |
]. |
|
5783 |
bindings at:#ignoreCase put:caseHolder. |
|
5784 |
bindings at:#patternList put:LastSearchPatterns. |
|
5785 |
modal ifTrue:[ |
|
5786 |
searchBox := SimpleDialog new. |
|
5787 |
] ifFalse:[ |
|
5788 |
searchBox := ApplicationModel new. |
|
5789 |
searchBox createBuilder. |
|
5790 |
]. |
|
5791 |
searchBox resources:(self resources). |
|
5792 |
bldr := searchBox builder. |
|
5793 |
bldr addBindings:bindings. |
|
5794 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
5795 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
5796 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
5797 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
5798 |
modal ifTrue:[ |
|
5799 |
searchBox openDialog. |
|
5800 |
searchBox accepted ifTrue:[ |
|
5801 |
action value:flag |
|
5802 |
]. |
|
5803 |
] ifFalse:[ |
|
5804 |
(bldr componentAt:#nextButton) isReturnButton:false. |
|
5805 |
(bldr componentAt:#cancelButton) |
|
5806 |
label:(resources string:'Close'); |
|
5807 |
action:[ searchBox closeRequest ]. |
|
5808 |
||
5809 |
"/ searchBox masterApplication:self application. |
|
5810 |
||
5811 |
self topView beMaster. |
|
5812 |
(searchBox window) |
|
5813 |
beSlave; |
|
5814 |
openInGroup:(self windowGroup). |
|
5815 |
||
5816 |
"/ searchBox window open. |
|
5817 |
||
5818 |
searchBox window assignKeyboardFocusToFirstInputField. |
|
5819 |
] |
|
5820 |
||
5821 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
5822 |
! |
|
5823 |
||
121 | 5824 |
showDeleted |
5825 |
"open a readonly editor on all deleted text" |
|
5826 |
||
5827 |
|v| |
|
5828 |
||
5829 |
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
|
5830 |
v readOnly:true. |
121 | 5831 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5832 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5833 |
|
3221 | 5834 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
5835 |
"sort the selected lines" |
|
5836 |
||
5837 |
|lines extractor fetcher lineWise nStr n s words| |
|
5838 |
||
5839 |
lineWise := true. |
|
5840 |
||
5841 |
how == #lines ifTrue:[ |
|
5842 |
extractor := [:l | l withoutLeadingSeparators]. |
|
5843 |
] ifFalse:[ how == #linesByFirstWord ifTrue:[ |
|
3222 | 5844 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
3221 | 5845 |
] ifFalse:[ how == #linesByNthWord ifTrue:[ |
5846 |
nStr := Dialog request:'Word (1..)'. |
|
5847 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
5848 |
n := Integer readFrom:nStr onError:[^ self]. |
|
5849 |
||
3227
49b97c45652a
sort by nth word: do not skip non-alphanumeric words
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
5850 |
extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')]. |
3221 | 5851 |
] ifFalse:[ how == #words ifTrue:[ |
5852 |
lineWise := false. |
|
5853 |
extractor := [:w | w]. |
|
5854 |
] ifFalse:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5855 |
self error:'unknown sort criteria: ', how printString. |
3221 | 5856 |
]]]]. |
5857 |
||
5858 |
ignoreCase ifTrue:[ |
|
5859 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
5860 |
] ifFalse:[ |
|
5861 |
fetcher := extractor. |
|
5862 |
]. |
|
5863 |
||
5864 |
lineWise ifTrue:[ |
|
5865 |
start == end ifTrue:[^ self ]. |
|
5866 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
5867 |
lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)]. |
|
5868 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
5869 |
self textChanged. |
|
5870 |
^ self. |
|
5871 |
]. |
|
5872 |
||
5873 |
s := self selectionAsString. |
|
5874 |
words := s asCollectionOfWords. |
|
5875 |
words := words sort:[:w1 :w2 | (fetcher value:w1) < (fetcher value:w2)]. |
|
5876 |
s := words asStringCollection asStringWith:Character space. |
|
5877 |
self replace:s. |
|
5878 |
self textChanged. |
|
5879 |
! |
|
5880 |
||
5881 |
sortSelection:how ignoreCase:ignoreCase |
|
5882 |
"sort the selected lines" |
|
5883 |
||
5884 |
|start end| |
|
5885 |
||
5886 |
selectionStartLine isNil ifTrue:[^ self]. |
|
5887 |
||
5888 |
start := selectionStartLine. |
|
5889 |
end := selectionEndLine. |
|
5890 |
(selectionEndCol == 0) ifTrue:[ |
|
5891 |
end := end - 1 |
|
5892 |
]. |
|
5893 |
||
5894 |
self |
|
5895 |
undoableDo:[ |
|
5896 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end. |
|
5897 |
] |
|
5898 |
info:'sort' |
|
5899 |
! |
|
5900 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5901 |
specialCharacters |
2915 | 5902 |
CharacterSetView |
3160 | 5903 |
openAsInputFor:self |
5904 |
label:'Special Character Input' |
|
5905 |
clickLabel:'Click to Insert Character'. |
|
2866 | 5906 |
! |
5907 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5908 |
undoablePaste:someText |
3495 | 5909 |
self undoablePaste:someText info:nil. |
5910 |
||
5911 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
5912 |
! |
|
5913 |
||
5914 |
undoablePaste:someText info:infoOrNil |
|
5915 |
self |
|
5916 |
undoableDo:[ |
|
5917 |
self paste:someText. |
|
5918 |
] |
|
5919 |
info:infoOrNil |
|
5920 |
||
5921 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
5922 |
! |
|
5923 |
||
5924 |
undoablePasteOrReplace:someText info:infoOrNil |
|
5925 |
self |
|
5926 |
undoableDo:[ |
|
5927 |
self pasteOrReplace:someText. |
|
5928 |
] |
|
5929 |
info:infoOrNil |
|
5930 |
||
5931 |
"Created: / 28-07-2007 / 13:26:16 / cg" |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5932 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5933 |
|
2724 | 5934 |
withSelfAndTextForPasteDo:aBlock |
5935 |
"common code for paste/replace of the copybuffer" |
|
5936 |
||
5937 |
|sel| |
|
5938 |
||
5939 |
self checkModificationsAllowed ifFalse:[ |
|
3160 | 5940 |
self flash. |
5941 |
^ self |
|
2724 | 5942 |
]. |
5943 |
||
5944 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
5945 |
sel notNil ifTrue:[ |
|
3160 | 5946 |
aBlock value:self value:sel. |
2724 | 5947 |
] |
105 | 5948 |
! ! |
5949 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5950 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5951 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5952 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5953 |
"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
|
5954 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5955 |
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
|
5956 |
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
|
5957 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5958 |
self isReadOnly ifTrue: [ |
3160 | 5959 |
exceptionBlock isNil ifTrue:[ |
5960 |
^ false |
|
5961 |
]. |
|
5962 |
||
5963 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
5964 |
^ false |
|
5965 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5966 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5967 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5968 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
5969 |
"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
|
5970 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5971 |
|
2596 | 5972 |
currentSelectionBgColor |
5973 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 5974 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 5975 |
]. |
5976 |
^ super currentSelectionBgColor |
|
5977 |
||
5978 |
" |
|
5979 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
5980 |
" |
|
5981 |
! |
|
5982 |
||
5983 |
currentSelectionFgColor |
|
5984 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 5985 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 5986 |
]. |
5987 |
^ super currentSelectionFgColor |
|
5988 |
! |
|
5989 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5990 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5991 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5992 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
5993 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5994 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5995 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5996 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5997 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5998 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
5999 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6000 |
textChanged |
522 | 6001 |
"my text was modified (internally). |
6002 |
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
|
6003 |
contentsChanged, which is triggered when the size has changed, and |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6004 |
is used to notify scrollers, other views etc.)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6005 |
|
641 | 6006 |
self contentsChanged. |
1015 | 6007 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6008 |
contentsWasSaved := false |
641 | 6009 |
|
1015 | 6010 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 6011 |
! |
6012 |
||
2617 | 6013 |
textChangedButNoSizeChange |
2207 | 6014 |
"my text was modified (internally). |
6015 |
Sent whenever text has been edited (not to confuse with |
|
6016 |
contentsChanged, which is triggered when the size has changed, and |
|
6017 |
is used to notify scrollers, other views etc.)" |
|
6018 |
||
6019 |
self modified:true. |
|
6020 |
contentsWasSaved := false |
|
6021 |
||
6022 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6023 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6024 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6025 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6026 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6027 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6028 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6029 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6030 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6031 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6032 |
"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
|
6033 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6034 |
|
1878 | 6035 |
isKeyboardConsumer |
6036 |
"return true, if the receiver is a keyboard consumer; |
|
6037 |
Return true here, redefined from SimpleView." |
|
6038 |
||
3476 | 6039 |
^ self isReadOnly not |
1878 | 6040 |
! |
6041 |
||
997 | 6042 |
specClass |
1390 | 6043 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
6044 |
||
997 | 6045 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 6046 |
^ super specClass |
6047 |
||
1390 | 6048 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 6049 |
! |
6050 |
||
324 | 6051 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6052 |
"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
|
6053 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
6054 |
"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
|
6055 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6056 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 6057 |
|
6058 |
"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
|
6059 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
6060 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6061 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6062 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6063 |
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
|
6064 |
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
|
6065 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6066 |
|
697 | 6067 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6068 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6069 |
w := super widthOfContents. |
697 | 6070 |
(dev := device) isNil ifTrue:[ |
3160 | 6071 |
"/ really dont know ... |
6072 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
6073 |
]. |
697 | 6074 |
^ w + (font widthOn:dev) |
6075 |
||
6076 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6077 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6078 |
|
1588 | 6079 |
!EditTextView methodsFor:'realization'! |
6080 |
||
6081 |
realize |
|
6082 |
"make the view visible - scroll to make the cursor visible." |
|
6083 |
||
6084 |
super realize. |
|
6085 |
||
6086 |
self makeCursorVisible. |
|
1993 | 6087 |
cursorFgColor := cursorFgColor onDevice:device. |
6088 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 6089 |
|
6090 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
6091 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
6092 |
! ! |
|
6093 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6094 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6095 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6096 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6097 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6098 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6099 |
cursorShown ifTrue:[ |
3160 | 6100 |
cursorVisibleLine notNil ifTrue:[ |
6101 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
6102 |
self drawCursorCharacter |
|
6103 |
] |
|
6104 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6105 |
] |
105 | 6106 |
! |
6107 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6108 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6109 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6110 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6111 |
cursorShown ifTrue:[ |
3160 | 6112 |
(visLine == cursorVisibleLine) ifTrue:[ |
6113 |
self drawCursorCharacter |
|
6114 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6115 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6116 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6117 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6118 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6119 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6120 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6121 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6122 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6123 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6124 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6125 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6126 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6127 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6128 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6129 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6130 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6131 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6132 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6133 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6134 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6135 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6136 |
cursorShown ifTrue:[ |
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6137 |
(visLine == cursorVisibleLine) ifTrue:[ |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6138 |
(colNr == cursorCol) ifTrue:[ |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6139 |
self drawCursorCharacter. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6140 |
^ self |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6141 |
] |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6142 |
] |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6143 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6144 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6145 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6146 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6147 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6148 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6149 |
"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
|
6150 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6151 |
super redrawVisibleLine:visLine from:startCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6152 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6153 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6154 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6155 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6156 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6157 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6158 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6159 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6160 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6161 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6162 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6163 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6164 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6165 |
"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
|
6166 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6167 |
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
|
6168 |
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
|
6169 |
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
|
6170 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6171 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6172 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6173 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6174 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6175 |
"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
|
6176 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6177 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6178 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6179 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6180 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6181 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6182 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6183 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6185 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6186 |
"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
|
6187 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6188 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6189 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6190 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6191 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6192 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6193 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6194 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6195 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6196 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6197 |
"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
|
6198 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6199 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6200 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6201 |
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
|
6202 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6203 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6204 |
prevCursorState ifTrue:[ |
3160 | 6205 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6206 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6207 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6208 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6209 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6210 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6211 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6212 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6213 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6214 |
prevCursorState := cursorShown. |
1601 | 6215 |
"/ cursorShown := false. |
1591 | 6216 |
cursorShown ifTrue:[ |
3160 | 6217 |
self hideCursor |
1591 | 6218 |
] |
6219 |
||
1601 | 6220 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6221 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6222 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6223 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6224 |
"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
|
6225 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6226 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6227 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6228 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6229 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6230 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6231 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6232 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6233 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6234 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6235 |
"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
|
6236 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6237 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6238 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6240 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6241 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6242 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6243 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6245 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6246 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6247 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6248 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6249 |
|
2822 | 6250 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 6251 |
! |
6252 |
||
6253 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
6254 |
"do a backward search" |
|
6255 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6256 |
|pos startLine startCol| |
1339 | 6257 |
|
6258 |
cursorLine isNil ifTrue:[^ self]. |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6259 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6260 |
pos := self startPositionForSearchBackward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6261 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6262 |
startCol := pos x. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6263 |
|
3160 | 6264 |
self |
6265 |
searchBackwardFor:pattern |
|
6266 |
ignoreCase:ign |
|
6267 |
startingAtLine:startLine col:startCol |
|
6268 |
ifFound:[:line :col | |
|
6269 |
self cursorMovementAllowed ifTrue:[ |
|
6270 |
self cursorLine:line col:col. |
|
6271 |
]. |
|
6272 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 6273 |
"/ self makeLineVisible:cursorLine |
3160 | 6274 |
typeOfSelection := #search] |
6275 |
ifAbsent:aBlock |
|
1339 | 6276 |
|
6277 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6278 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6279 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6280 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6281 |
"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
|
6282 |
|
2554 | 6283 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6284 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6285 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6286 |
searchForMatchingParenthesis |
3160 | 6287 |
"search for a matching parenthesis starting at cursor position. |
6288 |
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
|
6289 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6290 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6291 |
|
2822 | 6292 |
self cursorMovementAllowed ifFalse:[^ self]. |
6293 |
||
3160 | 6294 |
self |
6295 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
|
6296 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
6297 |
ifNotFound:[self showNotFound] |
|
6298 |
onError:[self beep] |
|
1339 | 6299 |
|
6300 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6301 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6302 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6303 |
searchFwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6304 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6305 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6306 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6307 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6308 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6309 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6310 |
startCol := pos x. |
1339 | 6311 |
|
3160 | 6312 |
self |
6313 |
searchFwd:pattern |
|
6314 |
startingAtLine:startLine col:startCol |
|
6315 |
ifAbsent:aBlock |
|
1339 | 6316 |
|
6317 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
6318 |
! |
|
6319 |
||
6320 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
6321 |
"do a forward search" |
|
6322 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6323 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6324 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6325 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6326 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6327 |
startCol := pos x. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6328 |
|
3160 | 6329 |
self |
6330 |
searchFwd:pattern |
|
6331 |
ignoreCase:ign |
|
6332 |
startingAtLine:startLine col:startCol |
|
6333 |
ifAbsent:aBlock |
|
1339 | 6334 |
|
6335 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
6336 |
"Created: 9.10.1997 / 13:04:10 / cg" |
|
6337 |
! |
|
6338 |
||
6339 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
6340 |
"do a forward search" |
|
6341 |
||
6342 |
cursorLine isNil ifTrue:[^ self]. |
|
3160 | 6343 |
self |
6344 |
searchForwardFor:pattern |
|
6345 |
ignoreCase:ign |
|
6346 |
startingAtLine:startLine col:startCol |
|
6347 |
ifFound:[:line :col | |
|
6348 |
self cursorMovementAllowed ifTrue:[ |
|
6349 |
self cursorLine:line col:col. |
|
6350 |
]. |
|
6351 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 6352 |
"/ self makeLineVisible:cursorLine |
3160 | 6353 |
typeOfSelection := #search] |
6354 |
ifAbsent:aBlock |
|
1339 | 6355 |
|
6356 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
6357 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6358 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6359 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6360 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6361 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6362 |
|
2822 | 6363 |
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
|
6364 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6365 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6366 |
setSearchPattern |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6367 |
"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
|
6368 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6369 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6370 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6371 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6372 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6373 |
"/ 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
|
6374 |
"/ original string (for search after again) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6375 |
"/ |
3160 | 6376 |
(lastString notNil |
565 | 6377 |
and:[lastReplacement notNil |
6378 |
and:[typeOfSelection ~~ #search]]) ifTrue:[ |
|
3160 | 6379 |
lastString isString ifTrue:[ |
6380 |
lastSearchPattern := lastString. |
|
6381 |
] ifFalse:[ |
|
6382 |
lastSearchPattern := lastString asStringWithoutFinalCR. |
|
6383 |
]. |
|
6384 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6385 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6386 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6387 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6388 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6389 |
"/ 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
|
6390 |
"/ 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
|
6391 |
"/ it did not result from a paste. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6392 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6393 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6394 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6395 |
sel notNil ifTrue:[ |
3160 | 6396 |
(lastSearchPattern isNil |
6397 |
or:[typeOfSelection ~~ #paste]) ifTrue:[ |
|
6398 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
6399 |
lastSearchPattern := sel asStringWithoutFinalCR withMatchEscapes |
|
6400 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6401 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6402 |
|
565 | 6403 |
"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
|
6404 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6405 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6406 |
startPositionForSearchBackward |
2822 | 6407 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
6408 |
! |
|
6409 |
||
6410 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6411 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6412 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6413 |
selectionStartLine notNil ifTrue:[ |
3160 | 6414 |
startLine := selectionStartLine. |
6415 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6416 |
] ifFalse:[ |
3160 | 6417 |
cursorLine isNil ifTrue:[ |
6418 |
startLine := list size. |
|
6419 |
startCol := self listAt:startLine size. |
|
6420 |
] ifFalse:[ |
|
6421 |
startLine := cursorLine min:list size. |
|
6422 |
startCol := cursorCol |
|
6423 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6424 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6425 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6426 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6427 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6428 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6429 |
startPositionForSearchForward |
2822 | 6430 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
6431 |
! |
|
6432 |
||
6433 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6434 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6435 |
|
3160 | 6436 |
"/ 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
|
6437 |
"/ 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
|
6438 |
startCol := cursorCol. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6439 |
self hasSelection ifFalse:[ |
3160 | 6440 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
6441 |
startCol := 0 |
|
6442 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6443 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6444 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6445 |
^ startCol @ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6446 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6447 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6448 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6449 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6450 |
addToSelectionAfter:aBlock |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6451 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6452 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6453 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6454 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6455 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6456 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6457 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6458 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6459 |
self hasSelection ifTrue: [ |
3160 | 6460 |
startLine := selectionStartLine . |
6461 |
startCol := selectionStartCol . |
|
6462 |
endLine := selectionEndLine . |
|
6463 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6464 |
] ifFalse: [ |
3160 | 6465 |
startLine := endLine := cursorLine . |
6466 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6467 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6468 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6469 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6470 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6471 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6472 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6473 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6474 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
3160 | 6475 |
ifTrue: [ |
6476 |
startCol := cursorCol. |
|
6477 |
] ifFalse: [ |
|
6478 |
endCol := cursorCol - 1. |
|
6479 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6480 |
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
|
6481 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6482 |
|
1850 | 6483 |
autoMoveCursorToEndOfSelection |
6484 |
"return true, if the cursor should be automatically moved to the |
|
6485 |
end of a selection. |
|
6486 |
Redefined to return false in terminaViews, where the cursor should |
|
6487 |
not be affected by selecting" |
|
6488 |
||
6489 |
^ true |
|
6490 |
! |
|
6491 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6492 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6493 |
typeOfSelection ~~ newType ifTrue:[ |
3160 | 6494 |
typeOfSelection := newType. |
6495 |
selectionStartLine notNil ifTrue:[ |
|
6496 |
self |
|
6497 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
6498 |
toLine:selectionEndLine col:selectionEndCol |
|
6499 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6500 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6501 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6502 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6503 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6504 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6505 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6506 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6507 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6508 |
list isNil ifTrue:[ |
3160 | 6509 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6510 |
] ifFalse:[ |
3160 | 6511 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
6512 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6513 |
] |
1082 | 6514 |
|
6515 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6516 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6517 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6518 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6519 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6520 |
|
3160 | 6521 |
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
|
6522 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6523 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6524 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6525 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6526 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6527 |
cursorCol > 1 ifTrue:[ |
3160 | 6528 |
self selectFromLine:cursorLine col:1 |
6529 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6530 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6531 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6532 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6533 |
! |
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 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6536 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6537 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6538 |
selectionStartLine isNil ifTrue:[ |
3160 | 6539 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6540 |
] ifFalse:[ |
3160 | 6541 |
self selectFromLine:selectionStartLine col:selectionStartCol |
6542 |
toLine:cursorLine+1 col:0. |
|
6543 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6544 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6545 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6547 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6548 |
"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
|
6549 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6550 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6551 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6552 |
list isNil ifTrue:[ |
3160 | 6553 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6554 |
] ifFalse:[ |
3160 | 6555 |
cursorCol == 0 ifTrue:[ |
6556 |
col := 0 |
|
6557 |
] ifFalse:[ |
|
6558 |
col := cursorCol - 1 |
|
6559 |
]. |
|
6560 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
6561 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6562 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6563 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6564 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6565 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6566 |
"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
|
6567 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6568 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6569 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 6570 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
3160 | 6571 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 6572 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6573 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6574 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6575 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6576 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6577 |
"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
|
6578 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6579 |
list isNil ifTrue:[ |
3160 | 6580 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6581 |
] ifFalse:[ |
3160 | 6582 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
6583 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6584 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6585 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6586 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6587 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6588 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6589 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6590 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6591 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6592 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6593 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6594 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6595 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6596 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6597 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6598 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6599 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6600 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6601 |
wasOn ifTrue:[self showCursor] |
105 | 6602 |
! ! |
6603 |
||
6604 |
!EditTextView methodsFor:'undo & again'! |
|
6605 |
||
2952 | 6606 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6607 |
^ undoSupport addUndo:action. |
2952 | 6608 |
! |
6609 |
||
105 | 6610 |
again |
6611 |
"repeat the last action (which was a cut or replace). |
|
6612 |
If current selection is not last string, search forward to |
|
3160 | 6613 |
next occurrence of it before repeating the last operation." |
105 | 6614 |
|
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
6615 |
|s l c sel savedSelectStyle startColForSearch| |
105 | 6616 |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6617 |
lastString isNil ifTrue:[ |
3160 | 6618 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6619 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6620 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6621 |
self undoableDo:[ |
3160 | 6622 |
s := lastString asString. |
6623 |
||
6624 |
"remove final cr" |
|
6625 |
(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
|
6626 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
3160 | 6627 |
savedSelectStyle := selectStyle. |
6628 |
selectStyle := nil. |
|
6629 |
||
6630 |
sel := self selection. |
|
6631 |
||
6632 |
"if we are already there (after a find), ommit search" |
|
6633 |
||
6634 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
6635 |
l := selectionStartLine "cursorLine". |
|
6636 |
c := selectionStartCol "cursorCol". |
|
6637 |
self deleteSelection. |
|
6638 |
lastReplacement notNil ifTrue:[ |
|
6639 |
self insertLines:lastReplacement asStringCollection withCR:false. |
|
6640 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
6641 |
]. |
|
6642 |
selectStyle := savedSelectStyle. |
|
6643 |
^ true |
|
6644 |
]. |
|
6645 |
startColForSearch := cursorCol. |
|
6646 |
sel isNil ifTrue:[ |
|
6647 |
startColForSearch := startColForSearch - 1 |
|
6648 |
]. |
|
6649 |
self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch |
|
6650 |
ifFound: |
|
6651 |
[ |
|
6652 |
:line :col | |
|
6653 |
||
6654 |
|repl| |
|
6655 |
||
6656 |
self selectFromLine:line col:col |
|
6657 |
toLine:line col:(col + s size - 1). |
|
6658 |
self makeLineVisible:line. |
|
6659 |
||
6660 |
self deleteSelection. |
|
6661 |
lastReplacement notNil ifTrue:[ |
|
6662 |
lastReplacement isString ifFalse:[ |
|
6663 |
repl := lastReplacement asString "withoutSpaces" |
|
6664 |
] ifTrue:[ |
|
6665 |
repl := lastReplacement "withoutSpaces". |
|
6666 |
]. |
|
6667 |
self insertLines:repl asStringCollection withCR:false. |
|
6668 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
6669 |
undoSupport actionInfo:'replace'. |
|
6670 |
]. |
|
6671 |
selectStyle := savedSelectStyle. |
|
6672 |
^ true |
|
6673 |
] |
|
6674 |
ifAbsent: |
|
6675 |
[ |
|
6676 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
6677 |
self showNotFound. |
|
6678 |
selectStyle := savedSelectStyle. |
|
6679 |
^ false |
|
6680 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6681 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6682 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6683 |
^ true. |
501 | 6684 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
6685 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 6686 |
! |
6687 |
||
2952 | 6688 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6689 |
^ undoSupport hasRedoAction. |
2952 | 6690 |
! |
6691 |
||
6692 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6693 |
^ undoSupport hasUndoAction. |
2952 | 6694 |
! |
6695 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6696 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6697 |
"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
|
6698 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6699 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6700 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6701 |
|
2952 | 6702 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6703 |
undoSupport nonUndoableDo:aBlock. |
2952 | 6704 |
! |
6705 |
||
6706 |
redo |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6707 |
undoSupport hasRedoAction ifFalse:[ |
3160 | 6708 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6709 |
] ifTrue:[ |
3160 | 6710 |
undoSupport redo. |
2952 | 6711 |
] |
6712 |
! |
|
6713 |
||
121 | 6714 |
undo |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6715 |
undoSupport hasUndoAction ifFalse:[ |
3160 | 6716 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6717 |
] ifTrue:[ |
3160 | 6718 |
undoSupport undo. |
121 | 6719 |
] |
2952 | 6720 |
! |
6721 |
||
6722 |
undoableDo:aBlock |
|
3495 | 6723 |
self undoableDo:aBlock info:nil. |
6724 |
||
6725 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 6726 |
! |
6727 |
||
6728 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6729 |
self checkModificationsAllowed ifFalse:[ |
3495 | 6730 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
6731 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6732 |
] ifTrue:[ |
3495 | 6733 |
undoSupport undoableDo:aBlock info:aString. |
6734 |
]. |
|
6735 |
||
6736 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 6737 |
! ! |
6738 |
||
6739 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
6740 |
||
6741 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6742 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6743 |
! |
|
6744 |
||
3115 | 6745 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 6746 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 6747 |
! |
6748 |
||
2952 | 6749 |
line:arg1 col:arg2 character:arg3 |
6750 |
^ self new line:arg1 col:arg2 character:arg3 |
|
6751 |
! |
|
6752 |
||
3115 | 6753 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 6754 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 6755 |
! |
6756 |
||
3235 | 6757 |
line:arg1 col:arg2 characters:arg3 info:info |
6758 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
6759 |
! |
|
6760 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6761 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6762 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6763 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6764 |
|
2952 | 6765 |
line:arg1 col:arg2 string:arg3 |
6766 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 6767 |
! |
6768 |
||
6769 |
line:arg1 col:arg2 string:arg3 info:info |
|
6770 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 6771 |
! |
6772 |
||
6773 |
line:arg1 string:arg3 info:info |
|
6774 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 6775 |
! |
6776 |
||
6777 |
text:arg info:info |
|
6778 |
^ (self new text:arg) info:info |
|
3115 | 6779 |
! ! |
6780 |
||
6781 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
6782 |
||
6783 |
info |
|
6784 |
^ userFriendlyInfo |
|
6785 |
! |
|
6786 |
||
6787 |
info:aString |
|
6788 |
userFriendlyInfo := aString |
|
2952 | 6789 |
! ! |
6790 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6791 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6792 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6793 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6794 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6795 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6796 |
"Created: / 25-09-2006 / 12:16:25 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6797 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6798 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6799 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6800 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6801 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6802 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6803 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6804 |
|
2952 | 6805 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
6806 |
||
3160 | 6807 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 6808 |
"set instance variables (automatically generated)" |
6809 |
||
6810 |
self assert:(line1Arg notNil). |
|
6811 |
self assert:(col1Arg notNil). |
|
6812 |
self assert:(line2Arg notNil). |
|
6813 |
self assert:(col2Arg notNil). |
|
6814 |
||
6815 |
line1 := line1Arg. |
|
6816 |
col1 := col1Arg. |
|
6817 |
line2 := line2Arg. |
|
6818 |
col2 := col2Arg. |
|
6819 |
! ! |
|
6820 |
||
6821 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
6822 |
||
3160 | 6823 |
executeIn:editor |
2952 | 6824 |
editor unselect. |
3160 | 6825 |
editor |
6826 |
deleteFromLine:line1 |
|
6827 |
col:col1 |
|
6828 |
toLine:line2 |
|
6829 |
col:col2. |
|
2952 | 6830 |
editor cursorLine:line1 col:col1. |
6831 |
! ! |
|
6832 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6833 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6834 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6835 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6836 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6837 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6838 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6839 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6840 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6841 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6842 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6843 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6844 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6845 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6846 |
|
3160 | 6847 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6848 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6849 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6850 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6851 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6852 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6853 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6854 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6855 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6856 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6857 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6858 |
|
3160 | 6859 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6860 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6861 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6862 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6863 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6864 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6865 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6866 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6867 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6868 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6869 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6870 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6871 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6872 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6873 |
|
3160 | 6874 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6875 |
"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
|
6876 |
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
|
6877 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6878 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6879 |
previousDeleteAction line == line ifTrue:[ |
3160 | 6880 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
6881 |
^ true |
|
6882 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6883 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6884 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6885 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6886 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6887 |
|
3160 | 6888 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6889 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6890 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6891 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6892 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6893 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6894 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6895 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6896 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6897 |
|
3160 | 6898 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6899 |
editor unselect. |
3160 | 6900 |
editor |
6901 |
deleteFromLine:line |
|
6902 |
col:col1 |
|
6903 |
toLine:line |
|
6904 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6905 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6906 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6907 |
|
3235 | 6908 |
!EditTextView::EditMode class methodsFor:'constants'! |
6909 |
||
6910 |
insertAndSelectMode |
|
6911 |
^ InsertAndSelectMode |
|
6912 |
! |
|
6913 |
||
6914 |
insertMode |
|
6915 |
^ InsertMode |
|
6916 |
! |
|
6917 |
||
6918 |
overwriteMode |
|
6919 |
^ OverwriteMode |
|
6920 |
! ! |
|
6921 |
||
6922 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
6923 |
||
6924 |
isInsertAndSelectMode |
|
6925 |
^ false |
|
6926 |
! |
|
6927 |
||
6928 |
isInsertMode |
|
6929 |
^ false |
|
6930 |
! |
|
6931 |
||
6932 |
symbolicName |
|
6933 |
self subclassResponsibility |
|
6934 |
! ! |
|
6935 |
||
6936 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
6937 |
||
6938 |
infoPrintString |
|
6939 |
^ 'IS' |
|
6940 |
! ! |
|
6941 |
||
6942 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
6943 |
||
6944 |
isInsertAndSelectMode |
|
6945 |
^ true |
|
6946 |
! |
|
6947 |
||
6948 |
isInsertMode |
|
6949 |
^ true |
|
6950 |
! ! |
|
6951 |
||
6952 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
6953 |
||
6954 |
infoPrintString |
|
6955 |
^ 'I' |
|
6956 |
! ! |
|
6957 |
||
6958 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
6959 |
||
6960 |
isInsertMode |
|
6961 |
^ true |
|
6962 |
! ! |
|
6963 |
||
6964 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
6965 |
||
6966 |
infoPrintString |
|
6967 |
^ 'O' |
|
6968 |
! ! |
|
6969 |
||
2952 | 6970 |
!EditTextView::PasteString methodsFor:'accessing'! |
6971 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6972 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6973 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6974 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6975 |
"Created: / 25-09-2006 / 12:19:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6976 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6977 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6978 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6979 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6980 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6981 |
"Created: / 25-09-2006 / 12:20:18 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6982 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6983 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6984 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6985 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6986 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6987 |
"Created: / 25-09-2006 / 12:21:08 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6988 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6989 |
|
3160 | 6990 |
line:lineArg col:colArg string:stringArg |
2952 | 6991 |
self assert:(lineArg notNil). |
6992 |
self assert:(colArg notNil). |
|
6993 |
self assert:(stringArg notNil). |
|
6994 |
||
6995 |
line := lineArg. |
|
6996 |
col := colArg. |
|
6997 |
string := stringArg. |
|
6998 |
! |
|
6999 |
||
7000 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
7001 |
self assert:(lineArg notNil). |
|
7002 |
self assert:(colArg notNil). |
|
7003 |
self assert:(stringArg notNil). |
|
7004 |
||
7005 |
line := lineArg. |
|
7006 |
col := colArg. |
|
7007 |
string := stringArg. |
|
7008 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7009 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7010 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7011 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7012 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7013 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7014 |
"Created: / 25-09-2006 / 12:25:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7015 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7016 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7017 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7018 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7019 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7020 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7021 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7022 |
"Created: / 25-09-2006 / 12:15:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7023 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7024 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7025 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7026 |
"I will combine only if we both are single character inserts, |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7027 |
and my col-to-insert is the next after anotherInsertActions end-col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7028 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7029 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7030 |
previousPasteAction line == line ifTrue:[ |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7031 |
previousPasteAction col == (self col2+1) ifTrue:[ |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7032 |
^ true |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7033 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7034 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7035 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7036 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7037 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7038 |
"Modified: / 25-09-2006 / 12:22:21 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7039 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7040 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7041 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7042 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7043 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7044 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7045 |
self assert:((col - 1) == (nextPasteAction col2)). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7046 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7047 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7048 |
s1 isString ifFalse:[s1 := s1 asStringWith:nil]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7049 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7050 |
s2 isString ifFalse:[s2 := s2 asStringWith:nil]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7051 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7052 |
string := s1, s2. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7053 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7054 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7055 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7056 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 7057 |
! ! |
7058 |
||
7059 |
!EditTextView::PasteString methodsFor:'execution'! |
|
7060 |
||
3160 | 7061 |
executeIn:editor |
2952 | 7062 |
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
|
7063 |
editor paste:string. |
2952 | 7064 |
selected ~~ true ifTrue:[ |
3160 | 7065 |
editor unselect |
2952 | 7066 |
]. |
7067 |
! ! |
|
7068 |
||
7069 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
7070 |
||
3235 | 7071 |
col |
7072 |
^ col |
|
7073 |
! |
|
7074 |
||
7075 |
col1 |
|
7076 |
^ col |
|
7077 |
! |
|
7078 |
||
7079 |
col2 |
|
7080 |
^ col |
|
7081 |
! |
|
7082 |
||
7083 |
line |
|
7084 |
^ line |
|
7085 |
! |
|
7086 |
||
3160 | 7087 |
line:lineArg col:colArg character:characterArg |
2952 | 7088 |
line := lineArg. |
7089 |
col := colArg. |
|
7090 |
character := characterArg. |
|
7091 |
! ! |
|
7092 |
||
7093 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
7094 |
||
3160 | 7095 |
executeIn:editor |
7096 |
editor |
|
7097 |
replace:character |
|
7098 |
atLine:line |
|
7099 |
col:col. |
|
2952 | 7100 |
editor cursorLine:line col:col. |
105 | 7101 |
! ! |
7102 |
||
3235 | 7103 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
7104 |
||
7105 |
characters |
|
7106 |
^ characters |
|
7107 |
! |
|
7108 |
||
7109 |
col1 |
|
7110 |
^ col1 |
|
7111 |
! |
|
7112 |
||
7113 |
col2 |
|
7114 |
^ col2 |
|
7115 |
! |
|
7116 |
||
7117 |
line |
|
7118 |
^ line |
|
7119 |
! |
|
7120 |
||
7121 |
line:lineArg col:colArg character:characterArg |
|
7122 |
line := lineArg. |
|
7123 |
col1 := col2 := colArg. |
|
7124 |
characters := characterArg asString. |
|
7125 |
! |
|
7126 |
||
7127 |
line:lineArg col:colArg characters:charactersArg |
|
7128 |
line := lineArg. |
|
7129 |
col1 := colArg. |
|
7130 |
characters := charactersArg asString. |
|
7131 |
col2 := col1 + charactersArg size - 1 |
|
7132 |
! ! |
|
7133 |
||
7134 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
7135 |
||
7136 |
canCombineWithNext:anotherAction |
|
7137 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
7138 |
! |
|
7139 |
||
7140 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
7141 |
"I will combine only if we both are single character deletes, |
|
7142 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
7143 |
(i.e. single-character typing)" |
|
7144 |
||
7145 |
previousReplaceAction line == line ifTrue:[ |
|
7146 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
|
7147 |
^ true |
|
7148 |
]. |
|
7149 |
]. |
|
7150 |
||
7151 |
^ false |
|
7152 |
! |
|
7153 |
||
7154 |
combineWithNext:nextReplaceAction |
|
7155 |
self assert:(line == nextReplaceAction line). |
|
7156 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
7157 |
||
7158 |
col2 := nextReplaceAction col2. |
|
7159 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
7160 |
characters := characters , nextReplaceAction characters. |
|
7161 |
! ! |
|
7162 |
||
7163 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
7164 |
||
7165 |
executeIn:editor |
|
7166 |
editor |
|
7167 |
replaceString:characters |
|
7168 |
atLine:line |
|
7169 |
col:col1. |
|
7170 |
editor cursorLine:line col:col1. |
|
7171 |
! ! |
|
7172 |
||
3131 | 7173 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
7174 |
||
7175 |
text:something |
|
7176 |
text := something. |
|
7177 |
! ! |
|
7178 |
||
7179 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
7180 |
||
3160 | 7181 |
executeIn:editor |
3131 | 7182 |
editor contents:text |
7183 |
! ! |
|
7184 |
||
3130 | 7185 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
7186 |
||
3160 | 7187 |
line:lineArg string:stringArg |
3130 | 7188 |
line := lineArg. |
7189 |
text := stringArg. |
|
7190 |
! ! |
|
7191 |
||
7192 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
7193 |
||
3160 | 7194 |
executeIn:editor |
3130 | 7195 |
editor list at:line put:text. |
7196 |
editor invalidateLine:line |
|
7197 |
! ! |
|
7198 |
||
3402 | 7199 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
7200 |
||
7201 |
line:lineArg lines:lineCollectionArg |
|
7202 |
line := lineArg. |
|
7203 |
text := lineCollectionArg. |
|
7204 |
||
7205 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
7206 |
! ! |
|
7207 |
||
7208 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
7209 |
||
7210 |
executeIn:editor |
|
7211 |
|lnr| |
|
7212 |
||
7213 |
lnr := line. |
|
7214 |
text do:[:eachLine | |
|
7215 |
editor list at:lnr put:eachLine. |
|
7216 |
editor invalidateLine:lnr. |
|
7217 |
lnr := lnr + 1. |
|
7218 |
]. |
|
7219 |
||
7220 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
7221 |
! ! |
|
7222 |
||
865 | 7223 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7224 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7225 |
version |
3566 | 7226 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.425 2008-02-28 09:34:57 cg Exp $' |
0 | 7227 |
! ! |