author | Claus Gittinger <cg@exept.de> |
Fri, 13 Jun 2008 11:01:06 +0200 | |
changeset 3631 | 7800380ae0dc |
parent 3623 | f99c70d99425 |
child 3650 | f3132c5a61a3 |
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:[ |
3631
7800380ae0dc
cannot send asStringWithoutFinalCR to non-stringcollections
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
2373 |
text := aDropObject theObject. |
7800380ae0dc
cannot send asStringWithoutFinalCR to non-stringcollections
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
2374 |
text isStringCollection ifTrue:[ |
7800380ae0dc
cannot send asStringWithoutFinalCR to non-stringcollections
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
2375 |
text := text asStringWithoutFinalCR |
7800380ae0dc
cannot send asStringWithoutFinalCR to non-stringcollections
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
2376 |
]. |
3415 | 2377 |
] ifFalse:[ |
2378 |
text := aDropObject theObject asString |
|
2379 |
]. |
|
3495 | 2380 |
self undoablePaste:text info:'drop'. |
3412 | 2381 |
]. |
2382 |
||
2383 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2384 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2385 |
! |
2386 |
||
2387 |
dropObjects:aCollectionOfDropObjects |
|
2388 |
"public from d&d. |
|
2389 |
drop objects (old API)" |
|
2390 |
||
2391 |
aCollectionOfDropObjects do:[:el| |
|
2392 |
self dropObject:el |
|
2393 |
]. |
|
2394 |
||
2395 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2396 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2397 |
! ! |
2398 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2400 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2401 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2402 |
"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
|
2403 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2404 |
selectionStartLine notNil ifTrue:[ |
3160 | 2405 |
self setClipboardText:(self selection). |
2406 |
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
|
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 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2409 |
"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
|
2410 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2411 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2412 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2413 |
"delete single character under cursor; does not merge lines" |
121 | 2414 |
|
2415 |
|wasOn| |
|
2416 |
||
2417 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2418 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2419 |
wasOn ifTrue:[self showCursor] |
2420 |
! |
|
2421 |
||
827 | 2422 |
deleteCharAtLine:lineNr col:colNr |
2423 |
"delete a single character at colNr in line lineNr" |
|
2424 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2425 |
self st80EditMode ifTrue:[ |
3160 | 2426 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2427 |
| wasOn | |
|
2428 |
wasOn := self hideCursor. |
|
2429 |
self |
|
2430 |
cursorReturn; |
|
2431 |
cursorCol:1; |
|
2432 |
deleteCharBeforeCursor. |
|
2433 |
wasOn ifTrue:[ self showCursor]. |
|
2434 |
^ self. |
|
2435 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2436 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2437 |
|
827 | 2438 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2439 |
! |
|
2440 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2441 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2442 |
"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
|
2443 |
|
2491 | 2444 |
|soCol wasOn lineNrAboveCursor ln prevTab| |
121 | 2445 |
|
2446 |
wasOn := self hideCursor. |
|
2491 | 2447 |
autoIndent ifTrue:[ |
3160 | 2448 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
2449 |
ln := (list at:cursorLine) ? ''. |
|
2450 |
ln size < prevTab ifTrue:[ |
|
2451 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2452 |
]. |
|
2453 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2454 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2455 |
cursorCol > prevTab ifTrue:[ |
|
2456 |
self cursorLine:cursorLine col:prevTab. |
|
2457 |
wasOn ifTrue:[ self showCursor ]. |
|
2458 |
^ self |
|
2459 |
]. |
|
2460 |
] ifFalse:[ |
|
2461 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2462 |
self cursorLine:cursorLine col:prevTab. |
|
2463 |
wasOn ifTrue:[ self showCursor ]. |
|
2464 |
^ self. |
|
2465 |
] |
|
2466 |
]. |
|
827 | 2467 |
]. |
2468 |
||
2491 | 2469 |
"/ (autoIndent |
2470 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2471 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2472 |
"/ ifTrue:[ |
2473 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2474 |
"/ |
|
2475 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2476 |
"/ ln := list at:cursorLine. |
|
2477 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2478 |
"/ soCol := 1 |
|
2479 |
"/ ] |
|
2480 |
"/ ] |
|
2481 |
"/ ] ifFalse:[ |
|
3160 | 2482 |
soCol := 1. |
2491 | 2483 |
"/ ]. |
2484 |
||
1419 | 2485 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
3160 | 2486 |
" |
2487 |
somewhere in the middle of a line |
|
2488 |
" |
|
2489 |
self cursorLeft. |
|
2490 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2491 |
] ifFalse:[ |
3160 | 2492 |
" |
2493 |
at begin of line - merge with previous line; |
|
2494 |
except for the very first line. |
|
2495 |
" |
|
2496 |
(cursorLine == 1) ifFalse:[ |
|
2497 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2498 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2499 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2500 |
"/ we are beyond the end of the text. |
|
2501 |
"/ move the cursor to the previous line. |
|
2502 |
self cursorLine:lineNrAboveCursor col:1. |
|
2503 |
] ifFalse:[ |
|
2504 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2505 |
] |
|
2506 |
] |
|
2507 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2508 |
]. |
827 | 2509 |
wasOn ifTrue:[ self showCursor ] |
2510 |
||
1419 | 2511 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2512 |
! |
2513 |
||
2514 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2515 |
"delete characters from colNr up to the end in line lineNr" |
|
2516 |
||
2517 |
|line| |
|
2518 |
||
2519 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
3160 | 2520 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2521 |
] |
2522 |
||
2523 |
! |
|
2524 |
||
2525 |
deleteCharsAtLine:lineNr toCol:colNr |
|
2526 |
"delete characters from start up to colNr in line lineNr" |
|
2527 |
||
2528 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2529 |
||
2530 |
||
121 | 2531 |
! |
2532 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2534 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2535 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
self deleteLine:cursorLine |
121 | 2537 |
! |
2538 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2539 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2540 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2541 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2542 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2543 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2544 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2545 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2546 |
col1 == 0 ifTrue:[ |
3160 | 2547 |
line1 := line1 - 1. |
2548 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2549 |
]. |
2385
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 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2552 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2553 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2554 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2555 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2556 |
|
2954 | 2557 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2558 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2559 |
joining lines if nescessary" |
|
2560 |
||
2561 |
|line newLine lineSize nMore| |
|
2562 |
||
2563 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2564 |
list isNil ifTrue:[^ self]. |
|
2565 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2566 |
||
2567 |
(startLine == endLine) ifTrue:[ |
|
3160 | 2568 |
"/ delete chars within a line |
2569 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2570 |
^ self |
|
2954 | 2571 |
]. |
2572 |
||
2573 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
3160 | 2574 |
"/ delete full lines only |
2575 |
endLine > startLine ifTrue:[ |
|
2576 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2577 |
]. |
|
2578 |
^ self |
|
2954 | 2579 |
]. |
2580 |
||
2581 |
"/ delete right rest of 1st line |
|
2582 |
self deleteCharsAtLine:startLine fromCol:startCol. |
|
2583 |
||
2584 |
"/ delete the inner lines ... |
|
2585 |
endLine > (startLine + 1) ifTrue:[ |
|
3160 | 2586 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 2587 |
]. |
2588 |
||
2589 |
(endCol ~~ 0) ifTrue:[ |
|
3160 | 2590 |
"/ delete the left rest of the last line |
2591 |
||
2592 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2593 |
||
2594 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2595 |
||
2596 |
line := list at:startLine. |
|
2597 |
lineSize := line size. |
|
2598 |
(startCol > lineSize) ifTrue:[ |
|
2599 |
newLine := line. |
|
2600 |
line isNil ifTrue:[ |
|
2601 |
newLine := String new:(startCol - 1) |
|
2602 |
] ifFalse:[ |
|
2603 |
nMore := startCol - 1 - lineSize. |
|
2604 |
nMore > 0 ifTrue:[ |
|
2605 |
newLine := line , (line species new:nMore) |
|
2606 |
] |
|
2607 |
]. |
|
2608 |
newLine ~~ line ifTrue:[ |
|
2609 |
list at:startLine put:newLine. |
|
2610 |
]. |
|
2611 |
"/ TODO: remember old maxwidth of linerange, |
|
2612 |
"/ only clear widthOfWidestLine, if this max |
|
2613 |
"/ length was (one of) the longest. |
|
2614 |
"/ avoids slow delete with huge texts. |
|
2615 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2616 |
self textChanged. |
|
2617 |
] |
|
2954 | 2618 |
]. |
2619 |
||
2620 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
2621 |
self mergeLine:startLine removeBlanks:false |
|
2622 |
||
2623 |
"Modified: / 10.11.1998 / 23:52:59 / cg" |
|
2624 |
! |
|
2625 |
||
827 | 2626 |
deleteLine:lineNr |
2627 |
"delete line" |
|
2628 |
||
2629 |
self deleteFromLine:lineNr toLine:lineNr |
|
2630 |
||
2631 |
||
2632 |
! |
|
2633 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2634 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2635 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2636 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2637 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2638 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2639 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2640 |
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
|
2641 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2643 |
(endLine > list size) ifTrue:[ |
3160 | 2644 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2645 |
] ifFalse:[ |
3160 | 2646 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2647 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2648 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2649 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2650 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2651 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2652 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2653 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2654 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2655 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2656 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2657 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2658 |
! |
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 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2661 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2662 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2663 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2664 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2665 |
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
|
2666 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2667 |
selectionStartLine notNil ifTrue:[ |
3160 | 2668 |
wasOn := self hideCursor. |
2669 |
||
2670 |
startLine := selectionStartLine. |
|
2671 |
startCol := selectionStartCol. |
|
2672 |
endLine := selectionEndLine. |
|
2673 |
endCol := selectionEndCol. |
|
2674 |
self unselectWithoutRedraw. |
|
2675 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
2676 |
self setCursorLine:startLine col:startCol. |
|
2677 |
||
2678 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2679 |
] |
121 | 2680 |
! |
2681 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2682 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2683 |
"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
|
2684 |
|
2952 | 2685 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2686 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2687 |
wasOn := self hideCursor. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2688 |
endCol := cursorCol-1. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2689 |
endLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2690 |
self cursorToPreviousWord. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2691 |
beginCol := cursorCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2692 |
beginLine := cursorLine. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2693 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2694 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2695 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2696 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2697 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2698 |
|
121 | 2699 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2700 |
"insert a single character at cursor-position - advance cursor." |
121 | 2701 |
|
2702 |
|wasOn| |
|
2703 |
||
2704 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2705 |
aCharacter == Character tab ifTrue:[ |
3160 | 2706 |
"/ needs special care to advance cursor correctly |
2707 |
self insertTabAtCursor |
|
121 | 2708 |
] ifFalse:[ |
3160 | 2709 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
2710 |
aCharacter == (Character cr) ifTrue:[ |
|
2711 |
self cursorReturn |
|
2712 |
] ifFalse:[ |
|
2713 |
self cursorRight. |
|
2714 |
]. |
|
121 | 2715 |
]. |
2716 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2717 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2718 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 2719 |
! |
2720 |
||
641 | 2721 |
insertLine:aString before:lineNr |
2722 |
"insert the line aString before line lineNr" |
|
2723 |
||
2724 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
2725 |
||
2726 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
2727 |
! |
|
2728 |
||
155 | 2729 |
insertLines:aStringCollection before:lineNr |
2730 |
"insert a bunch before line lineNr" |
|
2731 |
||
2732 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
2733 |
||
2734 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
2735 |
! |
|
2736 |
||
654 | 2737 |
insertLines:lines withCR:withCr |
3160 | 2738 |
"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
|
2739 |
Cursor is moved behind insertion. |
641 | 2740 |
If withCr is true, append cr after last line" |
2741 |
||
2742 |
|start end nLines wasOn| |
|
2743 |
||
2744 |
lines notNil ifTrue:[ |
|
3160 | 2745 |
nLines := lines size. |
2746 |
(nLines == 1) ifTrue:[ |
|
2747 |
self insertStringAtCursor:(lines at:1). |
|
2748 |
withCr ifTrue:[ |
|
2749 |
self insertCharAtCursor:(Character cr) |
|
2750 |
] |
|
2751 |
] ifFalse:[ |
|
2752 |
(cursorCol ~~ 1) ifTrue:[ |
|
2753 |
self insertStringAtCursor:(lines at:1). |
|
2754 |
self insertCharAtCursor:(Character cr). |
|
2755 |
start := 2 |
|
2756 |
] ifFalse:[ |
|
2757 |
start := 1 |
|
2758 |
]. |
|
2759 |
withCr ifTrue:[ |
|
2760 |
end := nLines |
|
2761 |
] ifFalse:[ |
|
2762 |
end := nLines - 1 |
|
2763 |
]. |
|
2764 |
(start < nLines) ifTrue:[ |
|
2765 |
(end >= start) ifTrue:[ |
|
2766 |
wasOn := self hideCursor. |
|
2767 |
self insertLines:lines from:start to:end before:cursorLine. |
|
2768 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
2769 |
wasOn ifTrue:[self showCursor]. |
|
2770 |
] |
|
2771 |
]. |
|
2772 |
withCr ifFalse:[ |
|
2773 |
"last line without cr" |
|
2774 |
self insertStringAtCursor:(lines at:nLines) |
|
2775 |
] |
|
2776 |
] |
|
641 | 2777 |
] |
654 | 2778 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
2779 |
"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
|
2780 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 2781 |
! |
2782 |
||
2783 |
insertLines:lines withCr:withCr |
|
2784 |
"insert a bunch of lines at cursor position. Cursor |
|
2785 |
is moved behind insertion. |
|
2786 |
If withCr is true, append cr after last line" |
|
2787 |
||
2363 | 2788 |
<resource:#obsolete> |
2789 |
||
1292 | 2790 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
2791 |
self insertLines:lines withCR:withCr. |
|
2792 |
||
2793 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 2794 |
! |
2795 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2796 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2797 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2798 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2799 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2800 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2802 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2803 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2804 |
self selectFromLine:startLine col:startCol |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
2805 |
toLine:cursorLine col:(cursorCol - 1). |
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
2806 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2807 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2808 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2809 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2810 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2811 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2812 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2813 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2814 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2815 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2816 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2817 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
2818 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2819 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2820 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2821 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2822 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2823 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2824 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2825 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2826 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2827 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2828 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2829 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2830 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2831 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 2832 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2833 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2834 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2835 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2836 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2837 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2838 |
[start <= end] whileTrue:[ |
3160 | 2839 |
stop := aString indexOf:(Character cr) startingAt:start. |
2840 |
stop == 0 ifTrue:[ |
|
2841 |
stop := end + 1 |
|
2842 |
]. |
|
2843 |
subString := aString copyFrom:start to:(stop - 1). |
|
2844 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
2845 |
(stop <= end) ifTrue:[ |
|
2846 |
c := c + subString size. |
|
2847 |
self insert:(Character cr) atLine:l col:c. |
|
2848 |
l := l + 1. |
|
2849 |
c := 1 |
|
2850 |
]. |
|
2851 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2852 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2853 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2854 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 2855 |
! |
2856 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2857 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2858 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2859 |
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
|
2860 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2861 |
aString isNil ifTrue:[ |
3160 | 2862 |
"new:" |
2863 |
self insertCharAtCursor:(Character cr). |
|
2864 |
^ self |
|
105 | 2865 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2866 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 2867 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 2868 |
]. |
2869 |
||
654 | 2870 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2871 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
2872 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 2873 |
! |
2874 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2875 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2876 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2877 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2878 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2879 |
shown ifTrue:[self redrawLine:lineNr from:colNr] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2880 |
|
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
2881 |
"Modified: / 5.4.1998 / 16:51:14 / cg" |
105 | 2882 |
! |
2883 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2884 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2885 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2886 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2887 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2888 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2889 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2890 |
aString size > 0 ifTrue:[ |
3160 | 2891 |
wasOn := self hideCursor. |
2892 |
(aString includes:Character tab) ifTrue:[ |
|
2893 |
self checkForExistingLine:cursorLine. |
|
2894 |
oldLen := (list at:cursorLine) size. |
|
2895 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
2896 |
newLen := (list at:cursorLine) size. |
|
2897 |
deltaLen := newLen - oldLen. |
|
2898 |
] ifFalse:[ |
|
2899 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
2900 |
deltaLen := aString size. |
|
2901 |
]. |
|
2902 |
self setCursorCol:(cursorCol + deltaLen). |
|
2903 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2904 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2905 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
2906 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2907 |
! |
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 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2910 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2911 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2912 |
|wasOn nextTab| |
105 | 2913 |
|
121 | 2914 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2915 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2916 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2917 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 2918 |
! |
2919 |
||
3542 | 2920 |
joinLines |
3583 | 2921 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
2922 |
||
3542 | 2923 |
self |
2924 |
undoableDo:[ |
|
3549 | 2925 |
|line col lineLen| |
2926 |
||
2927 |
line := cursorLine. |
|
2928 |
col := cursorCol. |
|
2929 |
lineLen := (list at:line) size. |
|
2930 |
col > lineLen ifTrue:[ |
|
2931 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
2932 |
] ifFalse:[ |
|
2933 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
2934 |
]. |
|
2935 |
self mergeLine:line removeBlanks:true. |
|
2936 |
self cursorLine:line col:col. |
|
3542 | 2937 |
] |
2938 |
info:'Join' |
|
2939 |
! |
|
2940 |
||
2952 | 2941 |
mergeLine:lineNr |
2942 |
"merge line lineNr with line lineNr+1" |
|
2943 |
||
2944 |
self mergeLine:lineNr removeBlanks:true |
|
2945 |
||
2946 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
2947 |
! |
|
2948 |
||
2506 | 2949 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2950 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2951 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2952 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2953 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2954 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2955 |
|
2506 | 2956 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
3160 | 2957 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
2958 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
2959 |
newSelectionEnd := newSelectionEnd-1. |
|
2960 |
]. |
|
2961 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
2962 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2963 |
newSelectionEnd := newSelectionEnd-1. |
|
2964 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2965 |
] ifFalse:[ |
3160 | 2966 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
2967 |
newSelectionEnd := newSelectionEnd+1. |
|
2968 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
2969 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
2970 |
newSelectionEnd := newSelectionEnd+1. |
|
2971 |
] |
|
2972 |
]. |
|
2973 |
self |
|
2974 |
selectFromLine:selectionStartLine col:selectionStartCol |
|
2975 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2976 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
2977 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2978 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2979 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2980 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2981 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2982 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2983 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2984 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2985 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2986 |
[finished] whileFalse:[ |
3160 | 2987 |
(lastLine <= 1) ifTrue:[ |
2988 |
finished := true |
|
2989 |
] ifFalse:[ |
|
2990 |
line := list at:lastLine. |
|
2991 |
line notNil ifTrue:[ |
|
2992 |
line isBlank ifTrue:[ |
|
2993 |
list at:lastLine put:nil. |
|
2994 |
line := nil |
|
2995 |
] |
|
2996 |
]. |
|
2997 |
line notNil ifTrue:[ |
|
2998 |
finished := true |
|
2999 |
] ifFalse:[ |
|
3000 |
lastLine := lastLine - 1 |
|
3001 |
] |
|
3002 |
] |
|
118 | 3003 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3004 |
(lastLine ~~ list size) ifTrue:[ |
3160 | 3005 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3006 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3007 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3008 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3009 |
|
3430 | 3010 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ign |
3011 |
|pattern replacePattern| |
|
3012 |
||
3013 |
pattern := patternArg string. |
|
3014 |
replacePattern := replacePatternArg string. |
|
3015 |
^ (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
|
3016 |
self rememberSearchPattern:pattern. |
|
3017 |
self rememberSearchPattern:replacePattern. |
|
3018 |
LastSearchIgnoredCase := ign. |
|
3019 |
self |
|
3020 |
undoableDo:[ |
|
3021 |
all ifTrue:[ |
|
3022 |
self |
|
3023 |
replaceString:pattern |
|
3024 |
to:replacePattern |
|
3025 |
ignoreCase:ign |
|
3026 |
] ifFalse:[ |
|
3027 |
(self selectionAsString notNil |
|
3028 |
and:[ self selectionAsString sameAs:pattern ignoreCase:ign ]) |
|
3029 |
ifTrue:[ |
|
3030 |
self replaceSelectionWith:replacePattern. |
|
3031 |
self |
|
3032 |
search:pattern |
|
3033 |
ignoreCase:ign |
|
3034 |
forward:(lastSearchDirection = #forward). |
|
3035 |
]. |
|
3036 |
] |
|
3037 |
] |
|
3542 | 3038 |
info:'Replace' |
3430 | 3039 |
] |
3040 |
||
3041 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3042 |
! |
|
3043 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3044 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3045 |
"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
|
3046 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3047 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3048 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3049 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3050 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3051 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3052 |
] ifFalse:[ |
3160 | 3053 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3054 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3055 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3056 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3057 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3058 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3059 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3060 |
|
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3061 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3062 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3063 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3064 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3065 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3066 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3067 |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3068 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3069 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3070 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3071 |
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
|
3072 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3073 |
|
1809 | 3074 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3075 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3076 |
lines notNil ifTrue:[ |
3160 | 3077 |
wasOn := self hideCursor. |
3078 |
nLines := lines size. |
|
3079 |
line := cursorLine. |
|
3080 |
col := cursorCol. |
|
3081 |
lines keysAndValuesDo:[:i :l | |
|
3082 |
self replaceString:l atLine:line col:col. |
|
3083 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3084 |
line := line + 1. |
|
3085 |
col := 1. |
|
3086 |
] ifFalse:[ |
|
3087 |
col := col + (l size). |
|
3088 |
] |
|
3089 |
]. |
|
3090 |
self cursorLine:line col:col. |
|
3091 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3092 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3093 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3094 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3095 |
"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
|
3096 |
"Modified: / 12.6.1998 / 22:05:51 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3097 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3098 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3099 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3100 |
"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
|
3101 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3102 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3103 |
self replaceSelectionBy:something keepCursor:false |
105 | 3104 |
! |
3105 |
||
3106 |
replaceSelectionBy:something keepCursor:keep |
|
3107 |
"delete the selection (if any) and insert something, a character or string; |
|
3108 |
leave cursor after insertion or leave it, depending on keep" |
|
3109 |
||
3110 |
|sel l c| |
|
3111 |
||
3112 |
l := cursorLine. |
|
3113 |
c := cursorCol. |
|
3114 |
||
3115 |
sel := self selection. |
|
3116 |
sel notNil ifTrue:[ |
|
3161 | 3117 |
lastString := sel. |
3118 |
self deleteSelection. |
|
3119 |
replacing := true. |
|
3120 |
lastReplacement := ''. |
|
3121 |
undoSupport actionInfo:'replace'. |
|
3122 |
]. |
|
3123 |
||
3124 |
something isCharacter ifTrue:[ |
|
3125 |
lastReplacement notNil ifTrue:[ |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3126 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3127 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3128 |
"/ lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3129 |
"/ lastReplacement := lastReplacement copyWith:something. |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3130 |
"/ lastReplacement := lastReplacement copyWith:Character space |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3131 |
"/ ] ifFalse:[ |
3161 | 3132 |
lastReplacement := lastReplacement copyWith:something. |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3133 |
"/ ] |
3161 | 3134 |
]. |
3235 | 3135 |
self isInInsertMode ifTrue:[ |
3161 | 3136 |
self insertCharAtCursor:something |
3137 |
] ifFalse:[ |
|
3138 |
self replaceCharAtCursor:something |
|
3139 |
] |
|
105 | 3140 |
] ifFalse:[ |
3161 | 3141 |
something isString ifTrue:[ |
3142 |
lastReplacement := something. |
|
3235 | 3143 |
self isInInsertMode ifTrue:[ |
3161 | 3144 |
self insertStringAtCursor:something |
3145 |
] ifFalse:[ |
|
3146 |
self replaceStringAtCursor:something |
|
3147 |
] |
|
3148 |
] ifFalse:[ |
|
3149 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3150 |
]. |
|
105 | 3151 |
]. |
3152 |
keep ifTrue:[ |
|
3161 | 3153 |
self cursorLine:l col:c |
105 | 3154 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3155 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3156 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3157 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3158 |
|
3549 | 3159 |
replaceString:aString to:aNewString ignoreCase:ign |
3160 |
|continue count| |
|
3161 |
||
3162 |
self cursorToTop. |
|
3163 |
self selectFromBeginning. |
|
3164 |
count := 0. |
|
3165 |
continue := true. |
|
3166 |
[ continue ] whileTrue:[ |
|
3167 |
(self selectionAsString notNil |
|
3168 |
and:[ self selectionAsString sameAs:aString ignoreCase:ign ]) |
|
3169 |
ifTrue:[ |
|
3170 |
self replaceSelectionWith:aNewString. |
|
3171 |
count := count + 1. |
|
3172 |
]. |
|
3173 |
self |
|
3174 |
searchFwd:aString |
|
3175 |
ignoreCase:ign |
|
3176 |
ifAbsent:[ |
|
3177 |
Dialog |
|
3178 |
information:aString , ' has been replaced to ' , aNewString , ' ' |
|
3179 |
, count printString , ' times'. |
|
3180 |
continue := false. |
|
3181 |
]. |
|
3182 |
]. |
|
3430 | 3183 |
|
3184 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3185 |
! |
|
3186 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3187 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3188 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3189 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3190 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3191 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3192 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3193 |
(aString includes:Character tab) ifTrue:[ |
3160 | 3194 |
"/ need special care for TAB (to move cursor correctly) |
3195 |
i1 := 1. |
|
3196 |
[i1 ~~ 0] whileTrue:[ |
|
3197 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3198 |
i2 ~~ 0 ifTrue:[ |
|
3199 |
i1 ~~ i2 ifTrue:[ |
|
3200 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3201 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3202 |
]. |
|
3203 |
self replaceTABAtCursor. |
|
3204 |
i2 := i2 + 1. |
|
3205 |
] ifFalse:[ |
|
3206 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3207 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3208 |
]. |
|
3209 |
i1 := i2. |
|
3210 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3211 |
] ifFalse:[ |
3160 | 3212 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3213 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3214 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3215 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3216 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3217 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3218 |
"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
|
3219 |
! |
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 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3222 |
"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
|
3223 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3224 |
|wasOn nextTab| |
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 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3227 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3228 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3229 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3230 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3231 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3232 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3233 |
|
2752 | 3234 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3235 |
|
2952 | 3236 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3237 |
"delete characters from startCol to endCol in line lineNr" |
3238 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
3239 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3240 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3241 |
line := self listAt:lineNr. |
827 | 3242 |
|
3160 | 3243 |
(self checkModificationsAllowed and:[line notNil]) ifTrue:[ |
3549 | 3244 |
lineSize := line size. |
3245 |
||
3246 |
startCol == 0 ifFalse:[ start := startCol ] |
|
3247 |
ifTrue:[ start := 1 ]. |
|
3248 |
||
3249 |
endCol > lineSize ifFalse:[ stop := endCol ] |
|
3250 |
ifTrue:[ stop := lineSize ]. |
|
3251 |
||
3252 |
stop >= start ifTrue:[ |
|
3253 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
3254 |
ifFalse:[ newLine := '' ]. |
|
3255 |
||
3256 |
stop == lineSize ifFalse:[ |
|
3257 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
3258 |
newLine := line string species fromString:newLine. |
|
3259 |
]. |
|
3260 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
3261 |
]. |
|
3262 |
||
3263 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
3264 |
newLine := nil |
|
3265 |
]. |
|
3266 |
||
3267 |
prevWidth := self widthOfLine:lineNr. |
|
3268 |
||
3269 |
list at:lineNr put:newLine. |
|
3270 |
||
3271 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
3272 |
"/ remember old width of this line, |
|
3273 |
"/ only clear widthOfWidestLine, if this lines |
|
3274 |
"/ length was (one of) the longest. |
|
3275 |
"/ avoids slow delete with huge texts. |
|
3276 |
widthOfWidestLine := nil. "i.e. unknown" |
|
3277 |
||
3278 |
"/ scroll left if reqiured |
|
3279 |
viewOrigin x > 0 ifTrue:[ |
|
3280 |
newWidth := self widthOfLine:lineNr. |
|
3281 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
3282 |
self scrollHorizontalTo:(newWidth |
|
3283 |
- width |
|
3284 |
+ margin + margin |
|
3285 |
+ (font widthOf:' ')) |
|
3286 |
] |
|
3287 |
]. |
|
3288 |
self textChanged. |
|
3289 |
] ifFalse:[ |
|
3290 |
self textChanged "/ textChangedButNoSizeChange |
|
3291 |
]. |
|
3292 |
self redrawLine:lineNr from:start. |
|
3293 |
||
3294 |
] |
|
827 | 3295 |
] |
3296 |
||
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3297 |
"Modified: / 11.11.1998 / 00:01:09 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3298 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3299 |
|
2952 | 3300 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3301 |
"delete some lines" |
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 nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3304 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3305 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3306 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3307 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3308 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3309 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3310 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3311 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3312 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3313 |
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
|
3314 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3315 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3316 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3317 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3318 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3319 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3320 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3321 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3322 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3323 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3324 |
(firstLineShown >= nLines) ifTrue:[ |
3160 | 3325 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3326 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3327 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3328 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3329 |
"Modified: / 10.11.1998 / 23:55:05 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3330 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3331 |
|
2952 | 3332 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3333 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3334 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3335 |
|
2952 | 3336 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3337 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3338 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3339 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3340 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3341 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3342 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3343 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3344 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3345 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3346 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3347 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3348 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3349 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3350 |
|
2952 | 3351 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 3352 |
"insert a single character at lineNr/colNr; |
827 | 3353 |
set emphasis to character at current position" |
3354 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
3355 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3356 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3357 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3358 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3359 |
aCharacter == (Character cr) ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3360 |
self splitLine:lineNr before:colNr. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3361 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3362 |
]. |
827 | 3363 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3364 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3365 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3366 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3367 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3368 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3369 |
self st80EditMode ifFalse:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3370 |
(trimBlankLines |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3371 |
and:[colNr > lineSize |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3372 |
and:[aCharacter == Character space]]) ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3373 |
^ self |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3374 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3375 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3376 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3377 |
(lineSize == 0) ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3378 |
newLine := aCharacter asString species new:colNr. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3379 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3380 |
] ifFalse: [ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3381 |
(colNr > lineSize) ifTrue: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3382 |
colNr == (lineSize +1) ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3383 |
attribute := line emphasisAt:lineSize |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3384 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3385 |
newLine := line species new:colNr. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3386 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3387 |
drawCharacterOnly := true |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3388 |
] ifFalse: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3389 |
attribute := line emphasisAt:colNr. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3390 |
newLine := line species new:(lineSize + 1). |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3391 |
|
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3392 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3393 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3394 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3395 |
]. |
827 | 3396 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3397 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3398 |
newLine := aCharacter asString species fromString:newLine. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3399 |
line isText ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3400 |
newLine := newLine asText |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3401 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3402 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3403 |
newLine at:colNr put:aCharacter. |
827 | 3404 |
|
3405 |
attribute notNil ifTrue:[ |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3406 |
newLine emphasisAt:colNr put:attribute. |
827 | 3407 |
]. |
3408 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3409 |
aCharacter == (Character tab) ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3410 |
newLine := self withTabsExpanded:newLine. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3411 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3412 |
]. |
827 | 3413 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3414 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3415 |
widthOfWidestLine notNil ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3416 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3417 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3418 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3419 |
shown ifTrue:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3420 |
"/ care for italic text - in this case, we must also |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3421 |
"/ redraw the character before the insertion in order |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3422 |
"/ to fix the slanted piece of the character. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3423 |
"/ (but we must clip, to avoid destoying the character before) |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3424 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3425 |
colNr > 1 ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3426 |
cursorVisibleLine notNil ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3427 |
oldClip := self clippingRectangleOrNil. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3428 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3429 |
y := self yOfVisibleLine:cursorVisibleLine. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3430 |
drawCharacterOnly ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3431 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3432 |
self redrawLine:lineNr from:colNr-1 to:colNr |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3433 |
] ifFalse:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3434 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3435 |
self redrawLine:lineNr from:colNr-1 |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3436 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3437 |
self clippingRectangle:oldClip. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3438 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3439 |
^ self. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3440 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3441 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3442 |
drawCharacterOnly ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3443 |
self redrawLine:lineNr col:colNr |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3444 |
] ifFalse:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3445 |
self redrawLine:lineNr from:colNr |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3446 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3447 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3448 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
3449 |
"Modified: / 20.6.1998 / 18:19:22 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3450 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3451 |
|
2952 | 3452 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 3453 |
"merge line lineNr with line lineNr+1" |
3454 |
||
827 | 3455 |
|leftPart rightPart bothParts nextLineNr i| |
3456 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
3457 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
3160 | 3458 |
"/ empty list or beyond end of text |
3459 |
^ self |
|
827 | 3460 |
]. |
3461 |
leftPart := self listAt:lineNr. |
|
3462 |
||
3463 |
leftPart isNil ifTrue:[ |
|
3160 | 3464 |
leftPart := ''. |
3465 |
autoIndent ifTrue:[ |
|
3466 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
3467 |
leftPart := String new:i |
|
3468 |
] |
|
3469 |
] |
|
827 | 3470 |
]. |
3471 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
3472 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
3473 |
||
3474 |
nextLineNr > (list size) ifFalse:[ |
|
3160 | 3475 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
3476 |
rightPart := '' |
|
3477 |
] ifFalse:[ |
|
3478 |
removeBlanks ifTrue:[ |
|
3479 |
rightPart := rightPart withoutLeadingSeparators. |
|
3480 |
] |
|
3481 |
]. |
|
3482 |
||
3483 |
bothParts := leftPart , rightPart. |
|
3484 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
3485 |
list at:lineNr put:bothParts. |
|
3486 |
self redrawLine:lineNr. |
|
3487 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3488 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3489 |
|
1319 | 3490 |
"Created: 9.9.1997 / 09:27:38 / cg" |
3491 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3492 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3493 |
|
2952 | 3494 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3495 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3496 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3497 |
|line lineSize newLine drawCharacterOnly| |
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 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3500 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3501 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3502 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3503 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3504 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3505 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3506 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3507 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3508 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3509 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3510 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3511 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3512 |
and:[aCharacter == Character space]]) ifTrue:[ |
3160 | 3513 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3514 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3515 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3516 |
(lineSize == 0) ifTrue:[ |
3160 | 3517 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3518 |
] ifFalse: [ |
3160 | 3519 |
(colNr > lineSize) ifTrue: [ |
3520 |
newLine := line species new:colNr. |
|
3521 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3522 |
] ifFalse: [ |
|
3523 |
newLine := line copy. |
|
3524 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3525 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3526 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3527 |
aCharacter == (Character tab) ifTrue:[ |
3160 | 3528 |
newLine := self withTabsExpanded:newLine. |
3529 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3530 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3531 |
list at:lineNr put:newLine. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3532 |
widthOfWidestLine notNil ifTrue:[ |
3160 | 3533 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3534 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3535 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3536 |
shown ifTrue:[ |
3160 | 3537 |
drawCharacterOnly ifTrue:[ |
3538 |
self redrawLine:lineNr col:colNr |
|
3539 |
] ifFalse:[ |
|
3540 |
self redrawLine:lineNr from:colNr |
|
3541 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3542 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3543 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
3544 |
"Created: / 6.3.1996 / 12:29:20 / cg" |
1559
cecf77805bff
expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
3545 |
"Modified: / 10.6.1998 / 18:50:18 / cg" |
105 | 3546 |
! |
3547 |
||
3235 | 3548 |
basicReplaceString:aString atLine:lineNr col:colNr |
3549 |
"replace multiple characters starting at lineNr/colNr. |
|
3550 |
This is not prepared to encounter special chars (except TAB) |
|
3551 |
in the string." |
|
3552 |
||
3553 |
|line lineSize newLine endCol| |
|
3554 |
||
3555 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3556 |
||
3557 |
self checkForExistingLine:lineNr. |
|
3558 |
line := list at:lineNr. |
|
3559 |
lineSize := line size. |
|
3560 |
||
3561 |
endCol := colNr + aString size - 1. |
|
3562 |
(lineSize == 0) ifTrue:[ |
|
3563 |
newLine := aString species new:endCol. |
|
3564 |
] ifFalse: [ |
|
3565 |
(endCol > lineSize) ifTrue: [ |
|
3566 |
aString isText ifTrue:[ |
|
3567 |
newLine := aString species new:endCol. |
|
3568 |
] ifFalse:[ |
|
3569 |
newLine := line species new:endCol. |
|
3570 |
]. |
|
3571 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3572 |
] ifFalse: [ |
|
3573 |
aString isText ifTrue:[ |
|
3574 |
newLine := aString species new:line size. |
|
3575 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3576 |
] ifFalse:[ |
|
3577 |
newLine := line copy. |
|
3578 |
] |
|
3579 |
] |
|
3580 |
]. |
|
3581 |
newLine replaceFrom:colNr with:aString. |
|
3582 |
(aString includes:(Character tab)) ifTrue:[ |
|
3583 |
newLine := self withTabsExpanded:newLine. |
|
3584 |
]. |
|
3585 |
list at:lineNr put:newLine. |
|
3586 |
widthOfWidestLine notNil ifTrue:[ |
|
3587 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3588 |
]. |
|
3589 |
self textChanged. |
|
3590 |
shown ifTrue:[ |
|
3591 |
self redrawLine:lineNr from:colNr |
|
3592 |
] |
|
3593 |
||
3594 |
"Created: / 11.6.1998 / 10:38:32 / cg" |
|
3595 |
"Modified: / 20.6.1998 / 20:23:50 / cg" |
|
3596 |
! |
|
3597 |
||
2952 | 3598 |
basicSplitLine:lineNr before:colNr |
3599 |
"split the line linNr before colNr; the right part (from colNr) |
|
3600 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3601 |
||
3160 | 3602 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 3603 |
srcY "{ Class: SmallInteger }" | |
3604 |
||
3027 | 3605 |
list isNil ifTrue:[ ^ self ]. |
3606 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
3607 |
||
3608 |
(colNr == 1) ifTrue:[ |
|
3160 | 3609 |
self nonUndoableDo:[ |
3610 |
self insertLine:nil before:lineNr. |
|
3611 |
]. |
|
3612 |
^ self |
|
3027 | 3613 |
]. |
3614 |
||
3615 |
line := list at:lineNr. |
|
3616 |
line isNil ifFalse:[ |
|
3160 | 3617 |
lineSize := line size. |
3618 |
(colNr <= lineSize) ifTrue:[ |
|
3619 |
rightRest := line copyFrom:colNr to:lineSize. |
|
3620 |
(colNr > 1) ifTrue:[ |
|
3621 |
leftRest := line copyTo:(colNr - 1) |
|
3622 |
] |
|
3623 |
] ifFalse:[ |
|
3624 |
leftRest := line |
|
3625 |
] |
|
3027 | 3626 |
]. |
3627 |
leftRest notNil ifTrue:[ |
|
3160 | 3628 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 3629 |
]. |
3630 |
list at:lineNr put:leftRest. |
|
3631 |
self nonUndoableDo:[ |
|
3160 | 3632 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 3633 |
]. |
3634 |
visLine := self listLineToVisibleLine:(lineNr). |
|
3635 |
visLine notNil ifTrue:[ |
|
3160 | 3636 |
w := self widthForScrollBetween:lineNr |
3637 |
and:(firstLineShown + nLinesShown). |
|
3638 |
srcY := topMargin + (visLine * fontHeight). |
|
3639 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
3640 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
3641 |
self catchExpose. |
|
3642 |
self |
|
3643 |
copyFrom:self |
|
3644 |
x:textStartLeft y:srcY |
|
3645 |
toX:textStartLeft y:(srcY + fontHeight) |
|
3646 |
width:w |
|
3647 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
3648 |
async:true. |
|
3649 |
]. |
|
3650 |
self redrawLine:lineNr. |
|
3651 |
self redrawLine:(lineNr + 1). |
|
3652 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 3653 |
]. |
3654 |
widthOfWidestLine := nil. "/ unknown |
|
3655 |
self textChanged. |
|
2952 | 3656 |
|
3657 |
"Modified: 29.1.1997 / 13:03:22 / cg" |
|
3658 |
! |
|
3659 |
||
3660 |
basicWithoutRedrawInsertLine:aString before:lineNr |
|
3661 |
"insert the argument, aString before line lineNr; the string |
|
3662 |
becomes line nileNr; everything else is moved down; the view |
|
3663 |
is not redrawn" |
|
3664 |
||
3665 |
|line| |
|
3666 |
||
3667 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3668 |
||
3669 |
line := aString. |
|
3670 |
line notNil ifTrue:[ |
|
3160 | 3671 |
line isString ifTrue:[ |
3672 |
line isBlank ifTrue:[ |
|
3673 |
line := nil |
|
3674 |
] ifFalse:[ |
|
3675 |
(line includes:(Character tab)) ifTrue:[ |
|
3676 |
line := self withTabsExpanded:line |
|
3677 |
] |
|
3678 |
] |
|
3679 |
] |
|
2952 | 3680 |
]. |
3681 |
list isNil ifTrue: [ |
|
3160 | 3682 |
list := StringCollection new:lineNr |
2952 | 3683 |
] ifFalse: [ |
3160 | 3684 |
list grow:((list size + 1) max:lineNr) |
3685 |
]. |
|
3686 |
||
3687 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2952 | 3688 |
overlapping copy - if it didn't, we had to use:" |
3689 |
" |
|
3690 |
index := list size. |
|
3691 |
[index > lineNr] whileTrue: [ |
|
3160 | 3692 |
pIndex := index - 1. |
3693 |
list at:index put:(list at:pIndex). |
|
3694 |
index := pIndex |
|
2952 | 3695 |
]. |
3696 |
" |
|
3697 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
|
3698 |
list at:lineNr put:line. |
|
3699 |
self contentsChanged |
|
3700 |
||
3701 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
|
3702 |
! |
|
3703 |
||
2954 | 3704 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
3705 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3706 |
||
3707 |
|newLine newLines nLines| |
|
3708 |
||
3709 |
nLines := end - start + 1. |
|
3710 |
newLines := Array new:(lines size). |
|
3711 |
start to:end do:[:index | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3712 |
newLine := lines at:index. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3713 |
newLine notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3714 |
newLine isString ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3715 |
newLine isBlank ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3716 |
newLine := nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3717 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3718 |
(newLine includes:(Character tab)) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3719 |
newLine := self withTabsExpanded:newLine |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3720 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3721 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3722 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3723 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3724 |
newLines at:index put:newLine |
2954 | 3725 |
]. |
3726 |
list isNil ifTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3727 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 3728 |
] ifFalse: [ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3729 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 3730 |
]. |
3731 |
||
3732 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 3733 |
overlapping copy - if it didn't, we had to use:" |
3734 |
" |
|
3735 |
index := list size. |
|
3736 |
[index > lineNr] whileTrue: [ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3737 |
pIndex := index - 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3738 |
list at:index put:(list at:pIndex). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3739 |
index := pIndex |
2954 | 3740 |
]. |
3741 |
" |
|
3742 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
3743 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
3744 |
self contentsChanged |
|
3745 |
||
3746 |
"Modified: / 10.6.1998 / 19:01:16 / cg" |
|
3747 |
! |
|
3748 |
||
3749 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3750 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3751 |
||
3752 |
|isText strLen line lineSize newLine stringType sz| |
|
3753 |
||
3754 |
(aString notNil) ifFalse:[ ^ self]. |
|
3755 |
||
3756 |
strLen := aString size. |
|
3757 |
self checkForExistingLine:lineNr. |
|
3758 |
||
3759 |
stringType := aString string species. |
|
3760 |
isText := aString isText. |
|
3761 |
line := list at:lineNr. |
|
3762 |
||
3763 |
line notNil ifTrue:[ |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3764 |
lineSize := line size. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3765 |
line isString ifFalse:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3766 |
stringType := line species |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3767 |
] ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3768 |
line bitsPerCharacter > aString bitsPerCharacter ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3769 |
stringType := line string species |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3770 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3771 |
line isText ifTrue:[ isText := true ] |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3772 |
]. |
2954 | 3773 |
] ifFalse:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3774 |
lineSize := 0 |
2954 | 3775 |
]. |
3776 |
||
3777 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3778 |
newLine := aString |
2954 | 3779 |
] ifFalse:[ |
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3780 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3781 |
sz := colNr + strLen - 1 |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3782 |
] ifFalse:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3783 |
sz := lineSize + strLen |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3784 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3785 |
|
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3786 |
isText ifFalse:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3787 |
newLine := stringType new:sz |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3788 |
] ifTrue:[ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3789 |
newLine := Text string:(stringType new:sz) |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3790 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3791 |
|
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3792 |
(lineSize ~~ 0) ifTrue: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3793 |
(colNr > lineSize) ifTrue: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3794 |
newLine replaceFrom:1 to:lineSize |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3795 |
with:line startingAt:1 |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3796 |
] ifFalse: [ |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3797 |
newLine replaceFrom:1 to:(colNr - 1) |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3798 |
with:line startingAt:1. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3799 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3800 |
with:line startingAt:colNr |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3801 |
] |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3802 |
]. |
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3803 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
2954 | 3804 |
]. |
3805 |
||
3806 |
(aString includes:(Character tab)) ifTrue:[ |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3807 |
newLine := self withTabsExpanded:newLine |
2954 | 3808 |
]. |
3809 |
||
3810 |
list at:lineNr put:newLine. |
|
3811 |
widthOfWidestLine notNil ifTrue:[ |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
3812 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 3813 |
]. |
3814 |
self textChanged. |
|
3815 |
||
3816 |
"Modified: / 10.6.1998 / 19:01:52 / cg" |
|
3817 |
! |
|
3818 |
||
2952 | 3819 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3820 |
"delete characters from startCol to endCol in line lineNr" |
3821 |
||
2952 | 3822 |
|deleted| |
3823 |
||
3824 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3825 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3115 | 3826 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
2952 | 3827 |
! |
3828 |
||
3829 |
deleteFromLine:startLineNr toLine:endLineNr |
|
3830 |
"delete some lines" |
|
3831 |
||
3832 |
|deleted| |
|
3833 |
||
3834 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3835 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3115 | 3836 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
2952 | 3837 |
! |
3838 |
||
3839 |
deleteLineWithoutRedraw:lineNr |
|
3840 |
"delete line - no redraw; |
|
3841 |
return true, if something was really deleted" |
|
3842 |
||
3843 |
|deleted ret| |
|
3844 |
||
3845 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3846 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3115 | 3847 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
2952 | 3848 |
^ ret. |
3849 |
! |
|
3850 |
||
3851 |
insert:aCharacter atLine:lineNr col:colNr |
|
3160 | 3852 |
"insert a single character at lineNr/colNr; |
2952 | 3853 |
set emphasis to character at current position" |
3854 |
||
3855 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3856 |
aCharacter ~~ Character cr ifTrue:[ |
|
3160 | 3857 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
2952 | 3858 |
] |
3859 |
! |
|
3860 |
||
3861 |
insertLines:someText from:start to:end before:lineNr |
|
3862 |
"insert a bunch of lines before line lineNr" |
|
3863 |
||
2954 | 3864 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
3865 |
srcY "{ Class: SmallInteger }" |
|
3866 |
dstY "{ Class: SmallInteger }" | |
|
3867 |
||
3868 |
autoIndent ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3869 |
indent := self leftIndentForLine:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3870 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3871 |
text := someText collect:[:ln||line| |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3872 |
ln notNil ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3873 |
line := ln withoutLeadingSeparators. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3874 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3875 |
line := (String new:indent), line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3876 |
]. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3877 |
line |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3878 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3879 |
nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3880 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3881 |
]. |
2954 | 3882 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3883 |
text := someText |
2954 | 3884 |
]. |
3885 |
||
3886 |
visLine := self listLineToVisibleLine:lineNr. |
|
3887 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3888 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3889 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3890 |
before:lineNr. |
2954 | 3891 |
] ifFalse:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3892 |
nLines := end - start + 1. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3893 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3894 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3895 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3896 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3897 |
self redrawFromVisibleLine:visLine to:nLinesShown |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3898 |
] ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3899 |
w := self widthForScrollBetween:(lineNr + nLines) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3900 |
and:(firstLineShown + nLines + nLinesShown). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3901 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3902 |
dstY := srcY + (nLines * fontHeight). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3903 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3904 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3905 |
"/ scroll ... |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3906 |
"/ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3907 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3908 |
stupid: must catchExpose before inserting new |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3909 |
stuff - since catchExpose may perform redraws |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3910 |
" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3911 |
self catchExpose. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3912 |
self withoutRedrawInsertLines:text |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3913 |
from:start to:end |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3914 |
before:lineNr. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3915 |
self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3916 |
copyFrom:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3917 |
x:textStartLeft y:srcY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3918 |
toX:textStartLeft y:dstY |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3919 |
width:w |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3920 |
height:(height - dstY) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3921 |
async:true. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3922 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3923 |
self waitForExpose |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3924 |
]. |
2954 | 3925 |
]. |
3926 |
widthOfWidestLine notNil ifTrue:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3927 |
text do:[:line | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3928 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
3929 |
] |
2954 | 3930 |
]. |
3931 |
self textChanged. |
|
3932 |
||
3933 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
2952 | 3934 |
! |
3935 |
||
3936 |
mergeLine:lineNr removeBlanks:removeBlanks |
|
3937 |
"merge line lineNr with line lineNr+1" |
|
3938 |
||
3939 |
|len| |
|
3940 |
||
3583 | 3941 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3942 |
||
2952 | 3943 |
len := (self listAt:lineNr) size. |
3944 |
self nonUndoableDo:[ |
|
3542 | 3945 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
2952 | 3946 |
]. |
3947 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3948 |
! |
|
3949 |
||
3950 |
replace:aCharacter atLine:lineNr col:colNr |
|
3951 |
"replace a single character at lineNr/colNr" |
|
3952 |
||
3953 |
|originalChar| |
|
3954 |
||
3955 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3956 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3235 | 3957 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
2952 | 3958 |
! |
3959 |
||
3131 | 3960 |
replaceContentsWith:newContents |
3961 |
"replace everything" |
|
3962 |
||
3963 |
|originalContents| |
|
3964 |
||
3965 |
originalContents := self contents. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
3966 |
self contents:newContents keepUndoHistory:true. |
3131 | 3967 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
3968 |
! |
|
3969 |
||
3130 | 3970 |
replaceLine:lineNr with:newText |
3971 |
"replace a line at lineNr" |
|
3972 |
||
3973 |
|originalLine| |
|
3974 |
||
3975 |
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
|
3976 |
originalLine isNil ifTrue:[ |
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3977 |
self checkForExistingLine:lineNr |
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3978 |
]. |
3130 | 3979 |
self list at:lineNr put:newText. |
3980 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3981 |
self invalidateLine:lineNr. |
|
3479
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3982 |
|
5f9c6ff4fe6d
care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents:
3476
diff
changeset
|
3983 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
3130 | 3984 |
! |
3985 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3986 |
replaceString:aString atLine:lineNr col:colNr |
1557 | 3987 |
"replace multiple characters starting at lineNr/colNr. |
3235 | 3988 |
This is not prepared to encounter special chars (except TAB) in the string." |
3989 |
||
3990 |
|originalString| |
|
1557 | 3991 |
|
3992 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3993 |
||
3235 | 3994 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
3995 |
||
3996 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3997 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
1557 | 3998 |
! |
3999 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4000 |
splitLine:lineNr before:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4001 |
"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
|
4002 |
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
|
4003 |
|
2952 | 4004 |
self basicSplitLine:lineNr before:colNr. |
3115 | 4005 |
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
|
4006 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4007 |
|
3130 | 4008 |
withoutRedrawAt:lineNr put:aString |
4009 |
"replace a line at lineNr" |
|
4010 |
||
4011 |
|originalLine| |
|
4012 |
||
4013 |
originalLine := self listAt:lineNr. |
|
4014 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4015 |
super withoutRedrawAt:lineNr put:aString. |
|
4016 |
! |
|
4017 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4018 |
withoutRedrawInsertLine:aString before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4019 |
"insert the argument, aString before line lineNr; the string |
2954 | 4020 |
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
|
4021 |
is not redrawn" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4022 |
|
2952 | 4023 |
self basicWithoutRedrawInsertLine:aString before:lineNr. |
3115 | 4024 |
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
|
4025 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4027 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4028 |
"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
|
4029 |
|
2954 | 4030 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4031 |
self isReadOnly ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4032 |
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
|
4033 |
]. |
121 | 4034 |
! |
4035 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4036 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4037 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4038 |
|
2954 | 4039 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
3115 | 4040 |
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
|
4041 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4042 |
|
2752 | 4043 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4044 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4045 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4046 |
"hide the cursor when button is activated" |
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 |
hasKeyboardFocus := true. |
2589 | 4049 |
dragIsActive := false. |
4050 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4051 |
cursorShown ifTrue: [ |
3160 | 4052 |
self drawCursor |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4053 |
]. |
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 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 4056 |
self hideCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4057 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4058 |
(button == #paste) ifTrue:[ |
3160 | 4059 |
self pasteOrReplace. |
4060 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4061 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4062 |
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
|
4063 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4064 |
"Modified: / 23.3.1999 / 13:51:40 / cg" |
121 | 4065 |
! |
4066 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4067 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4068 |
"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
|
4069 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4070 |
((button == 1) or:[button == #select]) ifTrue:[ |
3160 | 4071 |
typeOfSelection := nil. |
4072 |
||
4073 |
dragIsActive ifTrue:[ |
|
4074 |
self unselect |
|
4075 |
]. |
|
4076 |
selectionStartLine isNil ifTrue:[ |
|
4077 |
clickCol notNil ifTrue:[ |
|
4078 |
self cursorMovementAllowed ifTrue:[ |
|
4079 |
self cursorLine:clickLine col:clickCol |
|
4080 |
] |
|
4081 |
] |
|
4082 |
] ifFalse:[ |
|
4083 |
lastString := nil. "new selection invalidates remembered string" |
|
4084 |
]. |
|
4085 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4086 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4087 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4088 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4089 |
"Modified: / 18.6.1998 / 14:14:05 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4090 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4091 |
|
2580 | 4092 |
cursorKeyPress:key shifted:shifted |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4093 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4094 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4095 |
self changeTypeOfSelectionTo:nil. |
2580 | 4096 |
|
4097 |
(key == #CursorRight) ifTrue:[ |
|
3232 | 4098 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4099 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
4100 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
4101 |
expandingTop := false. |
|
4102 |
self validateNewSelection. |
|
4103 |
self redrawLine:selectionStartLine. |
|
4104 |
^ self. |
|
4105 |
]. |
|
4106 |
||
4107 |
selectionStartLine notNil ifTrue:[ |
|
4108 |
self cursorMovementAllowed ifTrue:[ |
|
4109 |
"/ |
|
4110 |
"/ treat the whole selection as cursor |
|
4111 |
"/ |
|
3303 | 4112 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 4113 |
selectionEndCol == 0 ifTrue:[ |
4114 |
selectionEndCol := 1. |
|
4115 |
]. |
|
4116 |
self setCursorCol:selectionEndCol. |
|
4117 |
shifted ifTrue:[ |
|
4118 |
self expandSelectionRight. |
|
4119 |
^ self |
|
4120 |
]. |
|
4121 |
self unselect; makeCursorVisible. |
|
4122 |
cursorCol == 1 ifTrue:[^ self]. |
|
4123 |
]. |
|
4124 |
]. |
|
4125 |
self cursorRight. |
|
4126 |
^ self |
|
2580 | 4127 |
]. |
4128 |
(key == #CursorDown) ifTrue:[ |
|
3232 | 4129 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4130 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
4131 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
4132 |
selectionEndCol == 1 ifTrue:[ |
|
4133 |
selectionEndCol := 0. |
|
4134 |
]. |
|
4135 |
self validateNewSelection. |
|
4136 |
self redrawLine:selectionStartLine. |
|
4137 |
expandingTop := false. |
|
4138 |
self redrawLine:selectionEndLine. |
|
4139 |
^ self |
|
4140 |
]. |
|
4141 |
||
4142 |
selectionStartLine notNil ifTrue:[ |
|
4143 |
self cursorMovementAllowed ifTrue:[ |
|
4144 |
"/ |
|
4145 |
"/ treat the whole selection as cursor |
|
4146 |
"/ |
|
3303 | 4147 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3232 | 4148 |
self setCursorCol:selectionStartCol. |
4149 |
cursorCol == 0 ifTrue:[ |
|
4150 |
self setCursorCol:1. |
|
4151 |
self setCursorLine:(cursorLine - 1). |
|
4152 |
]. |
|
4153 |
self makeCursorVisible. |
|
4154 |
||
4155 |
shifted ifTrue:[ |
|
4156 |
clickLine := cursorLine. |
|
4157 |
clickCol := cursorCol. |
|
4158 |
self expandSelectionDown. |
|
4159 |
^ self |
|
4160 |
]. |
|
4161 |
self unselect. |
|
4162 |
]. |
|
4163 |
]. |
|
4164 |
||
4165 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
4166 |
self cursorDown:n. |
|
4167 |
"/ |
|
4168 |
"/ flush keyboard to avoid runaway cursor |
|
4169 |
"/ |
|
4170 |
self sensor flushKeyboardFor:self. |
|
4171 |
^ self |
|
2580 | 4172 |
]. |
4173 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
3232 | 4174 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
4175 |
expandingTop := true. |
|
4176 |
key == #CursorLeft ifTrue:[ |
|
4177 |
cursorCol > 1 ifTrue:[ |
|
4178 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
4179 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
4180 |
selectionStartCol := cursorCol-1. |
|
4181 |
self validateNewSelection. |
|
4182 |
self redrawLine:selectionStartLine. |
|
4183 |
^ self |
|
4184 |
] |
|
4185 |
] ifFalse:[ |
|
4186 |
cursorLine > 1 ifTrue:[ |
|
4187 |
selectionEndLine := clickStartLine := cursorLine. |
|
4188 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
4189 |
selectionStartLine := cursorLine - 1. |
|
4190 |
selectionEndCol == 1 ifTrue:[ |
|
4191 |
selectionEndCol := 0. |
|
4192 |
]. |
|
4193 |
self validateNewSelection. |
|
4194 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
4195 |
^ self |
|
4196 |
] |
|
4197 |
] |
|
4198 |
]. |
|
4199 |
||
4200 |
selectionStartLine notNil ifTrue:[ |
|
4201 |
self cursorMovementAllowed ifTrue:[ |
|
4202 |
"/ |
|
4203 |
"/ treat the whole selection as cursor |
|
4204 |
"/ |
|
4205 |
self setCursorLine:selectionStartLine. |
|
4206 |
self setCursorCol:selectionStartCol. |
|
4207 |
(key == #CursorLeft) ifTrue:[ |
|
4208 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
4209 |
]. |
|
4210 |
self makeCursorVisible. |
|
4211 |
||
4212 |
shifted ifTrue:[ |
|
4213 |
(key == #CursorUp) ifTrue:[ |
|
4214 |
clickLine := cursorLine. |
|
4215 |
self expandSelectionUp. |
|
4216 |
] ifFalse:[ |
|
4217 |
self expandSelectionLeft. |
|
4218 |
]. |
|
4219 |
^ self |
|
4220 |
]. |
|
4221 |
self unselect. |
|
4222 |
]. |
|
4223 |
]. |
|
4224 |
(key == #CursorLeft) ifTrue:[ |
|
4225 |
self cursorLeft. ^self |
|
4226 |
]. |
|
4227 |
(key == #CursorUp) ifTrue:[ |
|
4228 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
4229 |
self cursorUp:n. |
|
4230 |
"/ |
|
4231 |
"/ flush keyboard to avoid runaway cursor |
|
4232 |
"/ |
|
4233 |
self sensor flushKeyboardFor:self. |
|
4234 |
^ self |
|
4235 |
]. |
|
2580 | 4236 |
]. |
4237 |
! |
|
4238 |
||
2952 | 4239 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4240 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4241 |
|
2978 | 4242 |
<resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept |
3235 | 4243 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
3542 | 4244 |
#SelectWord #DeleteSpaces #Join |
3235 | 4245 |
#SearchMatchingParent #SelectMatchingParents |
4246 |
#SelectToEnd #SelectFromBeginning |
|
4247 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
4248 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4249 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4250 |
#GotoLine #BeginOfText #EndOfText |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4251 |
#SelectLine #ExpandSelectionByLine |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4252 |
#InsertLine #DeleteLine |
3235 | 4253 |
#SelectLineFromBeginning |
4254 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
4255 |
#'F*' #'f*')> |
|
2017 | 4256 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4257 |
|fKeyMacros shiftPressed ctrlPressed i event cmdMacro| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4258 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4259 |
event := WindowGroup lastEventQuerySignal query. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4260 |
shiftPressed := event hasShift. |
3024 | 4261 |
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
|
4262 |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4263 |
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
|
4264 |
cmdMacro notNil ifTrue:[ |
3235 | 4265 |
self |
4266 |
undoableDo: |
|
4267 |
[ self executeKeyboardMacro:cmdMacro ] |
|
4268 |
info: key. |
|
4269 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4270 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4271 |
|
3257 | 4272 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3235 | 4273 |
selectionStartLine notNil ifTrue:[ |
3326 | 4274 |
((key == #BasicBackspace) |
4275 |
or:[ UserPreferences current deleteSetsClipboardText not ]) |
|
4276 |
ifTrue:[ |
|
3235 | 4277 |
self deleteSelection. |
4278 |
] ifFalse: [ |
|
4279 |
self copyAndDeleteSelection. |
|
4280 |
]. |
|
4281 |
^ self |
|
4282 |
]. |
|
4283 |
||
4284 |
self makeCursorVisible. |
|
4285 |
shiftPressed ifTrue:[ |
|
4286 |
self deleteWordBeforeCursor. |
|
4287 |
] ifFalse:[ |
|
4288 |
self deleteCharBeforeCursor. |
|
4289 |
]. |
|
4290 |
||
4291 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4292 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4293 |
|
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4294 |
(key == #LearnKeyboardMacro) ifTrue:[ |
3235 | 4295 |
self toggleLearnMode. |
4296 |
^ self |
|
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 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
3235 | 4299 |
self executeLearnedKeyboardMacro. |
4300 |
^ self. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4301 |
]. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4302 |
self learnMode ifTrue:[ |
3235 | 4303 |
learnedMacro add:event. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4304 |
]. |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4305 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4306 |
(key isMemberOf:Character) ifTrue:[ |
3235 | 4307 |
self handleNonCommandKey:key. |
4308 |
^ self |
|
4309 |
]. |
|
4310 |
||
4311 |
key == #ToggleInsertMode ifTrue:[ |
|
4312 |
editMode value == EditMode insertMode ifTrue:[ |
|
4313 |
editMode value:(EditMode overwriteMode). |
|
4314 |
^ self. |
|
4315 |
]. |
|
4316 |
editMode value == EditMode overwriteMode ifTrue:[ |
|
4317 |
editMode value:(EditMode insertAndSelectMode). |
|
4318 |
^ self. |
|
4319 |
]. |
|
4320 |
editMode value == EditMode insertAndSelectMode ifTrue:[ |
|
4321 |
editMode value:(EditMode insertMode). |
|
4322 |
^ self. |
|
4323 |
]. |
|
4324 |
^ self. |
|
3160 | 4325 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4326 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4327 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4328 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4329 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4330 |
Fn pastes a key-sequence (but only if not overlayed with |
3235 | 4331 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4332 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4333 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4334 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4335 |
(key at:1) asLowercase == $f ifTrue:[ |
3235 | 4336 |
(('[fF][0-9]' match:key) |
4337 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4338 |
shiftPressed ifFalse:[ |
|
4339 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
4340 |
fKeyMacros notNil ifTrue:[ |
|
4341 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4342 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4343 |
^ self |
|
4344 |
] |
|
4345 |
] |
|
4346 |
] |
|
4347 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4348 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4349 |
|
2506 | 4350 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3235 | 4351 |
self parenthizeSelectionWith:$( and:$). |
4352 |
^ self. |
|
2506 | 4353 |
]. |
4354 |
(key == #'Ctrl2') ifTrue:[ |
|
3235 | 4355 |
self parenthizeSelectionWith:$" and:$". |
4356 |
^ self. |
|
2506 | 4357 |
]. |
4358 |
(key == #'Ctrl#') ifTrue:[ |
|
3235 | 4359 |
self parenthizeSelectionWith:$' and:$'. |
4360 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4361 |
]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4362 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4363 |
(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
|
4364 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4365 |
((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4366 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4367 |
(key == #Again) ifTrue:[self again. ^self]. |
2978 | 4368 |
(key == #Undo) ifTrue:[self undo. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4369 |
|
3542 | 4370 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4371 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4372 |
(key == #SelectWord) ifTrue:[ |
3235 | 4373 |
self makeCursorVisible. |
4374 |
self selectWordUnderCursor. |
|
4375 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4376 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4377 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4378 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4379 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4380 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4381 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4383 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4384 |
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
|
4385 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
4386 |
(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
|
4387 |
(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
|
4388 |
(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
|
4389 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4390 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4391 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4392 |
(key == #BeginOfLine) ifTrue:[ |
3235 | 4393 |
shiftPressed ifTrue: [ |
4394 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4395 |
"/ self unselect. |
|
4396 |
"/ self cursorHome. |
|
4397 |
"Jan's modification" |
|
4398 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
4399 |
] ifFalse: [ |
|
4400 |
self unselect. |
|
4401 |
ctrlPressed ifTrue:[ |
|
4402 |
self cursorHome. |
|
4403 |
] ifFalse:[ |
|
4404 |
self cursorToBeginOfLine. |
|
4405 |
] |
|
4406 |
]. |
|
4407 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4408 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4409 |
(key == #EndOfLine) ifTrue:[ |
3235 | 4410 |
shiftPressed ifTrue:[ |
4411 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4412 |
"/ self unselect. |
|
4413 |
"/ self cursorToBottom |
|
4414 |
"Jan's modification" |
|
4415 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
4416 |
] ifFalse:[ |
|
4417 |
self unselect. |
|
4418 |
ctrlPressed ifTrue:[ |
|
4419 |
self cursorToBottom |
|
4420 |
] ifFalse:[ |
|
4421 |
self cursorToEndOfLine. |
|
4422 |
] |
|
4423 |
]. |
|
4424 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4425 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4426 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 4427 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 4428 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4429 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4430 |
|
2580 | 4431 |
(key == #CursorRight |
4432 |
or:[key == #CursorDown |
|
4433 |
or:[key == #CursorLeft |
|
4434 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3235 | 4435 |
self cursorKeyPress:key shifted:shiftPressed. |
4436 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4437 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4438 |
|
3257 | 4439 |
(key == #NonInsertingReturn) ifTrue:[ |
4440 |
self unselect. self cursorReturn. |
|
4441 |
^ self |
|
4442 |
]. |
|
4443 |
||
4444 |
(key == #Return) ifTrue:[ |
|
3235 | 4445 |
shiftPressed ifTrue:[ |
4446 |
self unselect. self cursorReturn. |
|
4447 |
^ self |
|
4448 |
]. |
|
4449 |
self isReadOnly ifTrue:[ |
|
4450 |
self unselect; makeCursorVisible. |
|
4451 |
self cursorReturn |
|
4452 |
] ifFalse:[ |
|
4453 |
self isInInsertMode ifFalse:[ |
|
4454 |
self cursorReturn. |
|
4455 |
autoIndent == true ifTrue:[ |
|
4456 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4457 |
self cursorCol:(i+1 max:1) |
|
4458 |
] |
|
4459 |
] ifTrue:[ |
|
4460 |
"/ old version just unselected ... |
|
4461 |
"/ self unselect; makeCursorVisible. |
|
4462 |
||
4463 |
"/ new version deletes ... |
|
4464 |
typeOfSelection == #paste ifTrue:[ |
|
4465 |
self unselect; makeCursorVisible. |
|
4466 |
] ifFalse:[ |
|
4467 |
self copyAndDeleteSelection. |
|
4468 |
]. |
|
4469 |
self insertCharAtCursor:(Character cr). |
|
4470 |
autoIndent == true ifTrue:[ |
|
4471 |
i := self leftIndentForLine:cursorLine. |
|
4472 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
4473 |
self cursorCol:(i+1 max:1) |
|
4474 |
]. |
|
4475 |
]. |
|
4476 |
]. |
|
4477 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4478 |
]. |
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
|
4479 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4480 |
(key == #NonInsertingTab) ifTrue:[ |
3235 | 4481 |
self unselect. self cursorTab. |
4482 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
4483 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4484 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3235 | 4485 |
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
|
4486 |
|
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4487 |
self hasSelection ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4488 |
selectStyle == #line ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4489 |
fKeyMacros := UserPreferences current functionKeySequences. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4490 |
fKeyMacros notNil ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4491 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4492 |
cmdMacro := fKeyMacros at:#IndentBy4 ifAbsent:nil. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4493 |
] ifFalse:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4494 |
cmdMacro := fKeyMacros at:#UndentBy4 ifAbsent:nil. |
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 |
cmdMacro notNil ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4497 |
self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4498 |
undoableDo: |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4499 |
[ self executeKeyboardMacro:cmdMacro ] |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4500 |
info:'IndentBy4'. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4501 |
^ self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4502 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4503 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4504 |
] |
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 |
|
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4507 |
self unselect. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4508 |
(key == #Tab) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4509 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4510 |
self cursorTab. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4511 |
^ self |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4512 |
]. |
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4513 |
self insertTabAtCursor. |
3257 | 4514 |
^ self |
3235 | 4515 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
4516 |
self cursorBacktab. |
3235 | 4517 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4518 |
]. |
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
|
4519 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4520 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4521 |
(key == #Delete) ifTrue:[ |
3235 | 4522 |
shiftPressed ifTrue:[ |
4523 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
4524 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4525 |
self makeCursorVisible. |
3235 | 4526 |
self deleteCharAtCursor. |
4527 |
]. |
|
4528 |
^ self |
|
4529 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4530 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
4531 |
|
870 | 4532 |
(key == #Delete |
4533 |
or:[key == #BasicDelete]) ifTrue:[ |
|
3235 | 4534 |
selectionStartLine notNil ifTrue:[ |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4535 |
((key == #BasicDelete) |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
4536 |
or:[UserPreferences current deleteSetsClipboardText not]) ifTrue:[ |
3235 | 4537 |
self deleteSelection. |
4538 |
] ifFalse:[ |
|
4539 |
self copyAndDeleteSelection. |
|
4540 |
]. |
|
4541 |
^ self |
|
4542 |
]. |
|
4543 |
self makeCursorVisible. |
|
4544 |
self deleteCharAtCursor. |
|
4545 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4546 |
]. |
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
|
4547 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4548 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3235 | 4549 |
self unselect. |
4550 |
cursorVisibleLine == 1 ifTrue:[ |
|
4551 |
self cursorHome. |
|
4552 |
] ifFalse:[ |
|
4553 |
self cursorToFirstVisibleLine |
|
4554 |
]. |
|
4555 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4556 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4557 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3235 | 4558 |
self unselect. |
4559 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
4560 |
self cursorToBottom. |
|
4561 |
] ifFalse:[ |
|
4562 |
self cursorToLastVisibleLine |
|
4563 |
]. |
|
4564 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4565 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4566 |
((key == #Escape) |
3257 | 4567 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3235 | 4568 |
self makeCursorVisible. |
4569 |
self unselect. self selectCursorLineFromBeginning. |
|
4570 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4571 |
]. |
3257 | 4572 |
(key == #SelectLine) ifTrue:[ |
3235 | 4573 |
self makeCursorVisible. |
4574 |
self unselect. self selectCursorLine. |
|
4575 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4576 |
]. |
3257 | 4577 |
(key == #ExpandSelectionByLine) ifTrue:[ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4578 |
"/ self makeCursorVisible. |
3235 | 4579 |
self selectExpandCursorLine. |
4580 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4581 |
]. |
3257 | 4582 |
(key == #DeleteLine) ifTrue:[ |
3235 | 4583 |
self makeCursorVisible. |
4584 |
self unselect. self deleteCursorLine. |
|
4585 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4586 |
]. |
3257 | 4587 |
(key == #InsertLine) ifTrue:[ |
3235 | 4588 |
self makeCursorVisible. |
4589 |
self unselect. self insertLine:nil before:cursorLine. |
|
4590 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4591 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4592 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4593 |
|
3310 | 4594 |
"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
|
4595 |
"Modified: / 28-10-2006 / 15:37:47 / cg" |
121 | 4596 |
! |
4597 |
||
2952 | 4598 |
executeKeyboardMacro:cmdMacro |
4599 |
Error handle:[:ex | |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4600 |
self warn:'Error in keyboard macro: ' , ex description. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4601 |
ex return. |
2952 | 4602 |
] do:[ |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4603 |
AbortOperationRequest handle:[:ex | |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4604 |
self warn:'Keyboard macro aborted'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4605 |
ex return. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4606 |
] do:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4607 |
Parser |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4608 |
evaluate:cmdMacro asString |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4609 |
receiver:self |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4610 |
notifying:nil |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4611 |
compile:false. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4612 |
]. |
2952 | 4613 |
]. |
4614 |
! |
|
4615 |
||
4616 |
handleNonCommandKey:keyArg |
|
4617 |
|selStartLine selStartCol selEndLine selEndCol sel key| |
|
4618 |
||
4619 |
self isReadOnly ifTrue:[ |
|
3235 | 4620 |
self flash. |
4621 |
^ self. |
|
2952 | 4622 |
]. |
4623 |
||
4624 |
key := keyArg. |
|
4625 |
||
4626 |
typeOfSelection == #paste ifTrue:[ |
|
3235 | 4627 |
"pasted selection will NOT be replaced by keystroke" |
4628 |
self unselect |
|
2952 | 4629 |
]. |
4630 |
||
4631 |
selStartLine := selectionStartLine. |
|
4632 |
selStartCol := self selectionStartCol. |
|
4633 |
selEndLine := selectionEndLine. |
|
4634 |
selEndCol := self selectionEndCol. |
|
4635 |
sel := self selection. |
|
4636 |
||
4637 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
|
3235 | 4638 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
2952 | 4639 |
]. |
4640 |
||
4641 |
"replace selection by what is typed in - |
|
3235 | 4642 |
if word was selected with a space, keep it. |
4643 |
if there was no selection, the keys character is inserted" |
|
4644 |
||
4645 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4646 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
|
4647 |
]. |
|
2952 | 4648 |
|
4649 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3235 | 4650 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 4651 |
] ifFalse:[ |
3235 | 4652 |
(selectStyle == #wordRight) ifTrue:[ |
4653 |
self replaceSelectionBy:(key asString , ' '). |
|
4654 |
self cursorLeft |
|
4655 |
] ifFalse:[ |
|
4656 |
self replaceSelectionBy:key |
|
4657 |
] |
|
3160 | 4658 |
]. |
2952 | 4659 |
selectStyle := nil. |
4660 |
||
3235 | 4661 |
editMode value isInsertAndSelectMode ifTrue:[ |
4662 |
selectionStartLine := selStartLine. |
|
4663 |
selectionStartCol := selStartCol. |
|
4664 |
selectionEndLine := selEndLine. |
|
4665 |
selectionEndCol := selEndCol. |
|
4666 |
]. |
|
4667 |
||
2952 | 4668 |
showMatchingParenthesis ifTrue:[ |
3235 | 4669 |
"emacs style parenthesis shower" |
4670 |
||
4671 |
"claus: only do it for closing parenthesis - |
|
4672 |
otherwise its too anoying. |
|
4673 |
" |
|
2952 | 4674 |
" |
3235 | 4675 |
(#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[ |
2952 | 4676 |
" |
3235 | 4677 |
(#( $) $] $} ) includes:key) ifTrue:[ |
4678 |
self |
|
4679 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
4680 |
ifFound:[:line :col | |
|
4681 |
|savLine savCol sensor| |
|
4682 |
||
4683 |
self withCursor:Cursor eye do:[ |
|
4684 |
savLine := cursorLine. |
|
4685 |
savCol := cursorCol. |
|
4686 |
self cursorLine:line col:col. |
|
4687 |
device flush. |
|
4688 |
||
4689 |
"/ want to wait 200ms, but not if another keyPress |
|
4690 |
"/ arrives in the meantime ... |
|
4691 |
||
4692 |
sensor := self sensor. |
|
4693 |
5 timesRepeat:[ |
|
4694 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
4695 |
Processor activeProcess millisecondDelay:40. |
|
4696 |
] |
|
4697 |
]. |
|
4698 |
self cursorLine:savLine col:savCol |
|
4699 |
] |
|
4700 |
] |
|
4701 |
ifNotFound:[self showNotFound] |
|
4702 |
onError:[self beep] |
|
4703 |
]. |
|
2952 | 4704 |
]. |
4705 |
||
4706 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
4707 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
4708 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
4709 |
"/ |
|
4710 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4711 |
"/ self selection. |
|
4712 |
"/ typeOfSelection := #paste. |
|
3160 | 4713 |
"/ ]. |
3235 | 4714 |
"/ ]. |
4715 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
4716 |
selectionStartLine isNil ifTrue:[ |
|
4717 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
4718 |
] ifFalse:[ |
|
4719 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
4720 |
]. |
|
4721 |
]. |
|
2952 | 4722 |
! |
4723 |
||
4724 |
keyPress:key x:x y:y |
|
4725 |
"handle keyboard input" |
|
4726 |
||
4727 |
self undoableDo:[ |
|
3160 | 4728 |
self doKeyPress:key x:x y:y |
2952 | 4729 |
]. |
4730 |
! |
|
4731 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4732 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4733 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4734 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4735 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4736 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4737 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4738 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4739 |
requestAutoAccept |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4740 |
"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
|
4741 |
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
|
4742 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4743 |
acceptEnabled == false ifTrue:[ |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4744 |
"/ nope - |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4745 |
^ false |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4746 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4747 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4748 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4749 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
4750 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4751 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4752 |
"make certain, cursor is visible after the sizechange" |
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 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4755 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4756 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4757 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4758 |
cv notNil ifTrue:[ |
3160 | 4759 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4760 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4761 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4762 |
|
1807 | 4763 |
!EditTextView methodsFor:'focus handling'! |
4764 |
||
4765 |
hasKeyboardFocus:aBoolean |
|
4766 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
4767 |
(otherwise, I would not know about this)" |
|
4768 |
||
4769 |
hasKeyboardFocus := aBoolean. |
|
3160 | 4770 |
(cursorShown |
4771 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4772 |
and:[self isReadOnly not]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4773 |
self drawCursor |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4774 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4775 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
4776 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 4777 |
! |
4778 |
||
4779 |
showFocus:explicit |
|
4780 |
"in addition to however my superclass thinks how a focusView is to be |
|
4781 |
displayed, show the cursor when I got the focus" |
|
4782 |
||
4783 |
self showCursor. |
|
4784 |
self hasKeyboardFocus:true. |
|
4785 |
super showFocus:explicit |
|
4786 |
||
4787 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4788 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4789 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4790 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4791 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4792 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4793 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4794 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4795 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4796 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4797 |
and:[self isReadOnly not]]]) ifTrue:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4798 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4799 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4800 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
4801 |
^ false |
1807 | 4802 |
! ! |
4803 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4804 |
!EditTextView methodsFor:'formatting'! |
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 |
indent |
3221 | 4807 |
"indent a line-range - this is done by searching for the |
4808 |
last non-empty line before the selection, and changing the indent |
|
4809 |
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
|
4810 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4811 |
|start end| |
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 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 4814 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4815 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4816 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4817 |
(selectionEndCol == 0) ifTrue:[ |
3221 | 4818 |
end := end - 1 |
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 |
self unselect. |
3160 | 4821 |
self |
3221 | 4822 |
undoableDo:[ |
4823 |
self indentFromLine:start toLine:end |
|
4824 |
] |
|
4825 |
info:'indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4826 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4827 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4828 |
indentFromLine:start toLine:end |
3221 | 4829 |
"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
|
4830 |
last non-empty line before start, and change the indent |
3221 | 4831 |
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
|
4832 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4833 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4834 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4835 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4836 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4837 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4838 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4839 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4840 |
(delta > 0) ifTrue:[ |
3221 | 4841 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4842 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4843 |
start to:end do:[:lineNr | |
3221 | 4844 |
line := self listAt:lineNr. |
4845 |
line notNil ifTrue:[ |
|
4846 |
line isBlank ifTrue:[ |
|
4847 |
list at:lineNr put:nil |
|
4848 |
] ifFalse:[ |
|
4849 |
(delta > 0) ifTrue:[ |
|
4850 |
line := spaces , line. |
|
4851 |
widthOfWidestLine notNil ifTrue:[ |
|
4852 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4853 |
] |
|
4854 |
] ifFalse:[ |
|
4855 |
"check if deletion is ok" |
|
4856 |
d := delta negated + 1. |
|
4857 |
||
4858 |
line size > d ifTrue:[ |
|
4859 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
4860 |
line := line copyFrom:d |
|
4861 |
] |
|
4862 |
]. |
|
4863 |
widthOfWidestLine := nil |
|
4864 |
]. |
|
4865 |
self replaceLine:lineNr with:line. |
|
4866 |
self textChanged. |
|
4867 |
] |
|
4868 |
] |
|
4869 |
]. |
|
4870 |
"/ self redrawFromLine:start to:end |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4871 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4872 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4873 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4874 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4875 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4876 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4877 |
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
|
4878 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4879 |
|
827 | 4880 |
"SHOULD GO TO ListView" |
4881 |
||
4882 |
|line lnr indent| |
|
4883 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4884 |
lnr := lineNr. |
827 | 4885 |
|
4886 |
[lnr ~~ 1] whileTrue:[ |
|
3160 | 4887 |
lnr := lnr - 1. |
4888 |
line := self listAt:lnr. |
|
4889 |
||
4890 |
line notNil ifTrue:[ |
|
4891 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
4892 |
indent ~~ 0 ifTrue:[ |
|
4893 |
^ indent - 1 |
|
4894 |
] |
|
4895 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4896 |
]. |
827 | 4897 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4898 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4899 |
"Created: 5.3.1996 / 14:58:53 / cg" |
105 | 4900 |
! ! |
4901 |
||
0 | 4902 |
!EditTextView methodsFor:'initialization'! |
4903 |
||
941 | 4904 |
fetchDeviceResources |
4905 |
"fetch device colors, to avoid reallocation at redraw time" |
|
4906 |
||
4907 |
super fetchDeviceResources. |
|
4908 |
||
1993 | 4909 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
4910 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
4911 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 4912 |
|
4913 |
"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
|
4914 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 4915 |
! |
4916 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4917 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4918 |
"enable enter/leave events in addition" |
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 initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4921 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4922 |
! |
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 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4925 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4926 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4927 |
super initStyle. |
2088 | 4928 |
lineSpacing := 1. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4929 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4930 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4931 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4932 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4933 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4934 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 4935 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4936 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
3160 | 4937 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
4938 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4939 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4940 |
cursorNoFocusFgColor isNil ifTrue:[ |
3160 | 4941 |
cursorType ~~ #block ifTrue:[ |
4942 |
cursorNoFocusFgColor := cursorBgColor |
|
4943 |
] ifFalse:[ |
|
4944 |
cursorNoFocusFgColor := cursorFgColor |
|
4945 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4946 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
4947 |
|
2088 | 4948 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4951 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4952 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4953 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4954 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4955 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4956 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4957 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4958 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4959 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4960 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4961 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4962 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4963 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4964 |
cursorCol := 1. |
2815 | 4965 |
cursorLineHolder := 1 asValue. |
4966 |
cursorColHolder := 1 asValue. |
|
2119 | 4967 |
modifiedChannel := ValueHolder with:false. |
4968 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
4969 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4970 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4971 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4972 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
4973 |
autoIndent := false. |
3235 | 4974 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4975 |
learnMode := false asValue. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
4976 |
trimBlankLines := self st80EditMode not. |
2131 | 4977 |
cursorMovementWhenUpdating := #beginOfText. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
4978 |
|
3236 | 4979 |
"/ enable drop by default |
2589 | 4980 |
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
|
4981 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
4982 |
undoSupport := UndoSupport for:self. |
0 | 4983 |
! ! |
4984 |
||
2580 | 4985 |
!EditTextView methodsFor:'macros'! |
4986 |
||
4987 |
executeLearnedKeyboardMacro |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
4988 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3160 | 4989 |
learnedMacro do:[:event | |
4990 |
WindowGroup lastEventQuerySignal answer:event |
|
4991 |
do:[ |
|
4992 |
self |
|
4993 |
dispatchEvent:event |
|
4994 |
withFocusOn:nil |
|
4995 |
delegate:false |
|
4996 |
] |
|
4997 |
]. |
|
2580 | 4998 |
] ifFalse:[ |
3160 | 4999 |
self flash. |
2580 | 5000 |
]. |
5001 |
! |
|
5002 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5003 |
learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5004 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5005 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5006 |
|
2580 | 5007 |
learnMode:aBoolean |
5008 |
|fg bg| |
|
5009 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5010 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5011 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5012 |
aBoolean ifTrue:[ |
3160 | 5013 |
learnedMacro := OrderedCollection new. |
5014 |
fg := Color white. |
|
5015 |
bg := Color black. |
|
2580 | 5016 |
] ifFalse:[ |
3160 | 5017 |
cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor. |
5018 |
cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor. |
|
2580 | 5019 |
]. |
5020 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5021 |
! |
|
5022 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5023 |
learnModeHolder |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5024 |
learnMode isNil ifTrue:[ |
3160 | 5025 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5026 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5027 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5028 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5029 |
|
2580 | 5030 |
toggleLearnMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5031 |
self learnMode: self learnMode not. |
2580 | 5032 |
! ! |
5033 |
||
121 | 5034 |
!EditTextView methodsFor:'menu actions'! |
5035 |
||
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5036 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5037 |
"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
|
5038 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5039 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5040 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5041 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5042 |
original size == 0 ifTrue:[^ self]. |
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 |
self withWaitCursorDo:[ |
3495 | 5045 |
SOAP::SoapImplError handle:[:ex | |
5046 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
5047 |
] do:[ |
|
5048 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5049 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5050 |
]. |
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 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5053 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5054 |
self unselect. |
3495 | 5055 |
self undoablePaste:translated info:'translate' |
5056 |
||
5057 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5058 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5059 |
|
3517 | 5060 |
compareWithClipboard |
5061 |
"compare the selection against the clipboard contents" |
|
5062 |
||
5063 |
|t1 t2| |
|
5064 |
||
5065 |
t2 := self getClipboardText. |
|
5066 |
t2 isEmptyOrNil ifTrue:[ |
|
5067 |
Dialog information:'Clipboard is empty.'. |
|
5068 |
^ self. |
|
5069 |
]. |
|
5070 |
||
5071 |
self hasSelection ifTrue:[ |
|
5072 |
t1 := self selectionAsString. |
|
5073 |
] ifFalse:[ |
|
5074 |
t1 := self contents asString |
|
5075 |
]. |
|
5076 |
t1 := t1 string. |
|
5077 |
||
5078 |
t1 = t2 ifTrue:[ |
|
5079 |
Dialog information:'Strings are equal.'. |
|
5080 |
^ self. |
|
5081 |
]. |
|
5082 |
DiffTextView |
|
5083 |
openOn:t1 label:'Editor' |
|
5084 |
and:t2 label:'Clipboard' |
|
5085 |
! |
|
5086 |
||
121 | 5087 |
cut |
5088 |
"cut selection into copybuffer" |
|
5089 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5090 |
self deleteCopyToClipboard:true |
121 | 5091 |
! |
5092 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5093 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5094 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5095 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5096 |
cursorLine notNil ifTrue:[ |
3160 | 5097 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5098 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5099 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5100 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5101 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5102 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5103 |
"cut selection into copybuffer" |
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 |
|line col history sel s| |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5106 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5107 |
(self checkModificationsAllowed) ifFalse:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5108 |
self flash. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5109 |
^ self |
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 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5112 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5113 |
sel notNil ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5114 |
lastString := s := sel asStringWithCRs. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5115 |
line := selectionStartLine. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5116 |
col := selectionStartCol. |
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 |
toClipboard ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5119 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5120 |
remember in CopyBuffer |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5121 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5122 |
self setClipboardText:sel. "/ lastString. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5123 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5124 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5125 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5126 |
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
|
5127 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5128 |
history := Smalltalk at:#DeleteHistory. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5129 |
history notNil ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5130 |
history addAll:(sel asStringCollection). |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5131 |
history size > 1000 ifTrue:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5132 |
history := history copyFrom:(history size - 1000) |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5133 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5134 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5135 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5136 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5137 |
now, delete it |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5138 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5139 |
self undoableDo:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5140 |
self deleteSelection. |
3542 | 5141 |
] info:'Delete'. |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5142 |
lastReplacement := nil |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5143 |
] ifFalse:[ |
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 |
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
|
5146 |
" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5147 |
self undoableDo:[ |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5148 |
self again |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5149 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5150 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5151 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5152 |
"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
|
5153 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5154 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5155 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5156 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5157 |
|
3566 | 5158 |
<resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print |
5159 |
#PasteFromHistory #Join #Undo)> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
5160 |
<resource: #programMenu> |
1054 | 5161 |
|
3495 | 5162 |
|items m sub translateItems sortItems miscItems toolItems subSub toolSub |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5163 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 5164 |
|
2460 | 5165 |
items := #( |
3221 | 5166 |
('Redo' redo ) |
5167 |
('Again (for All)' multipleAgain ) |
|
5168 |
('-' ) |
|
5169 |
('Search...' search Find ) |
|
5170 |
('Goto Line...' gotoLine GotoLine ) |
|
5171 |
('-' ) |
|
5172 |
('Tools' tools ) |
|
5173 |
('-' ) |
|
5174 |
('Save As...' save SaveAs ) |
|
5175 |
('Print' doPrint Print ) |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5176 |
('=' ) |
3495 | 5177 |
('Misc' misc ShiftCtrl) |
3221 | 5178 |
). |
2460 | 5179 |
|
2866 | 5180 |
miscItems := #( |
3221 | 5181 |
('AutoIndent \c' autoIndent: ) |
5182 |
('InsertMode \c' insertMode: ) |
|
5183 |
('-' ) |
|
3572
eaccc27e1d0a
redraw bug when inserting a single bold character
Claus Gittinger <cg@exept.de>
parents:
3569
diff
changeset
|
5184 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
3550 | 5185 |
('Join Lines' joinLines Join ) |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5186 |
('-' ) |
3550 | 5187 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
3221 | 5188 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
5189 |
('-' ) |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5190 |
('Insert File...' insertFile ) |
3495 | 5191 |
('Insert new UUID' insertUUID ) |
3595 | 5192 |
('Insert Date && Time' insertDateAndTime ) |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5193 |
('-' ) |
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5194 |
). |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5195 |
CharacterSetView notNil ifTrue:[ |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5196 |
miscItems := miscItems , |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5197 |
#( |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5198 |
('Special Characters...' specialCharacters ) |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5199 |
). |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5200 |
]. |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5201 |
miscItems := miscItems , |
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5202 |
#( |
3223 | 5203 |
('Font...' changeFont ) |
2870 | 5204 |
"/ ('Encoding...' changeEncoding ) |
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5205 |
). |
2866 | 5206 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5207 |
translateItems := #( |
3221 | 5208 |
('English -> German' (babelFishTranslate: 'en_de') ) |
5209 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
5210 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
5211 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
5212 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
5213 |
('-' ) |
|
5214 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
5215 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
5216 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
5217 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
5218 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
5219 |
). |
|
5220 |
||
5221 |
sortItems := #( |
|
5222 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
|
5223 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
5224 |
('Lines by nth Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
5225 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
5226 |
('-' ) |
|
5227 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
5228 |
('Lines by First Word (ignore case)'(sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
5229 |
('Lines by nth Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
5230 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
5231 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5232 |
|
2762 | 5233 |
toolItems := #( |
3221 | 5234 |
('Indent' indent ) |
5235 |
('Sort' sort ) |
|
5236 |
('-' ) |
|
5237 |
('Google Spell' googleSpellingSuggestion ) |
|
5238 |
('Translate' babelFishTranslate ) |
|
3517 | 5239 |
('Compare with Clipboard...' compareWithClipboard ) |
3221 | 5240 |
). |
2762 | 5241 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5242 |
Smalltalk isStandAloneApp ifFalse:[ |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5243 |
toolItems := toolItems , #( |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5244 |
('-' ) |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5245 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5246 |
('Open Workspace with It' openWorkspaceWithIt ) |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5247 |
). |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5248 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5249 |
|
2460 | 5250 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 5251 |
sub receiver:self. |
2460 | 5252 |
|
2919 | 5253 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
5254 |
toolSub receiver:self. |
|
5255 |
sub subMenuAt:#tools put:toolSub. |
|
5256 |
||
3495 | 5257 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
5258 |
transSub receiver:self. |
|
5259 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
5260 |
||
5261 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
5262 |
sortSub receiver:self. |
|
5263 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 5264 |
|
2866 | 5265 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
5266 |
subSub receiver:self. |
|
2952 | 5267 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 5268 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 5269 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
2866 | 5270 |
sub subMenuAt:#misc put:subSub. |
5271 |
||
3495 | 5272 |
mainItems := #( |
5273 |
('Undo' undo Undo ) |
|
5274 |
('Again' again Again ) |
|
5275 |
('-' ) |
|
5276 |
('Cut' cut Cut ) |
|
5277 |
('Copy' copySelection Copy ) |
|
5278 |
('Paste' pasteOrReplace Paste ) |
|
5279 |
('-' ) |
|
5280 |
('Accept' accept Accept ) |
|
5281 |
('=' ) |
|
5282 |
('More' others Ctrl ) |
|
5283 |
). |
|
5284 |
main := PopUpMenu itemList:mainItems resources:resources. |
|
5285 |
main subMenuAt:#others put:sub. |
|
5286 |
||
5287 |
sensor := self sensor. |
|
5288 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
5289 |
sensor shiftDown ifTrue:[ |
|
5290 |
m := subSub |
|
5291 |
] ifFalse:[ |
|
5292 |
m := sub |
|
5293 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5294 |
] ifFalse:[ |
3495 | 5295 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5296 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5297 |
|
2676 | 5298 |
SOAP::GoogleClient isNil ifTrue:[ |
3221 | 5299 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
5300 |
m disable:#googleSpellingSuggestion |
|
2676 | 5301 |
]. |
5302 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5303 |
self isReadOnly ifTrue:[ |
3583 | 5304 |
m disableAll:#(undo again multipleAgain redo |
5305 |
paste pasteOrReplace pasteOrReplaceFromHistory |
|
5306 |
cut indent autoIndent: insertMode: |
|
5307 |
insertFile babelFishTranslate googleSpellingSuggestion sort |
|
3595 | 5308 |
joinLines insertUUID insertDateAndTime |
3583 | 5309 |
specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5310 |
]. |
2817 | 5311 |
self hasSelectionForCopy ifFalse:[ |
3221 | 5312 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5313 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5314 |
self hasSelection ifFalse:[ |
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5315 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt openWorkspaceWithIt sort indent). |
2762 | 5316 |
] ifTrue:[ |
3221 | 5317 |
(Error handle:[:ex | |
5318 |
ex return:false |
|
5319 |
] do:[ |
|
5320 |
self selectionAsString asSingleByteString asFilename exists |
|
5321 |
]) ifFalse:[ |
|
5322 |
m disableAll:#(openFileBrowserOnIt). |
|
5323 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5324 |
]. |
2569 | 5325 |
self hasUndoAction ifFalse:[ |
3221 | 5326 |
m disable:#undo. |
3115 | 5327 |
] ifTrue:[ |
3221 | 5328 |
what := undoSupport undoActionInfo. |
5329 |
what notNil ifTrue:[ |
|
5330 |
undoIdx := m indexOf:#undo. |
|
5331 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
5332 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
5333 |
]. |
2952 | 5334 |
self hasRedoAction ifFalse:[ |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5335 |
sub disable:#redo. |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5336 |
] ifTrue:[ |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5337 |
what := undoSupport redoActionInfo. |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5338 |
what notNil ifTrue:[ |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5339 |
redoIdx := sub indexOf:#redo. |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5340 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
5341 |
] |
2952 | 5342 |
]. |
1108 | 5343 |
acceptEnabled == false ifTrue:[ |
3221 | 5344 |
m disable:#accept |
1108 | 5345 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5346 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5347 |
|
3495 | 5348 |
"Modified: / 28-07-2007 / 13:15:38 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5349 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5350 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5351 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5352 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5353 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5354 |
history := device getCopyBufferHistory copy. |
3160 | 5355 |
list := history collect:[:entry | |
3473 | 5356 |
|text shown| |
5357 |
||
5358 |
text := entry asString string asCollectionOfLines. |
|
5359 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
5360 |
text size > 1 ifTrue:[ |
|
5361 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
|
5362 |
]. |
|
5363 |
shown |
|
5364 |
]. |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5365 |
box := ListSelectionBox |
3583 | 5366 |
title:(resources string:'Clipboard History') |
5367 |
okText:(resources string:'Paste') |
|
5368 |
abortText:(resources string:'Cancel') |
|
3473 | 5369 |
list:list |
5370 |
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
|
5371 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5372 |
box show. |
3160 | 5373 |
^ sel. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5374 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5375 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5376 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5377 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5378 |
self sensor shiftDown ifTrue:[ |
3160 | 5379 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5380 |
]. |
2724 | 5381 |
|
5382 |
"/ return either the (xterm-) selection or the clipBoard |
|
3160 | 5383 |
^ self |
5384 |
getClipboardText:(self sensor ctrlDown |
|
5385 |
ifTrue:#selection |
|
5386 |
ifFalse:#clipboard) |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5387 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
5388 |
|
2676 | 5389 |
googleSpellingSuggestion |
5390 |
"insert the google-spelling suggestion for the selected text. |
|
5391 |
Requires that the SOAP stuff is loaded and working." |
|
5392 |
||
2677 | 5393 |
|text suggestion| |
2676 | 5394 |
|
5395 |
self withWaitCursorDo:[ |
|
3495 | 5396 |
text := self selection asString string withoutSeparators. |
5397 |
text size == 0 ifTrue:[^ self]. |
|
5398 |
||
5399 |
SOAP::SoapImplError handle:[:ex | |
|
5400 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
5401 |
^ self. |
|
5402 |
] do:[ |
|
5403 |
suggestion := SOAP::GoogleClient new spellingSuggestionOf:text. |
|
5404 |
]. |
|
5405 |
suggestion size == 0 ifTrue:[ |
|
5406 |
Transcript showCR:'No SpellingSuggestion from Google for: ' , text. |
|
5407 |
^ self. |
|
5408 |
]. |
|
5409 |
]. |
|
5410 |
self undoablePaste:suggestion info:'spelling suggestion'. |
|
5411 |
||
5412 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 5413 |
! |
5414 |
||
3595 | 5415 |
insertDateAndTime |
5416 |
"insert the curent date and time string" |
|
5417 |
||
5418 |
typeOfSelection := nil. |
|
5419 |
self |
|
5420 |
undoableDo:[ |
|
5421 |
self pasteOrReplace:(Timestamp now printStringRFC1123Format). |
|
5422 |
] |
|
5423 |
info:'paste date and time' |
|
5424 |
! |
|
5425 |
||
2676 | 5426 |
insertFile |
3160 | 5427 |
"insert contents of a file |
2676 | 5428 |
- ask user for filename using a fileSelectionBox." |
5429 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5430 |
|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
|
5431 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5432 |
((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
|
5433 |
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
|
5434 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5435 |
ifTrue:[ |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5436 |
initial := selFn pathName. |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5437 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5438 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5439 |
[ |
3190 | 5440 |
|why| |
5441 |
||
5442 |
file := Dialog |
|
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
5443 |
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
|
5444 |
default:initial |
3190 | 5445 |
ok:(resources string:'Insert') |
5446 |
abort:(resources string:'Cancel') |
|
5447 |
pattern:nil |
|
5448 |
fromDirectory:directoryForFileDialog. |
|
5449 |
file isNil ifTrue:[ |
|
5450 |
"cancel" |
|
5451 |
^ self. |
|
5452 |
]. |
|
5453 |
file := file asFilename. |
|
5454 |
directoryForFileDialog := file. |
|
5455 |
||
5456 |
ok := file isReadable and:[file isDirectory not]. |
|
5457 |
ok ifFalse:[ |
|
5458 |
file isReadable ifFalse:[ |
|
5459 |
why := '%1 is unreadable.\\Please try again.' |
|
5460 |
] ifTrue:[ |
|
5461 |
why := '%1 is a directory.\\Please try again.' |
|
5462 |
]. |
|
5463 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
5464 |
]. |
|
2909 | 5465 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5466 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
5467 |
text := file contentsOfEntireFile. |
3495 | 5468 |
self |
5469 |
undoableDo:[ |
|
5470 |
self paste:text |
|
5471 |
] |
|
5472 |
info:'paste file' |
|
5473 |
||
5474 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
5475 |
! |
|
5476 |
||
5477 |
insertUUID |
|
5478 |
"insert a new UUID's string" |
|
5479 |
||
5480 |
typeOfSelection := nil. |
|
5481 |
self |
|
5482 |
undoableDo:[ |
|
5483 |
self pasteOrReplace:(UUID genUUID printString). |
|
5484 |
] |
|
5485 |
info:'paste new uuid' |
|
5486 |
||
5487 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 5488 |
! |
5489 |
||
2762 | 5490 |
openFileBrowserOnIt |
5491 |
"open a fileBrowser on the selected fileName" |
|
5492 |
||
5493 |
|fn dir| |
|
5494 |
||
5495 |
fn := self selectionAsString asFilename. |
|
5496 |
fn exists ifFalse:[ |
|
3160 | 5497 |
^ self warn:'Oops - file is gone'. |
2762 | 5498 |
]. |
5499 |
(dir := fn) isDirectory ifFalse:[ |
|
3160 | 5500 |
dir := fn directory |
2762 | 5501 |
]. |
5502 |
UserPreferences fileBrowserClass openOn:dir |
|
5503 |
! |
|
5504 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5505 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5506 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5507 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5508 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5509 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5510 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5511 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5512 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5513 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5514 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
5515 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5516 |
paste |
1289 | 5517 |
"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
|
5518 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5519 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5520 |
self checkModificationsAllowed ifTrue:[ |
3160 | 5521 |
self withSelfAndTextForPasteDo:[:me :text | |
5522 |
me unselect. |
|
5523 |
me undoablePaste:text |
|
5524 |
] |
|
2952 | 5525 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5526 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5527 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5528 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5529 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5530 |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5531 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5532 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5533 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5534 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5535 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5536 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5537 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5538 |
CharacterEncoderError handle:[:ex | |
3180 | 5539 |
|code msg| |
5540 |
||
5541 |
code := ex parameter. |
|
5542 |
codingErrorReported ifFalse:[ |
|
5543 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
|
5544 |
code notNil ifTrue:[ |
|
5545 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
5546 |
]. |
|
3190 | 5547 |
Dialog warn:(resources stringWithCRs:msg). |
3180 | 5548 |
codingErrorReported := true. |
5549 |
]. |
|
3482
485fb4d1f464
CharacterEncoderError handling (take defaultValue from target encoding)
Stefan Vogel <sv@exept.de>
parents:
3479
diff
changeset
|
5550 |
ex proceedWith:ex defaultValue |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5551 |
] do:[ |
3180 | 5552 |
s isString ifTrue:[ |
5553 |
s encoding ~~ characterEncoding ifTrue:[ |
|
5554 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5555 |
]. |
|
5556 |
||
5557 |
s := s asStringCollection. |
|
5558 |
(someText endsWith:Character cr) ifTrue:[ |
|
5559 |
"/ s := s copyWith:nil. |
|
5560 |
s := s copyWith:'' "/ an empty line at the end |
|
5561 |
||
5562 |
] |
|
5563 |
] ifFalse:[ |
|
5564 |
s isStringCollection ifTrue:[ |
|
5565 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
5566 |
] ifFalse:[ |
|
5567 |
(self |
|
5568 |
confirm:(resources |
|
5569 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
5570 |
with:s class name)) ifFalse:[^ self]. |
|
5571 |
s := StringCollection with:s storeString . |
|
5572 |
"/ ^ self |
|
5573 |
]. |
|
5574 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5575 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
5576 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5577 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5578 |
(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
|
5579 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5580 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5581 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5582 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5583 |
startCol := c1 := cursorCol. |
3180 | 5584 |
|
5585 |
"do not expand tabs in s here - |
|
5586 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
5587 |
Some Subviews want to paste with unexpanded tabs!!" |
|
5588 |
||
5589 |
self insertLines:s withCR:false. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5590 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5591 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5592 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5593 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
5594 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5595 |
"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
|
5596 |
"Modified: / 30.1.2000 / 02:32:42 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5597 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5598 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5599 |
pasteOrReplace |
1289 | 5600 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 5601 |
otherwise paste at cursor position. |
5602 |
Replace is not done for selections which were created by a paste, |
|
2010 | 5603 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5604 |
|
2724 | 5605 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5606 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5607 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5608 |
pasteOrReplace:someText |
1289 | 5609 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5610 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5611 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5612 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5613 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5614 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5615 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5616 |
self undoableDo:[ |
3542 | 5617 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
5618 |
self replace:someText |
|
5619 |
] ifFalse:[ |
|
5620 |
self paste:someText. |
|
5621 |
] |
|
5622 |
] info:'Paste/Replace'. |
|
1289 | 5623 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
5624 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5625 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5626 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5627 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5628 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5629 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5630 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5631 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5632 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5633 |
self checkModificationsAllowed ifFalse:[ |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5634 |
self flash. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5635 |
^ self |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5636 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5637 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5638 |
text notNil ifTrue:[ |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5639 |
self pasteOrReplace:text |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5640 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5641 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
5642 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5643 |
replace |
1289 | 5644 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5645 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5646 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5647 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5648 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5649 |
self withSelfAndTextForPasteDo:[:me :text | |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5650 |
me undoableDo:[ |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5651 |
me replace:text |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
5652 |
] |
3542 | 5653 |
info:'Replace' |
2952 | 5654 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5655 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5656 |
|
121 | 5657 |
replace:someText |
1289 | 5658 |
"replace the selection by someText" |
121 | 5659 |
|
3160 | 5660 |
|selected selectedString |
5661 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 5662 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5663 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5664 |
|
3130 | 5665 |
self undoableDo:[ |
3542 | 5666 |
selected := self selection. |
5667 |
selected isNil ifTrue:[ |
|
5668 |
^ self paste:someText |
|
5669 |
]. |
|
5670 |
||
5671 |
self deleteSelection. |
|
5672 |
||
5673 |
"take care, if we replace a selection without space by a word selected |
|
5674 |
with one - in this case we usually do not want the space. |
|
5675 |
But, if we replace a word-selected selection by something without a |
|
5676 |
space, we DO want the space added." |
|
5677 |
||
5678 |
selected size == 1 ifTrue:[ |
|
5679 |
selectedString := selected at:1. |
|
5680 |
]. |
|
5681 |
||
5682 |
someText size == 1 ifTrue:[ |
|
5683 |
|cutOffSpace addSpace replacement replacementString| |
|
5684 |
||
5685 |
cutOffSpace := false. |
|
5686 |
addSpace := false. |
|
5687 |
replacement := someText copyFrom:1. |
|
5688 |
||
5689 |
selectedString notNil ifTrue:[ |
|
5690 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
5691 |
"selection has no space" |
|
5692 |
||
5693 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
5694 |
cutOffSpace := true |
|
5695 |
] |
|
5696 |
] ifTrue:[ |
|
5697 |
addSpace := true |
|
5698 |
] |
|
5699 |
]. |
|
5700 |
replacementString := replacement at:1. |
|
5701 |
cutOffSpace ifTrue:[ |
|
5702 |
(replacementString startsWith:' ') ifTrue:[ |
|
5703 |
replacementString := replacementString withoutSpaces |
|
5704 |
]. |
|
5705 |
] ifFalse:[ |
|
5706 |
selectStyle == #wordLeft ifTrue:[ |
|
5707 |
"want a space at left" |
|
5708 |
(replacementString startsWith:' ') ifFalse:[ |
|
5709 |
replacementString := replacementString withoutSpaces. |
|
5710 |
replacementString := ' ' , replacementString |
|
5711 |
] |
|
5712 |
]. |
|
5713 |
selectStyle == #wordRight ifTrue:[ |
|
5714 |
"want a space at right" |
|
5715 |
||
5716 |
(replacementString endsWith:' ') ifFalse:[ |
|
5717 |
replacementString := replacementString withoutSpaces. |
|
5718 |
replacementString := replacementString , ' ' |
|
5719 |
] |
|
5720 |
]. |
|
5721 |
]. |
|
5722 |
replacement at:1 put: replacementString. |
|
5723 |
self paste:replacement. |
|
5724 |
] ifFalse:[ |
|
5725 |
self paste:someText |
|
5726 |
]. |
|
5727 |
lastString := selectedString. |
|
5728 |
lastReplacement := someText. |
|
5729 |
||
5730 |
selStartLine := selectionStartLine. |
|
5731 |
selStartCol := self selectionStartCol. |
|
5732 |
selEndLine := selectionEndLine. |
|
5733 |
selEndCol := self selectionEndCol. |
|
3130 | 5734 |
] |
3542 | 5735 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
5736 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5737 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
5738 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 5739 |
! |
5740 |
||
3430 | 5741 |
searchReplace |
5742 |
"search for a string - show a box to enter searchpattern |
|
5743 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
|
5744 |
- currently no regular expressions are handled." |
|
5745 |
||
5746 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
|
5747 |
||
5748 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
5749 |
lastSearchDirection := #forward. |
|
5750 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5751 |
caseHolder := ign asValue. |
|
5752 |
patternHolder := '' asValue. |
|
5753 |
replacePatternHolder := '' asValue. |
|
5754 |
lastSearchPattern notNil ifTrue:[ |
|
5755 |
initialString := lastSearchPattern |
|
5756 |
]. |
|
5757 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
5758 |
initialString := self selectionAsString |
|
5759 |
]. |
|
5760 |
initialString isNil ifTrue:[ |
|
5761 |
LastSearchPatterns size > 0 ifTrue:[ |
|
5762 |
initialString := LastSearchPatterns first |
|
5763 |
] |
|
5764 |
]. |
|
5765 |
initialString notNil ifTrue:[ |
|
5766 |
patternHolder value:initialString. |
|
5767 |
replacePatternHolder value:initialString. |
|
5768 |
]. |
|
5769 |
flag := true. |
|
5770 |
search := [:fwd | |
|
5771 |
self |
|
5772 |
search:patternHolder value |
|
5773 |
ignoreCase:caseHolder value |
|
5774 |
forward:fwd. |
|
5775 |
]. |
|
5776 |
replace := [:all | |
|
5777 |
self |
|
5778 |
replace:patternHolder value |
|
5779 |
by:replacePatternHolder value |
|
5780 |
all:all |
|
5781 |
ignoreCase:caseHolder value |
|
5782 |
]. |
|
5783 |
bindings := IdentityDictionary new. |
|
5784 |
bindings at:#searchPattern put:patternHolder. |
|
5785 |
bindings at:#replacePattern put:replacePatternHolder. |
|
5786 |
modal ifTrue:[ |
|
5787 |
bindings at:#nextAction |
|
5788 |
put:[ |
|
5789 |
flag := true. |
|
5790 |
action := search. |
|
5791 |
searchBox doAccept. |
|
5792 |
]. |
|
5793 |
bindings at:#prevAction |
|
5794 |
put:[ |
|
5795 |
flag := false. |
|
5796 |
action := search. |
|
5797 |
searchBox doAccept. |
|
5798 |
]. |
|
5799 |
bindings at:#replaceAction |
|
5800 |
put:[ |
|
5801 |
flag := false. |
|
5802 |
action := replace. |
|
5803 |
searchBox doAccept. |
|
5804 |
]. |
|
5805 |
bindings at:#replaceAllAction |
|
5806 |
put:[ |
|
5807 |
flag := true. |
|
5808 |
action := replace. |
|
5809 |
searchBox doAccept. |
|
5810 |
]. |
|
5811 |
] ifFalse:[ |
|
5812 |
bindings at:#nextAction put:[ search value:true. ]. |
|
5813 |
bindings at:#prevAction put:[ search value:false. ]. |
|
5814 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
5815 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
5816 |
]. |
|
5817 |
bindings at:#ignoreCase put:caseHolder. |
|
5818 |
bindings at:#patternList put:LastSearchPatterns. |
|
5819 |
modal ifTrue:[ |
|
5820 |
searchBox := SimpleDialog new. |
|
5821 |
] ifFalse:[ |
|
5822 |
searchBox := ApplicationModel new. |
|
5823 |
searchBox createBuilder. |
|
5824 |
]. |
|
5825 |
searchBox resources:(self resources). |
|
5826 |
bldr := searchBox builder. |
|
5827 |
bldr addBindings:bindings. |
|
5828 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
5829 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
5830 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
5831 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
5832 |
modal ifTrue:[ |
|
5833 |
searchBox openDialog. |
|
5834 |
searchBox accepted ifTrue:[ |
|
5835 |
action value:flag |
|
5836 |
]. |
|
5837 |
] ifFalse:[ |
|
5838 |
(bldr componentAt:#nextButton) isReturnButton:false. |
|
5839 |
(bldr componentAt:#cancelButton) |
|
5840 |
label:(resources string:'Close'); |
|
5841 |
action:[ searchBox closeRequest ]. |
|
5842 |
||
5843 |
"/ searchBox masterApplication:self application. |
|
5844 |
||
5845 |
self topView beMaster. |
|
5846 |
(searchBox window) |
|
5847 |
beSlave; |
|
5848 |
openInGroup:(self windowGroup). |
|
5849 |
||
5850 |
"/ searchBox window open. |
|
5851 |
||
5852 |
searchBox window assignKeyboardFocusToFirstInputField. |
|
5853 |
] |
|
5854 |
||
5855 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
5856 |
! |
|
5857 |
||
121 | 5858 |
showDeleted |
5859 |
"open a readonly editor on all deleted text" |
|
5860 |
||
5861 |
|v| |
|
5862 |
||
5863 |
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
|
5864 |
v readOnly:true. |
121 | 5865 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5866 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5867 |
|
3221 | 5868 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
5869 |
"sort the selected lines" |
|
5870 |
||
5871 |
|lines extractor fetcher lineWise nStr n s words| |
|
5872 |
||
5873 |
lineWise := true. |
|
5874 |
||
5875 |
how == #lines ifTrue:[ |
|
5876 |
extractor := [:l | l withoutLeadingSeparators]. |
|
5877 |
] ifFalse:[ how == #linesByFirstWord ifTrue:[ |
|
3222 | 5878 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
3221 | 5879 |
] ifFalse:[ how == #linesByNthWord ifTrue:[ |
5880 |
nStr := Dialog request:'Word (1..)'. |
|
5881 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
5882 |
n := Integer readFrom:nStr onError:[^ self]. |
|
5883 |
||
3227
49b97c45652a
sort by nth word: do not skip non-alphanumeric words
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
5884 |
extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')]. |
3221 | 5885 |
] ifFalse:[ how == #words ifTrue:[ |
5886 |
lineWise := false. |
|
5887 |
extractor := [:w | w]. |
|
5888 |
] ifFalse:[ |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5889 |
self error:'unknown sort criteria: ', how printString. |
3221 | 5890 |
]]]]. |
5891 |
||
5892 |
ignoreCase ifTrue:[ |
|
5893 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
5894 |
] ifFalse:[ |
|
5895 |
fetcher := extractor. |
|
5896 |
]. |
|
5897 |
||
5898 |
lineWise ifTrue:[ |
|
5899 |
start == end ifTrue:[^ self ]. |
|
5900 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
5901 |
lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)]. |
|
5902 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
5903 |
self textChanged. |
|
5904 |
^ self. |
|
5905 |
]. |
|
5906 |
||
5907 |
s := self selectionAsString. |
|
5908 |
words := s asCollectionOfWords. |
|
5909 |
words := words sort:[:w1 :w2 | (fetcher value:w1) < (fetcher value:w2)]. |
|
5910 |
s := words asStringCollection asStringWith:Character space. |
|
5911 |
self replace:s. |
|
5912 |
self textChanged. |
|
5913 |
! |
|
5914 |
||
5915 |
sortSelection:how ignoreCase:ignoreCase |
|
5916 |
"sort the selected lines" |
|
5917 |
||
5918 |
|start end| |
|
5919 |
||
5920 |
selectionStartLine isNil ifTrue:[^ self]. |
|
5921 |
||
5922 |
start := selectionStartLine. |
|
5923 |
end := selectionEndLine. |
|
5924 |
(selectionEndCol == 0) ifTrue:[ |
|
5925 |
end := end - 1 |
|
5926 |
]. |
|
5927 |
||
5928 |
self |
|
5929 |
undoableDo:[ |
|
5930 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end. |
|
5931 |
] |
|
5932 |
info:'sort' |
|
5933 |
! |
|
5934 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
5935 |
specialCharacters |
2915 | 5936 |
CharacterSetView |
3160 | 5937 |
openAsInputFor:self |
5938 |
label:'Special Character Input' |
|
5939 |
clickLabel:'Click to Insert Character'. |
|
2866 | 5940 |
! |
5941 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5942 |
undoablePaste:someText |
3495 | 5943 |
self undoablePaste:someText info:nil. |
5944 |
||
5945 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
5946 |
! |
|
5947 |
||
5948 |
undoablePaste:someText info:infoOrNil |
|
5949 |
self |
|
5950 |
undoableDo:[ |
|
5951 |
self paste:someText. |
|
5952 |
] |
|
5953 |
info:infoOrNil |
|
5954 |
||
5955 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
5956 |
! |
|
5957 |
||
5958 |
undoablePasteOrReplace:someText info:infoOrNil |
|
5959 |
self |
|
5960 |
undoableDo:[ |
|
5961 |
self pasteOrReplace:someText. |
|
5962 |
] |
|
5963 |
info:infoOrNil |
|
5964 |
||
5965 |
"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
|
5966 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5967 |
|
2724 | 5968 |
withSelfAndTextForPasteDo:aBlock |
5969 |
"common code for paste/replace of the copybuffer" |
|
5970 |
||
5971 |
|sel| |
|
5972 |
||
5973 |
self checkModificationsAllowed ifFalse:[ |
|
3160 | 5974 |
self flash. |
5975 |
^ self |
|
2724 | 5976 |
]. |
5977 |
||
5978 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
5979 |
sel notNil ifTrue:[ |
|
3160 | 5980 |
aBlock value:self value:sel. |
2724 | 5981 |
] |
105 | 5982 |
! ! |
5983 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5984 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5985 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
5986 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5987 |
"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
|
5988 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
5989 |
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
|
5990 |
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
|
5991 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
5992 |
self isReadOnly ifTrue: [ |
3160 | 5993 |
exceptionBlock isNil ifTrue:[ |
5994 |
^ false |
|
5995 |
]. |
|
5996 |
||
5997 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
5998 |
^ false |
|
5999 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6000 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6001 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6002 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6003 |
"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
|
6004 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6005 |
|
2596 | 6006 |
currentSelectionBgColor |
6007 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 6008 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 6009 |
]. |
6010 |
^ super currentSelectionBgColor |
|
6011 |
||
6012 |
" |
|
6013 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
6014 |
" |
|
6015 |
! |
|
6016 |
||
6017 |
currentSelectionFgColor |
|
6018 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 6019 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 6020 |
]. |
6021 |
^ super currentSelectionFgColor |
|
6022 |
! |
|
6023 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6024 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6025 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6026 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6027 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6028 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6029 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6030 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6031 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6032 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6033 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6034 |
textChanged |
522 | 6035 |
"my text was modified (internally). |
6036 |
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
|
6037 |
contentsChanged, which is triggered when the size has changed, and |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6038 |
is used to notify scrollers, other views etc.)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6039 |
|
641 | 6040 |
self contentsChanged. |
1015 | 6041 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6042 |
contentsWasSaved := false |
641 | 6043 |
|
1015 | 6044 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 6045 |
! |
6046 |
||
2617 | 6047 |
textChangedButNoSizeChange |
2207 | 6048 |
"my text was modified (internally). |
6049 |
Sent whenever text has been edited (not to confuse with |
|
6050 |
contentsChanged, which is triggered when the size has changed, and |
|
6051 |
is used to notify scrollers, other views etc.)" |
|
6052 |
||
6053 |
self modified:true. |
|
6054 |
contentsWasSaved := false |
|
6055 |
||
6056 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6057 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6058 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6059 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6060 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6061 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6062 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6063 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6064 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6065 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6066 |
"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
|
6067 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6068 |
|
1878 | 6069 |
isKeyboardConsumer |
6070 |
"return true, if the receiver is a keyboard consumer; |
|
6071 |
Return true here, redefined from SimpleView." |
|
6072 |
||
3476 | 6073 |
^ self isReadOnly not |
1878 | 6074 |
! |
6075 |
||
997 | 6076 |
specClass |
1390 | 6077 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
6078 |
||
997 | 6079 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 6080 |
^ super specClass |
6081 |
||
1390 | 6082 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 6083 |
! |
6084 |
||
324 | 6085 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6086 |
"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
|
6087 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
6088 |
"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
|
6089 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6090 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 6091 |
|
6092 |
"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
|
6093 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
6094 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6095 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6096 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6097 |
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
|
6098 |
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
|
6099 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6100 |
|
697 | 6101 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6102 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6103 |
w := super widthOfContents. |
697 | 6104 |
(dev := device) isNil ifTrue:[ |
3160 | 6105 |
"/ really dont know ... |
6106 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
6107 |
]. |
697 | 6108 |
^ w + (font widthOn:dev) |
6109 |
||
6110 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6111 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6112 |
|
1588 | 6113 |
!EditTextView methodsFor:'realization'! |
6114 |
||
6115 |
realize |
|
6116 |
"make the view visible - scroll to make the cursor visible." |
|
6117 |
||
6118 |
super realize. |
|
6119 |
||
6120 |
self makeCursorVisible. |
|
1993 | 6121 |
cursorFgColor := cursorFgColor onDevice:device. |
6122 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 6123 |
|
6124 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
6125 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
6126 |
! ! |
|
6127 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6128 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6130 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6131 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6132 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6133 |
cursorShown ifTrue:[ |
3160 | 6134 |
cursorVisibleLine notNil ifTrue:[ |
6135 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
6136 |
self drawCursorCharacter |
|
6137 |
] |
|
6138 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6139 |
] |
105 | 6140 |
! |
6141 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6142 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6143 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6144 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6145 |
cursorShown ifTrue:[ |
3160 | 6146 |
(visLine == cursorVisibleLine) ifTrue:[ |
6147 |
self drawCursorCharacter |
|
6148 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6149 |
] |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6152 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6153 |
"redraw a visible line range" |
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 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6156 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6159 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6160 |
"redraw a visible line" |
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 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6163 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6164 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6165 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6166 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6167 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6168 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6169 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6170 |
cursorShown ifTrue:[ |
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6171 |
(visLine == cursorVisibleLine) ifTrue:[ |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6172 |
(colNr == cursorCol) ifTrue:[ |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6173 |
self drawCursorCharacter. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6174 |
^ self |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6175 |
] |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6176 |
] |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6177 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6178 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
6179 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6180 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6181 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6182 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6183 |
"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
|
6184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6185 |
super redrawVisibleLine:visLine from:startCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6186 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6187 |
! |
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 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6190 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6191 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6192 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6193 |
self redrawCursorIfInVisibleLine:visLine |
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 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6197 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6198 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6199 |
"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
|
6200 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6201 |
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
|
6202 |
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
|
6203 |
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
|
6204 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6205 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6206 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
6207 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6208 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6209 |
"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
|
6210 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6211 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6212 |
|prevCursorLine| |
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 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6215 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6216 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6217 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6218 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6219 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6220 |
"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
|
6221 |
within the real text " |
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 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6224 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6225 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6226 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6227 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6230 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6231 |
"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
|
6232 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6233 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6234 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6235 |
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
|
6236 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6237 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6238 |
prevCursorState ifTrue:[ |
3160 | 6239 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6240 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6241 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6242 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
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 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6246 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6247 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6248 |
prevCursorState := cursorShown. |
1601 | 6249 |
"/ cursorShown := false. |
1591 | 6250 |
cursorShown ifTrue:[ |
3160 | 6251 |
self hideCursor |
1591 | 6252 |
] |
6253 |
||
1601 | 6254 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6255 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6256 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6257 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6258 |
"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
|
6259 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6260 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6261 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6262 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6263 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6264 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6265 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6266 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6267 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6268 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6269 |
"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
|
6270 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6271 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6272 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6273 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6274 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6275 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6276 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6277 |
! ! |
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 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6280 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6281 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6282 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6283 |
|
2822 | 6284 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 6285 |
! |
6286 |
||
6287 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
6288 |
"do a backward search" |
|
6289 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6290 |
|pos startLine startCol| |
1339 | 6291 |
|
6292 |
cursorLine isNil ifTrue:[^ self]. |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6293 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6294 |
pos := self startPositionForSearchBackward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6295 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6296 |
startCol := pos x. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6297 |
|
3580 | 6298 |
self searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
6299 |
||
6300 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
6301 |
! |
|
6302 |
||
6303 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
6304 |
"do a backward search" |
|
6305 |
||
6306 |
cursorLine isNil ifTrue:[^ self]. |
|
6307 |
||
3160 | 6308 |
self |
3580 | 6309 |
searchBackwardFor:pattern |
6310 |
ignoreCase:ign |
|
6311 |
startingAtLine:startLine col:startCol |
|
6312 |
ifFound:[:line :col | |
|
6313 |
self cursorMovementAllowed ifTrue:[ |
|
6314 |
self cursorLine:line col:col. |
|
6315 |
]. |
|
6316 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 6317 |
"/ self makeLineVisible:cursorLine |
3580 | 6318 |
typeOfSelection := #search] |
6319 |
ifAbsent:aBlock |
|
1339 | 6320 |
|
6321 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6322 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6323 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6324 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6325 |
"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
|
6326 |
|
2554 | 6327 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6328 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6329 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6330 |
searchForMatchingParenthesis |
3160 | 6331 |
"search for a matching parenthesis starting at cursor position. |
6332 |
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
|
6333 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6334 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6335 |
|
2822 | 6336 |
self cursorMovementAllowed ifFalse:[^ self]. |
6337 |
||
3160 | 6338 |
self |
6339 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
|
6340 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
6341 |
ifNotFound:[self showNotFound] |
|
6342 |
onError:[self beep] |
|
1339 | 6343 |
|
6344 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6345 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6346 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6347 |
searchFwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6348 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6349 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6350 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6351 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6352 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6353 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6354 |
startCol := pos x. |
1339 | 6355 |
|
3160 | 6356 |
self |
6357 |
searchFwd:pattern |
|
6358 |
startingAtLine:startLine col:startCol |
|
6359 |
ifAbsent:aBlock |
|
1339 | 6360 |
|
6361 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
6362 |
! |
|
6363 |
||
6364 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
6365 |
"do a forward search" |
|
6366 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6367 |
|pos startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6368 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6369 |
pos := self startPositionForSearchForward. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6370 |
startLine := pos y. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6371 |
startCol := pos x. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6372 |
|
3160 | 6373 |
self |
6374 |
searchFwd:pattern |
|
6375 |
ignoreCase:ign |
|
6376 |
startingAtLine:startLine col:startCol |
|
6377 |
ifAbsent:aBlock |
|
1339 | 6378 |
|
6379 |
"Modified: 9.10.1997 / 12:58:59 / cg" |
|
6380 |
"Created: 9.10.1997 / 13:04:10 / cg" |
|
6381 |
! |
|
6382 |
||
6383 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
6384 |
"do a forward search" |
|
6385 |
||
6386 |
cursorLine isNil ifTrue:[^ self]. |
|
3160 | 6387 |
self |
6388 |
searchForwardFor:pattern |
|
6389 |
ignoreCase:ign |
|
6390 |
startingAtLine:startLine col:startCol |
|
6391 |
ifFound:[:line :col | |
|
6392 |
self cursorMovementAllowed ifTrue:[ |
|
6393 |
self cursorLine:line col:col. |
|
6394 |
]. |
|
6395 |
self showMatch:pattern atLine:line col:col. |
|
1339 | 6396 |
"/ self makeLineVisible:cursorLine |
3160 | 6397 |
typeOfSelection := #search] |
6398 |
ifAbsent:aBlock |
|
1339 | 6399 |
|
6400 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
6401 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6402 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6403 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6404 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6405 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6406 |
|
2822 | 6407 |
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
|
6408 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6409 |
|
3578 | 6410 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6411 |
"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
|
6412 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6413 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6414 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6415 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6416 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6417 |
"/ 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
|
6418 |
"/ original string (for search after again) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6419 |
"/ |
3160 | 6420 |
(lastString notNil |
565 | 6421 |
and:[lastReplacement notNil |
6422 |
and:[typeOfSelection ~~ #search]]) ifTrue:[ |
|
3578 | 6423 |
lastString isString ifTrue:[ |
6424 |
lastSearchPattern := lastString. |
|
6425 |
] ifFalse:[ |
|
6426 |
lastSearchPattern := lastString asStringWithoutFinalCR. |
|
6427 |
]. |
|
6428 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6429 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6430 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6431 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6432 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6433 |
"/ 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
|
6434 |
"/ 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
|
6435 |
"/ it did not result from a paste. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6436 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6437 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6438 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6439 |
sel notNil ifTrue:[ |
3578 | 6440 |
(lastSearchPattern isNil |
6441 |
or:[typeOfSelection ~~ #paste]) ifTrue:[ |
|
6442 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
6443 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
6444 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
6445 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6446 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
6447 |
|
565 | 6448 |
"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
|
6449 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6450 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6451 |
startPositionForSearchBackward |
2822 | 6452 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
6453 |
! |
|
6454 |
||
6455 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6456 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6457 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6458 |
selectionStartLine notNil ifTrue:[ |
3160 | 6459 |
startLine := selectionStartLine. |
6460 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6461 |
] ifFalse:[ |
3160 | 6462 |
cursorLine isNil ifTrue:[ |
6463 |
startLine := list size. |
|
6464 |
startCol := self listAt:startLine size. |
|
6465 |
] ifFalse:[ |
|
6466 |
startLine := cursorLine min:list size. |
|
6467 |
startCol := cursorCol |
|
6468 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6469 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6470 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6471 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6472 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6473 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6474 |
startPositionForSearchForward |
2822 | 6475 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
6476 |
! |
|
6477 |
||
6478 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6479 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6480 |
|
3160 | 6481 |
"/ 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
|
6482 |
"/ 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
|
6483 |
startCol := cursorCol. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6484 |
self hasSelection ifFalse:[ |
3160 | 6485 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
6486 |
startCol := 0 |
|
6487 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6488 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6489 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
6490 |
^ startCol @ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6491 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6492 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6493 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6494 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6495 |
addToSelectionAfter:aBlock |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6496 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6497 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6498 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6499 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6500 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6501 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6502 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6503 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6504 |
self hasSelection ifTrue: [ |
3160 | 6505 |
startLine := selectionStartLine . |
6506 |
startCol := selectionStartCol . |
|
6507 |
endLine := selectionEndLine . |
|
6508 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6509 |
] ifFalse: [ |
3160 | 6510 |
startLine := endLine := cursorLine . |
6511 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6512 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6513 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6514 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6515 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6516 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6517 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6518 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6519 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
3160 | 6520 |
ifTrue: [ |
6521 |
startCol := cursorCol. |
|
6522 |
] ifFalse: [ |
|
6523 |
endCol := cursorCol - 1. |
|
6524 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6525 |
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
|
6526 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
6527 |
|
1850 | 6528 |
autoMoveCursorToEndOfSelection |
6529 |
"return true, if the cursor should be automatically moved to the |
|
6530 |
end of a selection. |
|
6531 |
Redefined to return false in terminaViews, where the cursor should |
|
6532 |
not be affected by selecting" |
|
6533 |
||
6534 |
^ true |
|
6535 |
! |
|
6536 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6537 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6538 |
typeOfSelection ~~ newType ifTrue:[ |
3160 | 6539 |
typeOfSelection := newType. |
6540 |
selectionStartLine notNil ifTrue:[ |
|
6541 |
self |
|
6542 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
6543 |
toLine:selectionEndLine col:selectionEndCol |
|
6544 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6545 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6546 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6547 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6548 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6549 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6550 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6551 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6552 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6553 |
list isNil ifTrue:[ |
3160 | 6554 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6555 |
] ifFalse:[ |
3160 | 6556 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
6557 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6558 |
] |
1082 | 6559 |
|
6560 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6561 |
! |
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 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6564 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6565 |
|
3160 | 6566 |
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
|
6567 |
! |
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 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6570 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6571 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6572 |
cursorCol > 1 ifTrue:[ |
3160 | 6573 |
self selectFromLine:cursorLine col:1 |
6574 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6575 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6576 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
6577 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6580 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6581 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6582 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6583 |
selectionStartLine isNil ifTrue:[ |
3160 | 6584 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6585 |
] ifFalse:[ |
3160 | 6586 |
self selectFromLine:selectionStartLine col:selectionStartCol |
6587 |
toLine:cursorLine+1 col:0. |
|
6588 |
self makeLineVisible:selectionEndLine |
|
259
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 |
! |
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 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6593 |
"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
|
6594 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6595 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6596 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6597 |
list isNil ifTrue:[ |
3160 | 6598 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6599 |
] ifFalse:[ |
3160 | 6600 |
cursorCol == 0 ifTrue:[ |
6601 |
col := 0 |
|
6602 |
] ifFalse:[ |
|
6603 |
col := cursorCol - 1 |
|
6604 |
]. |
|
6605 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
6606 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6607 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6608 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6609 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6610 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6611 |
"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
|
6612 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6613 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6614 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 6615 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
3160 | 6616 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 6617 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6618 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6619 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6620 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6621 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6622 |
"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
|
6623 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6624 |
list isNil ifTrue:[ |
3160 | 6625 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6626 |
] ifFalse:[ |
3160 | 6627 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
6628 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6629 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6630 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6631 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6632 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6633 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6635 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6636 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6637 |
|
3580 | 6638 |
selectionForStringSearchTool |
6639 |
||
6640 |
|sel searchPattern| |
|
6641 |
||
6642 |
"/ |
|
6643 |
"/ if there is a selection: |
|
6644 |
"/ if there was no previous search, take it as search pattern. |
|
6645 |
"/ if there was a previous search, only take the selection if |
|
6646 |
"/ it did not result from a paste. |
|
6647 |
"/ (to allow search-paste to be repeated) |
|
6648 |
"/ |
|
6649 |
||
6650 |
sel := self selection. |
|
6651 |
sel notNil ifTrue:[ |
|
6652 |
typeOfSelection ~~ #search ifTrue:[ |
|
6653 |
typeOfSelection ~~ #paste ifTrue:[ |
|
6654 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
6655 |
searchPattern := sel asStringWithoutFinalCR. |
|
6656 |
] |
|
6657 |
] |
|
6658 |
]. |
|
6659 |
^ searchPattern |
|
6660 |
! |
|
6661 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6662 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6663 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6664 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6665 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6666 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6667 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6668 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
6669 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6670 |
wasOn ifTrue:[self showCursor] |
105 | 6671 |
! ! |
6672 |
||
6673 |
!EditTextView methodsFor:'undo & again'! |
|
6674 |
||
2952 | 6675 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6676 |
^ undoSupport addUndo:action. |
2952 | 6677 |
! |
6678 |
||
105 | 6679 |
again |
6680 |
"repeat the last action (which was a cut or replace). |
|
6681 |
If current selection is not last string, search forward to |
|
3160 | 6682 |
next occurrence of it before repeating the last operation." |
105 | 6683 |
|
2323
ef201d5d0689
fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents:
2310
diff
changeset
|
6684 |
|s l c sel savedSelectStyle startColForSearch| |
105 | 6685 |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6686 |
lastString isNil ifTrue:[ |
3160 | 6687 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6688 |
]. |
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
6689 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6690 |
self undoableDo:[ |
3160 | 6691 |
s := lastString asString. |
6692 |
||
6693 |
"remove final cr" |
|
6694 |
(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
|
6695 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
3160 | 6696 |
savedSelectStyle := selectStyle. |
6697 |
selectStyle := nil. |
|
6698 |
||
6699 |
sel := self selection. |
|
6700 |
||
6701 |
"if we are already there (after a find), ommit search" |
|
6702 |
||
6703 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
6704 |
l := selectionStartLine "cursorLine". |
|
6705 |
c := selectionStartCol "cursorCol". |
|
6706 |
self deleteSelection. |
|
6707 |
lastReplacement notNil ifTrue:[ |
|
6708 |
self insertLines:lastReplacement asStringCollection withCR:false. |
|
6709 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
6710 |
]. |
|
6711 |
selectStyle := savedSelectStyle. |
|
6712 |
^ true |
|
6713 |
]. |
|
6714 |
startColForSearch := cursorCol. |
|
6715 |
sel isNil ifTrue:[ |
|
6716 |
startColForSearch := startColForSearch - 1 |
|
6717 |
]. |
|
6718 |
self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch |
|
6719 |
ifFound: |
|
6720 |
[ |
|
6721 |
:line :col | |
|
6722 |
||
6723 |
|repl| |
|
6724 |
||
6725 |
self selectFromLine:line col:col |
|
6726 |
toLine:line col:(col + s size - 1). |
|
6727 |
self makeLineVisible:line. |
|
6728 |
||
6729 |
self deleteSelection. |
|
6730 |
lastReplacement notNil ifTrue:[ |
|
6731 |
lastReplacement isString ifFalse:[ |
|
6732 |
repl := lastReplacement asString "withoutSpaces" |
|
6733 |
] ifTrue:[ |
|
6734 |
repl := lastReplacement "withoutSpaces". |
|
6735 |
]. |
|
6736 |
self insertLines:repl asStringCollection withCR:false. |
|
6737 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
6738 |
undoSupport actionInfo:'replace'. |
|
6739 |
]. |
|
6740 |
selectStyle := savedSelectStyle. |
|
6741 |
^ true |
|
6742 |
] |
|
6743 |
ifAbsent: |
|
6744 |
[ |
|
6745 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
6746 |
self showNotFound. |
|
6747 |
selectStyle := savedSelectStyle. |
|
6748 |
^ false |
|
6749 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
6750 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6751 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6752 |
^ true. |
501 | 6753 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
6754 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 6755 |
! |
6756 |
||
2952 | 6757 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6758 |
^ undoSupport hasRedoAction. |
2952 | 6759 |
! |
6760 |
||
6761 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6762 |
^ undoSupport hasUndoAction. |
2952 | 6763 |
! |
6764 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6765 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6766 |
"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
|
6767 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6768 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6769 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6770 |
|
2952 | 6771 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6772 |
undoSupport nonUndoableDo:aBlock. |
2952 | 6773 |
! |
6774 |
||
6775 |
redo |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6776 |
undoSupport hasRedoAction ifFalse:[ |
3160 | 6777 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6778 |
] ifTrue:[ |
3160 | 6779 |
undoSupport redo. |
2952 | 6780 |
] |
6781 |
! |
|
6782 |
||
121 | 6783 |
undo |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6784 |
undoSupport hasUndoAction ifFalse:[ |
3160 | 6785 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6786 |
] ifTrue:[ |
3160 | 6787 |
undoSupport undo. |
121 | 6788 |
] |
2952 | 6789 |
! |
6790 |
||
6791 |
undoableDo:aBlock |
|
3495 | 6792 |
self undoableDo:aBlock info:nil. |
6793 |
||
6794 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 6795 |
! |
6796 |
||
6797 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6798 |
self checkModificationsAllowed ifFalse:[ |
3495 | 6799 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
6800 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
6801 |
] ifTrue:[ |
3495 | 6802 |
undoSupport undoableDo:aBlock info:aString. |
6803 |
]. |
|
6804 |
||
6805 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 6806 |
! ! |
6807 |
||
6808 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
6809 |
||
6810 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6811 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
6812 |
! |
|
6813 |
||
3115 | 6814 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 6815 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 6816 |
! |
6817 |
||
2952 | 6818 |
line:arg1 col:arg2 character:arg3 |
6819 |
^ self new line:arg1 col:arg2 character:arg3 |
|
6820 |
! |
|
6821 |
||
3115 | 6822 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 6823 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 6824 |
! |
6825 |
||
3235 | 6826 |
line:arg1 col:arg2 characters:arg3 info:info |
6827 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
6828 |
! |
|
6829 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6830 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6831 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6832 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6833 |
|
2952 | 6834 |
line:arg1 col:arg2 string:arg3 |
6835 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 6836 |
! |
6837 |
||
6838 |
line:arg1 col:arg2 string:arg3 info:info |
|
6839 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 6840 |
! |
6841 |
||
6842 |
line:arg1 string:arg3 info:info |
|
6843 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 6844 |
! |
6845 |
||
6846 |
text:arg info:info |
|
6847 |
^ (self new text:arg) info:info |
|
3115 | 6848 |
! ! |
6849 |
||
6850 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
6851 |
||
6852 |
info |
|
6853 |
^ userFriendlyInfo |
|
6854 |
! |
|
6855 |
||
6856 |
info:aString |
|
6857 |
userFriendlyInfo := aString |
|
2952 | 6858 |
! ! |
6859 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6860 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6861 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6862 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6863 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6864 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6865 |
"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
|
6866 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
6867 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6868 |
!EditTextView::EditAction methodsFor:'queries'! |
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:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6871 |
^ 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 |
|
2952 | 6874 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
6875 |
||
3160 | 6876 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 6877 |
"set instance variables (automatically generated)" |
6878 |
||
6879 |
self assert:(line1Arg notNil). |
|
6880 |
self assert:(col1Arg notNil). |
|
6881 |
self assert:(line2Arg notNil). |
|
6882 |
self assert:(col2Arg notNil). |
|
6883 |
||
6884 |
line1 := line1Arg. |
|
6885 |
col1 := col1Arg. |
|
6886 |
line2 := line2Arg. |
|
6887 |
col2 := col2Arg. |
|
6888 |
! ! |
|
6889 |
||
6890 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
6891 |
||
3160 | 6892 |
executeIn:editor |
2952 | 6893 |
editor unselect. |
3160 | 6894 |
editor |
6895 |
deleteFromLine:line1 |
|
6896 |
col:col1 |
|
6897 |
toLine:line2 |
|
6898 |
col:col2. |
|
2952 | 6899 |
editor cursorLine:line1 col:col1. |
6900 |
! ! |
|
6901 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6902 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6903 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6904 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6905 |
^ 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 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6908 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6909 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6910 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6911 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6912 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6913 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6914 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6915 |
|
3160 | 6916 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6917 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6918 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6919 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6920 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6921 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6922 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6923 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6924 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6925 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6926 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6927 |
|
3160 | 6928 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6929 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6930 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6931 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6932 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6933 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6934 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6935 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6936 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6937 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6938 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6939 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6940 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6941 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6942 |
|
3160 | 6943 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6944 |
"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
|
6945 |
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
|
6946 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6947 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6948 |
previousDeleteAction line == line ifTrue:[ |
3160 | 6949 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
6950 |
^ true |
|
6951 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6952 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6953 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6954 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6955 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6956 |
|
3160 | 6957 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6958 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6959 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6960 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6961 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6962 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6963 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6964 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6965 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6966 |
|
3160 | 6967 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6968 |
editor unselect. |
3160 | 6969 |
editor |
6970 |
deleteFromLine:line |
|
6971 |
col:col1 |
|
6972 |
toLine:line |
|
6973 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6974 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6975 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
6976 |
|
3235 | 6977 |
!EditTextView::EditMode class methodsFor:'constants'! |
6978 |
||
6979 |
insertAndSelectMode |
|
6980 |
^ InsertAndSelectMode |
|
6981 |
! |
|
6982 |
||
6983 |
insertMode |
|
6984 |
^ InsertMode |
|
6985 |
! |
|
6986 |
||
6987 |
overwriteMode |
|
6988 |
^ OverwriteMode |
|
6989 |
! ! |
|
6990 |
||
6991 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
6992 |
||
6993 |
isInsertAndSelectMode |
|
6994 |
^ false |
|
6995 |
! |
|
6996 |
||
6997 |
isInsertMode |
|
6998 |
^ false |
|
6999 |
! |
|
7000 |
||
7001 |
symbolicName |
|
7002 |
self subclassResponsibility |
|
7003 |
! ! |
|
7004 |
||
7005 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
7006 |
||
7007 |
infoPrintString |
|
7008 |
^ 'IS' |
|
7009 |
! ! |
|
7010 |
||
7011 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
7012 |
||
7013 |
isInsertAndSelectMode |
|
7014 |
^ true |
|
7015 |
! |
|
7016 |
||
7017 |
isInsertMode |
|
7018 |
^ true |
|
7019 |
! ! |
|
7020 |
||
7021 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
7022 |
||
7023 |
infoPrintString |
|
7024 |
^ 'I' |
|
7025 |
! ! |
|
7026 |
||
7027 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
7028 |
||
7029 |
isInsertMode |
|
7030 |
^ true |
|
7031 |
! ! |
|
7032 |
||
7033 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
7034 |
||
7035 |
infoPrintString |
|
7036 |
^ 'O' |
|
7037 |
! ! |
|
7038 |
||
2952 | 7039 |
!EditTextView::PasteString methodsFor:'accessing'! |
7040 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7041 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7042 |
^ col |
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 |
"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
|
7045 |
! |
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 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7048 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7049 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7050 |
"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
|
7051 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7052 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7053 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7054 |
^ line |
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:21:08 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7057 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7058 |
|
3160 | 7059 |
line:lineArg col:colArg string:stringArg |
2952 | 7060 |
self assert:(lineArg notNil). |
7061 |
self assert:(colArg notNil). |
|
7062 |
self assert:(stringArg notNil). |
|
7063 |
||
7064 |
line := lineArg. |
|
7065 |
col := colArg. |
|
7066 |
string := stringArg. |
|
7067 |
! |
|
7068 |
||
7069 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
7070 |
self assert:(lineArg notNil). |
|
7071 |
self assert:(colArg notNil). |
|
7072 |
self assert:(stringArg notNil). |
|
7073 |
||
7074 |
line := lineArg. |
|
7075 |
col := colArg. |
|
7076 |
string := stringArg. |
|
7077 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7078 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7079 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7080 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7081 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7082 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7083 |
"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
|
7084 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7085 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7086 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7087 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7088 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7089 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7090 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7091 |
"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
|
7092 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7093 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7094 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7095 |
"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
|
7096 |
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
|
7097 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7098 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7099 |
previousPasteAction line == line ifTrue:[ |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7100 |
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
|
7101 |
^ true |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7102 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7103 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7104 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7105 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7106 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7107 |
"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
|
7108 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7109 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7110 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7111 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7112 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7113 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7114 |
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
|
7115 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7116 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7117 |
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
|
7118 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7119 |
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
|
7120 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7121 |
string := s1, s2. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7122 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7123 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7124 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7125 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 7126 |
! ! |
7127 |
||
7128 |
!EditTextView::PasteString methodsFor:'execution'! |
|
7129 |
||
3160 | 7130 |
executeIn:editor |
2952 | 7131 |
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
|
7132 |
editor paste:string. |
2952 | 7133 |
selected ~~ true ifTrue:[ |
3160 | 7134 |
editor unselect |
2952 | 7135 |
]. |
7136 |
! ! |
|
7137 |
||
7138 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
7139 |
||
3235 | 7140 |
col |
7141 |
^ col |
|
7142 |
! |
|
7143 |
||
7144 |
col1 |
|
7145 |
^ col |
|
7146 |
! |
|
7147 |
||
7148 |
col2 |
|
7149 |
^ col |
|
7150 |
! |
|
7151 |
||
7152 |
line |
|
7153 |
^ line |
|
7154 |
! |
|
7155 |
||
3160 | 7156 |
line:lineArg col:colArg character:characterArg |
2952 | 7157 |
line := lineArg. |
7158 |
col := colArg. |
|
7159 |
character := characterArg. |
|
7160 |
! ! |
|
7161 |
||
7162 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
7163 |
||
3160 | 7164 |
executeIn:editor |
7165 |
editor |
|
7166 |
replace:character |
|
7167 |
atLine:line |
|
7168 |
col:col. |
|
2952 | 7169 |
editor cursorLine:line col:col. |
105 | 7170 |
! ! |
7171 |
||
3235 | 7172 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
7173 |
||
7174 |
characters |
|
7175 |
^ characters |
|
7176 |
! |
|
7177 |
||
7178 |
col1 |
|
7179 |
^ col1 |
|
7180 |
! |
|
7181 |
||
7182 |
col2 |
|
7183 |
^ col2 |
|
7184 |
! |
|
7185 |
||
7186 |
line |
|
7187 |
^ line |
|
7188 |
! |
|
7189 |
||
7190 |
line:lineArg col:colArg character:characterArg |
|
7191 |
line := lineArg. |
|
7192 |
col1 := col2 := colArg. |
|
7193 |
characters := characterArg asString. |
|
7194 |
! |
|
7195 |
||
7196 |
line:lineArg col:colArg characters:charactersArg |
|
7197 |
line := lineArg. |
|
7198 |
col1 := colArg. |
|
7199 |
characters := charactersArg asString. |
|
7200 |
col2 := col1 + charactersArg size - 1 |
|
7201 |
! ! |
|
7202 |
||
7203 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
7204 |
||
7205 |
canCombineWithNext:anotherAction |
|
7206 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
7207 |
! |
|
7208 |
||
7209 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
7210 |
"I will combine only if we both are single character deletes, |
|
7211 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
7212 |
(i.e. single-character typing)" |
|
7213 |
||
7214 |
previousReplaceAction line == line ifTrue:[ |
|
7215 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
|
7216 |
^ true |
|
7217 |
]. |
|
7218 |
]. |
|
7219 |
||
7220 |
^ false |
|
7221 |
! |
|
7222 |
||
7223 |
combineWithNext:nextReplaceAction |
|
7224 |
self assert:(line == nextReplaceAction line). |
|
7225 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
7226 |
||
7227 |
col2 := nextReplaceAction col2. |
|
7228 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
7229 |
characters := characters , nextReplaceAction characters. |
|
7230 |
! ! |
|
7231 |
||
7232 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
7233 |
||
7234 |
executeIn:editor |
|
7235 |
editor |
|
7236 |
replaceString:characters |
|
7237 |
atLine:line |
|
7238 |
col:col1. |
|
7239 |
editor cursorLine:line col:col1. |
|
7240 |
! ! |
|
7241 |
||
3131 | 7242 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
7243 |
||
7244 |
text:something |
|
7245 |
text := something. |
|
7246 |
! ! |
|
7247 |
||
7248 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
7249 |
||
3160 | 7250 |
executeIn:editor |
3131 | 7251 |
editor contents:text |
7252 |
! ! |
|
7253 |
||
3130 | 7254 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
7255 |
||
3160 | 7256 |
line:lineArg string:stringArg |
3130 | 7257 |
line := lineArg. |
7258 |
text := stringArg. |
|
7259 |
! ! |
|
7260 |
||
7261 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
7262 |
||
3160 | 7263 |
executeIn:editor |
3130 | 7264 |
editor list at:line put:text. |
7265 |
editor invalidateLine:line |
|
7266 |
! ! |
|
7267 |
||
3402 | 7268 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
7269 |
||
7270 |
line:lineArg lines:lineCollectionArg |
|
7271 |
line := lineArg. |
|
7272 |
text := lineCollectionArg. |
|
7273 |
||
7274 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
7275 |
! ! |
|
7276 |
||
7277 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
7278 |
||
7279 |
executeIn:editor |
|
7280 |
|lnr| |
|
7281 |
||
7282 |
lnr := line. |
|
7283 |
text do:[:eachLine | |
|
7284 |
editor list at:lnr put:eachLine. |
|
7285 |
editor invalidateLine:lnr. |
|
7286 |
lnr := lnr + 1. |
|
7287 |
]. |
|
7288 |
||
7289 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
7290 |
! ! |
|
7291 |
||
865 | 7292 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7294 |
version |
3631
7800380ae0dc
cannot send asStringWithoutFinalCR to non-stringcollections
Claus Gittinger <cg@exept.de>
parents:
3623
diff
changeset
|
7295 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.433 2008-06-13 09:01:06 cg Exp $' |
0 | 7296 |
! ! |