author | Claus Gittinger <cg@exept.de> |
Wed, 27 Nov 2013 13:41:16 +0100 | |
changeset 4827 | 243957c13134 |
parent 4826 | ee17c37a8012 |
child 4829 | 1073616fcbab |
child 4856 | 26db89c55340 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
0 | 14 |
TextView subclass:#EditTextView |
4826 | 15 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
16 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
17 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
18 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
19 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
20 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
21 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
22 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
23 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
24 |
undoSupport lastStringFromReplaceForNextSearch |
|
25 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
26 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
27 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
28 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
29 |
poolDictionaries:'' |
|
30 |
category:'Views-Text' |
|
0 | 31 |
! |
32 |
||
2952 | 33 |
Object subclass:#EditAction |
4826 | 34 |
instanceVariableNames:'userFriendlyInfo' |
35 |
classVariableNames:'' |
|
36 |
poolDictionaries:'' |
|
37 |
privateIn:EditTextView |
|
2952 | 38 |
! |
39 |
||
40 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 41 |
instanceVariableNames:'line1 col1 line2 col2' |
42 |
classVariableNames:'' |
|
43 |
poolDictionaries:'' |
|
44 |
privateIn:EditTextView |
|
2952 | 45 |
! |
46 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
47 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 48 |
instanceVariableNames:'line col1 col2' |
49 |
classVariableNames:'' |
|
50 |
poolDictionaries:'' |
|
51 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
53 |
|
3235 | 54 |
Object subclass:#EditMode |
4826 | 55 |
instanceVariableNames:'' |
56 |
classVariableNames:'' |
|
57 |
poolDictionaries:'' |
|
58 |
privateIn:EditTextView |
|
3235 | 59 |
! |
60 |
||
61 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 62 |
instanceVariableNames:'' |
63 |
classVariableNames:'' |
|
64 |
poolDictionaries:'' |
|
65 |
privateIn:EditTextView::EditMode |
|
3235 | 66 |
! |
67 |
||
68 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 69 |
instanceVariableNames:'' |
70 |
classVariableNames:'' |
|
71 |
poolDictionaries:'' |
|
72 |
privateIn:EditTextView::EditMode |
|
3235 | 73 |
! |
74 |
||
75 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 76 |
instanceVariableNames:'' |
77 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
78 |
poolDictionaries:'' |
|
79 |
privateIn:EditTextView::EditMode |
|
3235 | 80 |
! |
81 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
82 |
Query subclass:#ExecutingMacroQuery |
4826 | 83 |
instanceVariableNames:'' |
84 |
classVariableNames:'' |
|
85 |
poolDictionaries:'' |
|
86 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
87 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
88 |
|
4048 | 89 |
Object subclass:#LastReplacementInfo |
4826 | 90 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
91 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
92 |
classVariableNames:'' |
|
93 |
poolDictionaries:'' |
|
94 |
privateIn:EditTextView |
|
4048 | 95 |
! |
96 |
||
2952 | 97 |
EditTextView::EditAction subclass:#PasteString |
4826 | 98 |
instanceVariableNames:'line col string selected' |
99 |
classVariableNames:'' |
|
100 |
poolDictionaries:'' |
|
101 |
privateIn:EditTextView |
|
2952 | 102 |
! |
103 |
||
104 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 105 |
instanceVariableNames:'line col character' |
106 |
classVariableNames:'' |
|
107 |
poolDictionaries:'' |
|
108 |
privateIn:EditTextView |
|
2952 | 109 |
! |
110 |
||
3235 | 111 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 112 |
instanceVariableNames:'line col1 col2 characters' |
113 |
classVariableNames:'' |
|
114 |
poolDictionaries:'' |
|
115 |
privateIn:EditTextView |
|
3235 | 116 |
! |
117 |
||
3131 | 118 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 119 |
instanceVariableNames:'text' |
120 |
classVariableNames:'' |
|
121 |
poolDictionaries:'' |
|
122 |
privateIn:EditTextView |
|
3131 | 123 |
! |
124 |
||
3130 | 125 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 126 |
instanceVariableNames:'line text' |
127 |
classVariableNames:'' |
|
128 |
poolDictionaries:'' |
|
129 |
privateIn:EditTextView |
|
3130 | 130 |
! |
131 |
||
3402 | 132 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 133 |
instanceVariableNames:'line text' |
134 |
classVariableNames:'' |
|
135 |
poolDictionaries:'' |
|
136 |
privateIn:EditTextView |
|
3402 | 137 |
! |
138 |
||
865 | 139 |
!EditTextView class methodsFor:'documentation'! |
0 | 140 |
|
33 | 141 |
copyright |
142 |
" |
|
143 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 144 |
All Rights Reserved |
33 | 145 |
|
146 |
This software is furnished under a license and may be used |
|
147 |
only in accordance with the terms of that license and with the |
|
148 |
inclusion of the above copyright notice. This software may not |
|
149 |
be provided or otherwise made available to, or used by, any |
|
150 |
other person. No title to or ownership of the software is |
|
151 |
hereby transferred. |
|
152 |
" |
|
153 |
! |
|
154 |
||
0 | 155 |
documentation |
156 |
" |
|
157 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 158 |
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
|
159 |
acceptAction to be performed for accept |
125 | 160 |
|
161 |
If used with a model, this is informed by sending it a changeMsg with |
|
162 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
163 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 164 |
|
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
|
165 |
Please read the historic notice in the ListView class. |
0 | 166 |
|
586 | 167 |
[Instance variables:] |
0 | 168 |
|
4010 | 169 |
cursorLine <Number> line where cursor sits (1..) |
170 |
||
171 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
172 |
||
173 |
cursorCol <Number> col where cursor sits (1..) |
|
174 |
||
175 |
cursorShown <Boolean> true, if cursor is currently shown |
|
176 |
||
177 |
readOnly <Boolean> true, if text may not be edited |
|
178 |
||
179 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
180 |
cleared on accept. |
|
181 |
||
182 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
183 |
||
184 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
185 |
||
186 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
187 |
if it returns true, the modification will be done anyway. |
|
188 |
if it returns anything else, the modification is not done. |
|
189 |
||
190 |
cursorFgColor <Color> color used for cursor drawing |
|
191 |
cursorBgColor <Color> color used for cursor drawing |
|
192 |
||
193 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 194 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 195 |
(vertical bar at insertion point) |
4721 | 196 |
and #caret (caret below insertion-point). |
197 |
see cursorType: for an up-to-date list. |
|
4010 | 198 |
|
199 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
200 |
nil means: hide the cursor. |
|
201 |
||
202 |
undoAction <Block> block which undoes last cut, paste or replace |
|
203 |
(not yet fully implemented) |
|
204 |
||
205 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
206 |
this affects the next keyPress: if #paste it does not |
|
207 |
replace; otherwise it replaces the selection. |
|
208 |
||
209 |
lastCut <String> last cut or replaced string |
|
210 |
||
4053 | 211 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
212 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
213 |
lastReplacement is the string to replace lastStringToReplace |
|
214 |
||
215 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
216 |
(cleared after a new selection) |
|
4010 | 217 |
|
218 |
replacing <Boolean> true if entered characters replace last selection |
|
219 |
||
220 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
221 |
when entering one; this is the default. |
|
222 |
||
223 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
224 |
||
225 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
226 |
argument |
|
227 |
||
228 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
229 |
focus to the next field. For editTextViews, this is false |
|
230 |
by default (i.e. tabs can be entered into the text). |
|
231 |
For some subclasses (inputFields), this may be true. |
|
232 |
||
233 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
234 |
removed when editing. |
|
235 |
Default is true. |
|
236 |
||
237 |
wordWrap <Boolean> Currently not used. |
|
238 |
||
239 |
lockUpdates <Boolean> internal, private |
|
240 |
||
241 |
prevCursorState <Boolean> temporary, private |
|
242 |
||
243 |
cursorMovementWhenUpdating |
|
244 |
<Symbol> defines where the cursor is to be positioned if the |
|
245 |
model changes its value by some outside activity |
|
246 |
(i.e. not by user input into the field). |
|
247 |
Can be one of: |
|
248 |
#keep / nil -> stay where it was |
|
249 |
#endOfText -> cursor to the end |
|
250 |
#endOfLine -> stay in the line, but move to end |
|
251 |
#beginOfText -> cursor to the beginning |
|
252 |
#beginOfLine -> stay in the line, but move to begin |
|
253 |
The default is #beginOfText |
|
254 |
||
255 |
||
256 |
||
257 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 258 |
|
259 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
260 |
userPreference values: |
4010 | 261 |
userPreferences.st80EditMode |
262 |
<Boolean> if true, cursor positioning is |
|
263 |
done as in vi or ST80; i.e. |
|
264 |
wysiwyg mode is somewhat relaxed, |
|
265 |
in that the cursor cannot be |
|
266 |
positioned behind a lines end. |
|
267 |
This is not yet completely implemented. |
|
33 | 268 |
used globals: |
269 |
||
4010 | 270 |
DeleteHistory <Text> last 1000 lines of deleted text |
271 |
(but only if this variable exists already) |
|
586 | 272 |
|
273 |
[styleSheet parameters:] |
|
121 | 274 |
|
4010 | 275 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
276 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
277 |
textCursorNoFocusForegroundColor |
|
278 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
279 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 280 |
|
281 |
[author:] |
|
4010 | 282 |
Claus Gittinger |
586 | 283 |
|
284 |
[see also:] |
|
4010 | 285 |
CodeView Workspace TextView ListView |
286 |
EditField |
|
0 | 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 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
basic setup: |
4823 | 295 |
[exBegin] |
296 |
|top textView| |
|
297 |
||
298 |
top := StandardSystemView new. |
|
299 |
top extent:300@200. |
|
300 |
||
301 |
textView := EditTextView new. |
|
302 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
303 |
top addSubView:textView. |
|
304 |
||
305 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
306 |
||
307 |
top open. |
|
308 |
[exEnd] |
|
594 | 309 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
310 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
311 |
with vertical scrollbar: |
4823 | 312 |
[exBegin] |
313 |
|top scrollView textView| |
|
314 |
||
315 |
top := StandardSystemView new. |
|
316 |
top extent:300@200. |
|
317 |
||
318 |
scrollView := ScrollableView for:EditTextView. |
|
319 |
textView := scrollView scrolledView. |
|
320 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
321 |
top addSubView:scrollView. |
|
322 |
||
323 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
324 |
||
325 |
top open. |
|
326 |
[exEnd] |
|
594 | 327 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
328 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
329 |
with horizontal & vertical scrollbars: |
4823 | 330 |
[exBegin] |
331 |
|top scrollView textView| |
|
332 |
||
333 |
top := StandardSystemView new. |
|
334 |
top extent:300@200. |
|
335 |
||
336 |
scrollView := HVScrollableView for:EditTextView. |
|
337 |
textView := scrollView scrolledView. |
|
338 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
339 |
top addSubView:scrollView. |
|
340 |
||
341 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
342 |
||
343 |
top open. |
|
344 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
346 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
347 |
set the action for accept: |
4823 | 348 |
[exBegin] |
349 |
|top textView| |
|
350 |
||
351 |
top := StandardSystemView new. |
|
352 |
top extent:300@200. |
|
353 |
||
354 |
textView := EditTextView new. |
|
355 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
356 |
top addSubView:textView. |
|
357 |
||
358 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
359 |
textView acceptAction:[:contents | |
|
360 |
Transcript showCR:'will not overwrite the file with:'. |
|
361 |
Transcript showCR:contents asString |
|
362 |
]. |
|
363 |
top open. |
|
364 |
[exEnd] |
|
594 | 365 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
366 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
367 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
368 |
non-string (text) items: |
4823 | 369 |
[exBegin] |
370 |
|top textView list| |
|
371 |
||
372 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
373 |
1 to:list size by:2 do:[:nr | |
|
374 |
list at:nr put:(Text string:(list at:nr) |
|
375 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
376 |
]. |
|
377 |
||
378 |
top := StandardSystemView new. |
|
379 |
top extent:300@200. |
|
380 |
||
381 |
textView := EditTextView new. |
|
382 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
383 |
top addSubView:textView. |
|
384 |
||
385 |
textView contents:list. |
|
386 |
top open. |
|
387 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
388 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
389 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
390 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
391 |
MVC operation: |
594 | 392 |
(the examples model here is a plug simulating a real model; |
393 |
real world applications would not use a plug ..) |
|
4823 | 394 |
[exBegin] |
395 |
|top textView model| |
|
396 |
||
397 |
model := Plug new. |
|
398 |
model respondTo:#accepted: |
|
399 |
with:[:newContents | |
|
400 |
Transcript showCR:'will not overwrite the file with:'. |
|
401 |
Transcript showCR:newContents asString |
|
402 |
]. |
|
403 |
model respondTo:#getList |
|
404 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
405 |
||
406 |
||
407 |
top := StandardSystemView new. |
|
408 |
top extent:300@200. |
|
409 |
||
410 |
textView := EditTextView new. |
|
411 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
412 |
top addSubView:textView. |
|
413 |
||
414 |
textView listMessage:#getList; |
|
415 |
model:model; |
|
416 |
changeMessage:#accepted:; |
|
417 |
aspect:#list. |
|
418 |
top open. |
|
419 |
[exEnd] |
|
594 | 420 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
421 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
422 |
two textViews on the same model: |
4823 | 423 |
[exBegin] |
424 |
|top1 textView1 top2 textView2 model currentContents| |
|
425 |
||
426 |
model := Plug new. |
|
427 |
model respondTo:#accepted: |
|
428 |
with:[:newContents | |
|
429 |
Transcript showCR:'accepted:'. |
|
430 |
Transcript showCR:newContents asString. |
|
431 |
currentContents := newContents. |
|
432 |
model changed:#contents |
|
433 |
]. |
|
434 |
model respondTo:#getList |
|
435 |
with:[Transcript showCR:'query'. |
|
436 |
currentContents]. |
|
437 |
||
438 |
||
439 |
top1 := StandardSystemView new. |
|
440 |
top1 extent:300@200. |
|
441 |
||
442 |
textView1 := EditTextView new. |
|
443 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
444 |
top1 addSubView:textView1. |
|
445 |
||
446 |
textView1 listMessage:#getList; |
|
447 |
model:model; |
|
448 |
aspect:#contents; |
|
449 |
changeMessage:#accepted:. |
|
450 |
top1 open. |
|
451 |
||
452 |
top2 := StandardSystemView new. |
|
453 |
top2 extent:300@200. |
|
454 |
||
455 |
textView2 := EditTextView new. |
|
456 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
457 |
top2 addSubView:textView2. |
|
458 |
||
459 |
textView2 listMessage:#getList; |
|
460 |
model:model; |
|
461 |
aspect:#contents; |
|
462 |
changeMessage:#accepted:. |
|
463 |
top2 open. |
|
464 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
465 |
" |
0 | 466 |
! ! |
467 |
||
865 | 468 |
!EditTextView class methodsFor:'defaults'! |
59 | 469 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
470 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
471 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
472 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
473 |
"Created: / 26-09-2013 / 17:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
474 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
475 |
|
1419 | 476 |
st80Mode |
477 |
"return true, if the st80 editing mode is turned on. |
|
478 |
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
|
479 |
beyond the end of a line or the end of the text." |
1419 | 480 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
481 |
^ UserPreferences current st80EditMode |
1419 | 482 |
|
483 |
" |
|
484 |
EditTextView st80Mode:true |
|
485 |
EditTextView st80Mode:false |
|
486 |
" |
|
487 |
||
488 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
489 |
! |
|
490 |
||
491 |
st80Mode:aBoolean |
|
492 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 493 |
beyond the end of a line or the last line" |
1419 | 494 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
495 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 496 |
|
497 |
" |
|
498 |
EditTextView st80Mode:true |
|
499 |
EditTextView st80Mode:false |
|
500 |
" |
|
501 |
||
502 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
503 |
! |
|
504 |
||
59 | 505 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
506 |
"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
|
507 |
|
1390 | 508 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 509 |
#'textCursor.noFocusForegroundColor' |
510 |
#'textCursor.type' |
|
511 |
#'textCursor.typeNoFocus' |
|
512 |
#'editText.st80Mode')> |
|
1355 | 513 |
|
514 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
515 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
516 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
517 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
518 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
519 |
|
1419 | 520 |
" |
521 |
self updateStyleCache |
|
522 |
" |
|
523 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
524 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 525 |
! ! |
526 |
||
3431 | 527 |
!EditTextView class methodsFor:'specs'! |
528 |
||
529 |
searchReplaceDialogSpec |
|
530 |
"This resource specification was automatically generated |
|
531 |
by the UIPainter of ST/X." |
|
532 |
||
533 |
"Do not manually edit this!! If it is corrupted, |
|
534 |
the UIPainter may not be able to read the specification." |
|
535 |
||
536 |
" |
|
537 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
538 |
" |
|
539 |
||
540 |
<resource: #canvas> |
|
541 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
542 |
^ |
3431 | 543 |
#(FullSpec |
4823 | 544 |
name: searchReplaceDialogSpec |
545 |
window: |
|
3431 | 546 |
(WindowSpec |
4823 | 547 |
label: 'String Search and Replace' |
548 |
name: 'String Search and Replace' |
|
549 |
min: (Point 283 196) |
|
550 |
max: (Point 283 196) |
|
551 |
bounds: (Rectangle 0 0 279 192) |
|
552 |
) |
|
553 |
component: |
|
3431 | 554 |
(SpecCollection |
4823 | 555 |
collection: ( |
556 |
(LabelSpec |
|
557 |
label: 'Search Pattern:' |
|
558 |
name: 'label' |
|
559 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
560 |
level: 0 |
|
561 |
translateLabel: true |
|
562 |
adjust: left |
|
563 |
) |
|
564 |
(ComboBoxSpec |
|
565 |
name: 'patternComboBox' |
|
566 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
567 |
tabable: true |
|
568 |
model: searchPattern |
|
569 |
immediateAccept: false |
|
570 |
acceptOnLeave: true |
|
571 |
acceptOnReturn: true |
|
572 |
acceptOnTab: true |
|
573 |
acceptOnLostFocus: true |
|
574 |
acceptOnPointerLeave: false |
|
575 |
autoSelectInitialText: true |
|
576 |
comboList: patternList |
|
577 |
) |
|
578 |
(ComboBoxSpec |
|
579 |
name: 'replaceComboBox' |
|
580 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
581 |
tabable: true |
|
582 |
model: replacePattern |
|
583 |
immediateAccept: false |
|
584 |
acceptOnLeave: true |
|
585 |
acceptOnReturn: true |
|
586 |
acceptOnTab: true |
|
587 |
acceptOnLostFocus: true |
|
588 |
acceptOnPointerLeave: false |
|
589 |
autoSelectInitialText: true |
|
590 |
comboList: patternList |
|
591 |
) |
|
592 |
(CheckBoxSpec |
|
593 |
label: 'Ignore Case' |
|
594 |
name: 'ignoreCaseCheckBox' |
|
595 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
596 |
level: 0 |
|
597 |
tabable: true |
|
598 |
model: ignoreCase |
|
599 |
translateLabel: true |
|
600 |
) |
|
601 |
(VariableVerticalPanelSpec |
|
602 |
name: 'VariableVerticalPanel1' |
|
603 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
604 |
component: |
|
605 |
(SpecCollection |
|
606 |
collection: ( |
|
607 |
(HorizontalPanelViewSpec |
|
608 |
name: 'HorizontalPanel1' |
|
609 |
level: 0 |
|
610 |
horizontalLayout: fitSpace |
|
611 |
verticalLayout: center |
|
612 |
horizontalSpace: 3 |
|
613 |
verticalSpace: 3 |
|
614 |
ignoreInvisibleComponents: true |
|
615 |
reverseOrderIfOKAtLeft: true |
|
616 |
component: |
|
617 |
(SpecCollection |
|
618 |
collection: ( |
|
619 |
(ActionButtonSpec |
|
620 |
label: 'Replace' |
|
621 |
name: 'replaceButton' |
|
622 |
level: 2 |
|
623 |
translateLabel: true |
|
624 |
tabable: true |
|
625 |
model: replaceAction |
|
626 |
extent: (Point 134 21) |
|
627 |
) |
|
628 |
(ActionButtonSpec |
|
629 |
label: 'Replace All' |
|
630 |
name: 'replaceAllButton' |
|
631 |
level: 2 |
|
632 |
borderWidth: 1 |
|
633 |
translateLabel: true |
|
634 |
tabable: true |
|
635 |
model: replaceAllAction |
|
636 |
extent: (Point 134 21) |
|
637 |
) |
|
638 |
) |
|
639 |
||
640 |
) |
|
641 |
) |
|
642 |
(HorizontalPanelViewSpec |
|
643 |
name: 'horizontalPanelView' |
|
644 |
level: 0 |
|
645 |
horizontalLayout: fitSpace |
|
646 |
verticalLayout: center |
|
647 |
horizontalSpace: 3 |
|
648 |
verticalSpace: 3 |
|
649 |
ignoreInvisibleComponents: true |
|
650 |
reverseOrderIfOKAtLeft: true |
|
651 |
component: |
|
652 |
(SpecCollection |
|
653 |
collection: ( |
|
654 |
(ActionButtonSpec |
|
655 |
label: 'Cancel' |
|
656 |
name: 'cancelButton' |
|
657 |
level: 2 |
|
658 |
translateLabel: true |
|
659 |
tabable: true |
|
660 |
model: cancel |
|
661 |
extent: (Point 88 21) |
|
662 |
) |
|
663 |
(ActionButtonSpec |
|
664 |
label: 'Prev' |
|
665 |
name: 'prevButton' |
|
666 |
level: 2 |
|
667 |
translateLabel: true |
|
668 |
tabable: true |
|
669 |
model: prevAction |
|
670 |
extent: (Point 89 21) |
|
671 |
) |
|
672 |
(ActionButtonSpec |
|
673 |
label: 'Next' |
|
674 |
name: 'nextButton' |
|
675 |
level: 2 |
|
676 |
borderWidth: 1 |
|
677 |
translateLabel: true |
|
678 |
tabable: true |
|
679 |
model: nextAction |
|
680 |
isDefault: true |
|
681 |
extent: (Point 88 21) |
|
682 |
) |
|
683 |
) |
|
684 |
||
685 |
) |
|
686 |
) |
|
687 |
) |
|
688 |
||
689 |
) |
|
690 |
handles: (Any 0.5 1.0) |
|
691 |
) |
|
692 |
(LabelSpec |
|
693 |
label: 'Replace By:' |
|
694 |
name: 'ReplaceLabel' |
|
695 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
696 |
level: 0 |
|
697 |
translateLabel: true |
|
698 |
adjust: left |
|
699 |
) |
|
700 |
) |
|
701 |
||
702 |
) |
|
3431 | 703 |
) |
704 |
||
705 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
706 |
! ! |
|
707 |
||
2744 | 708 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
709 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
710 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
711 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
712 |
|
2019 | 713 |
"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
|
714 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
715 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
716 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
717 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
718 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
719 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
720 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
721 |
|
1390 | 722 |
cutSelection |
723 |
self cut |
|
724 |
||
725 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
726 |
! |
|
727 |
||
1590 | 728 |
deselect |
729 |
"remove the selection" |
|
730 |
||
731 |
^ self unselect |
|
732 |
||
733 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
734 |
! |
|
735 |
||
2101 | 736 |
enabled:aBoolean |
737 |
||
738 |
self readOnly:aBoolean not |
|
739 |
||
740 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
741 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
742 |
! |
|
743 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
744 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
745 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
746 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
747 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
748 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
749 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
750 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
751 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
752 |
"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
|
753 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
754 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
755 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
756 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
757 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
758 |
col < 1 ifTrue:[ |
4823 | 759 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
760 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
761 |
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
|
762 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
763 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
764 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
765 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
766 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
767 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
768 |
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
|
769 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
770 |
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
|
771 |
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
|
772 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
773 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
774 |
"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
|
775 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
776 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
777 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
778 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
779 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
780 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
781 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
782 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 783 |
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
|
784 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
785 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 786 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
787 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
788 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
789 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
790 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
791 |
v insertAndSelect:'<- hello there' at:5. |
125 | 792 |
" |
1390 | 793 |
! |
794 |
||
795 |
pasteSelection |
|
796 |
self paste |
|
797 |
||
798 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 799 |
! |
800 |
||
801 |
replaceSelectionWith:aString |
|
802 |
^ self replaceSelectionBy:aString |
|
803 |
||
804 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
805 |
! |
|
806 |
||
807 |
selectAt:pos |
|
808 |
"move the cursor before cursorPosition." |
|
809 |
||
810 |
self cursorToCharacterPosition:pos |
|
811 |
||
812 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
813 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
814 |
! |
|
815 |
||
2101 | 816 |
textHasChanged |
817 |
^ self modified |
|
818 |
||
819 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
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 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
822 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
823 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
824 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
825 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
826 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
827 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
828 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
829 |
|
4585 | 830 |
!EditTextView methodsFor:'accessing'! |
831 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
832 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
833 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
834 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
835 |
codeAspect := codeAspectHolder value. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
836 |
codeAspect notNil ifTrue:[^codeAspect]. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
837 |
self editedMethod notNil ifTrue:[^SyntaxHighlighter codeAspectMethod]. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
838 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
839 |
"/ Applications should set it explictly, however, to make it behavinh like |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
840 |
"/ CodeView2, I kept fetching code here for now. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
841 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
842 |
ifTrue:[app codeAspect] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
843 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
844 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
845 |
"Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
846 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
847 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
848 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
849 |
codeAspectHolder value: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
850 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
851 |
"Created: / 27-09-2013 / 09:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
852 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
853 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
854 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
855 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
856 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
857 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
858 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
859 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
860 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
861 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
862 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
863 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
864 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
865 |
"Created: / 26-09-2013 / 17:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
866 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
867 |
|
4609 | 868 |
editedClass |
869 |
|cm| |
|
870 |
||
871 |
cm := self editedMethodOrClass. |
|
872 |
cm isBehavior ifTrue:[^ cm]. |
|
873 |
cm isMethod ifTrue:[^ cm mclass]. |
|
874 |
^ nil |
|
875 |
! |
|
876 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
877 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
878 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
879 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
880 |
"Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
881 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
882 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
883 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
884 |
"Sets the edited language. Only defined here to make it polymorph with Workspace" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
885 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
886 |
"Created: / 27-09-2013 / 10:15:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
887 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
888 |
|
4609 | 889 |
editedMethod |
890 |
|cm| |
|
891 |
||
892 |
cm := self editedMethodOrClass. |
|
893 |
cm isMethod ifTrue:[^ cm]. |
|
894 |
cm isBehavior ifTrue:[^ nil]. |
|
895 |
^ nil |
|
896 |
! |
|
897 |
||
898 |
editedMethodOrClass |
|
899 |
^ nil |
|
900 |
! |
|
901 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
902 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
903 |
"Sets the edited method or class. Only defined here to make it polymorph with Workspace" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
904 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
"Created: / 27-09-2013 / 10:10:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
906 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
|
4585 | 908 |
hasSelectionOrTextInCursorLine |
909 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
910 |
! |
|
911 |
||
4589 | 912 |
selectionOrTextOfCursorLine |
913 |
^ self selectionOrTextOfCursorLine:true |
|
914 |
! |
|
915 |
||
4585 | 916 |
selectionOrTextOfCursorLine:doSelect |
917 |
|sel lNr line| |
|
918 |
||
919 |
sel := self selectionAsString. |
|
920 |
sel notNil ifTrue:[^ sel]. |
|
921 |
||
922 |
lNr := self cursorLine. |
|
923 |
line := self listAt:lNr. |
|
924 |
line notEmptyOrNil ifTrue:[ |
|
925 |
doSelect ifTrue:[ |
|
926 |
self selectLine:lNr. |
|
927 |
]. |
|
928 |
^ line |
|
929 |
]. |
|
930 |
||
931 |
^ nil |
|
932 |
! ! |
|
933 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
934 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
935 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
936 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
937 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
938 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
939 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
940 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
941 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
942 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
943 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
944 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
945 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
946 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
947 |
|
2792 | 948 |
acceptChannel |
949 |
"return the valueHolder holding true if text was accepted. |
|
950 |
By placing a true into this channel, an accept can also be forced." |
|
951 |
||
952 |
^ acceptChannel |
|
953 |
||
954 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
955 |
! |
|
956 |
||
957 |
acceptChannel:aValueHolder |
|
958 |
"set the valueHolder holding true if text was accepted. |
|
959 |
By placing a true into this channel, an accept can also be forced." |
|
960 |
||
961 |
|prev| |
|
962 |
||
963 |
prev := acceptChannel. |
|
964 |
acceptChannel := aValueHolder. |
|
965 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
966 |
||
967 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
968 |
! |
|
969 |
||
1108 | 970 |
acceptEnabled:aBoolean |
971 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
972 |
||
973 |
acceptEnabled := aBoolean |
|
974 |
||
975 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
976 |
! |
|
977 |
||
2792 | 978 |
accepted |
979 |
"return true if text was accepted" |
|
980 |
||
981 |
^ acceptChannel value |
|
982 |
||
983 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
984 |
! |
|
985 |
||
986 |
accepted:aBoolean |
|
987 |
"set/clear the accepted flag. |
|
988 |
This may force my current contents to be placed into my model." |
|
989 |
||
990 |
acceptChannel value:aBoolean. |
|
991 |
||
992 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
993 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
994 |
! |
|
995 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
996 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
997 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
998 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
999 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1000 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1001 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1002 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1003 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1004 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1005 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1006 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1007 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1008 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1009 |
|
2774 | 1010 |
cursorMovementWhenUpdating |
3160 | 1011 |
"return what is be done with the cursor, |
2774 | 1012 |
when I get a new text (via the model or the #contents/#list) |
1013 |
Allowed arguments are: |
|
4823 | 1014 |
#keep / nil -> stay where it was |
1015 |
#endOfText -> position cursor to the end |
|
1016 |
#beginOfText -> position cursor to the beginning |
|
1017 |
#endOfLine -> position cursor to the current lines end |
|
1018 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1019 |
The default is #beginOfText. |
1020 |
This may be useful for fields which get new values assigned from |
|
1021 |
the program (i.e. not from the user)" |
|
1022 |
||
1023 |
^ cursorMovementWhenUpdating |
|
1024 |
||
1025 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1026 |
! |
|
1027 |
||
2133 | 1028 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1029 |
"define what should be done with the cursor, |
2133 | 1030 |
when I get a new text (via the model or the #contents/#list) |
1031 |
Allowed arguments are: |
|
4823 | 1032 |
#keep / nil -> stay where it was |
1033 |
#endOfText -> position cursor to the end |
|
1034 |
#beginOfText -> position cursor to the beginning |
|
1035 |
#endOfLine -> position cursor to the current lines end |
|
1036 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1037 |
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
|
1038 |
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
|
1039 |
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
|
1040 |
|
2133 | 1041 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1042 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1043 |
"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
|
1044 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1045 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1046 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1047 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1048 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1049 |
|
2438 | 1050 |
dontReplaceSelectionOnInput |
4742 | 1051 |
"remember that the current selection was created by a paste operation |
1052 |
(as opposed to an explicit selection by the user). |
|
1053 |
This selection will not be replaced by followup user input, |
|
1054 |
so multiple pastes will be possible." |
|
1055 |
||
2438 | 1056 |
typeOfSelection := #paste |
1057 |
! |
|
1058 |
||
3235 | 1059 |
editModeHolder |
1060 |
^ editMode. |
|
1061 |
! |
|
1062 |
||
1063 |
editModeInsert |
|
1064 |
editMode value:EditMode insertMode |
|
1065 |
! |
|
1066 |
||
1067 |
editModeInsertAndSelect |
|
1068 |
editMode value:EditMode insertAndSelectMode |
|
1069 |
! |
|
1070 |
||
1071 |
editModeOverwrite |
|
1072 |
editMode value:EditMode overwriteMode |
|
1073 |
! |
|
1074 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1075 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1076 |
"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
|
1077 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1078 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1079 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1080 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1081 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1082 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1083 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1084 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1085 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1086 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1087 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1088 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1089 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1090 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1091 |
readOnly == true ifFalse:[ |
4823 | 1092 |
readOnly := true. |
1093 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1094 |
menu disableAll:#(cut paste replace indent) |
|
1095 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1096 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1097 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1098 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1099 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1100 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1101 |
insertMode:aBoolean |
3235 | 1102 |
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
|
1103 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1104 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1105 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1106 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1107 |
insertModeHolder |
3235 | 1108 |
^ BlockValue |
4823 | 1109 |
with:[:m | m isInsertMode] |
1110 |
argument:(editMode). |
|
3465 | 1111 |
|
1112 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1113 |
! |
1114 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1115 |
isInInsertMode |
3235 | 1116 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1117 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1118 |
|
2792 | 1119 |
isReadOnly |
1120 |
"return true, if the text is readonly." |
|
1121 |
||
1122 |
^ readOnly value |
|
1123 |
||
1124 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1125 |
! |
|
1126 |
||
2796 | 1127 |
modeLabelHolder |
1128 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1129 |
||
3160 | 1130 |
^ BlockValue |
4041 | 1131 |
with:[:e :l | |
1132 |
self isReadOnly ifTrue:[ |
|
1133 |
'' |
|
1134 |
] ifFalse:[ |
|
1135 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1136 |
ifFalse:[ e infoPrintString]]] |
|
1137 |
argument:(self editModeHolder) |
|
1138 |
argument:(self learnModeHolder). |
|
3465 | 1139 |
|
1140 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1141 |
! |
1142 |
||
2792 | 1143 |
modified |
1144 |
"return true if text was modified" |
|
1145 |
||
1146 |
^ modifiedChannel value |
|
1147 |
! |
|
1148 |
||
1149 |
modified:aBoolean |
|
1150 |
"set/clear the modified flag" |
|
1151 |
||
1152 |
modifiedChannel value:aBoolean |
|
1153 |
||
1154 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1155 |
! |
|
1156 |
||
1157 |
modifiedChannel |
|
1158 |
"return the valueHolder holding true if text was modified" |
|
1159 |
||
1160 |
^ modifiedChannel |
|
1161 |
! |
|
1162 |
||
1163 |
modifiedChannel:aValueHolder |
|
1164 |
"set the valueHolder holding true if text was modified" |
|
1165 |
||
1166 |
|prev| |
|
1167 |
||
1168 |
prev := modifiedChannel. |
|
1169 |
modifiedChannel := aValueHolder. |
|
1170 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1171 |
||
1172 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1173 |
! |
|
1174 |
||
1175 |
readOnly |
|
1176 |
"make the text readonly. |
|
4664 | 1177 |
Obsolete because it is obfuscating (looks like a getter) |
1178 |
- use #readOnly:" |
|
2792 | 1179 |
|
1180 |
<resource:#obsolete> |
|
1181 |
||
1182 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1183 |
self readOnly:true. |
2792 | 1184 |
|
4664 | 1185 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1186 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1187 |
! |
1188 |
||
1189 |
readOnly:aBoolean |
|
1190 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1191 |
The argument may also be a valueHolder." |
|
1192 |
||
1193 |
readOnly := aBoolean |
|
1194 |
||
1195 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1196 |
! |
|
1197 |
||
4782 | 1198 |
reallyModifiedChannel |
1199 |
"return the valueHolder holding true if text was really modified. |
|
1200 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1201 |
||
1202 |
^ self modifiedChannel |
|
1203 |
! |
|
1204 |
||
4192 | 1205 |
st80Mode:aBoolean |
1206 |
"set/clear the st80Mode flag. |
|
1207 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
1208 |
if off, we have the Rand-editor behavior (random access)" |
|
1209 |
||
1210 |
st80Mode := aBoolean |
|
1211 |
||
1212 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1213 |
! |
|
1214 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1215 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1216 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1217 |
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
|
1218 |
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
|
1219 |
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
|
1220 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1221 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1222 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1223 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1224 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1225 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1226 |
"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
|
1227 |
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
|
1228 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1229 |
|
3160 | 1230 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1231 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1232 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1233 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1234 |
"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
|
1235 |
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
|
1236 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1237 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1238 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1239 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1241 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1242 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1243 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1244 |
"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
|
1245 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1246 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1247 |
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
|
1248 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1249 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1250 |
|
522 | 1251 |
at:lineNr put:aLine |
1252 |
(self at:lineNr) = aLine ifFalse:[ |
|
4823 | 1253 |
super at:lineNr put:aLine. |
1254 |
self textChanged |
|
522 | 1255 |
]. |
1256 |
! |
|
1257 |
||
4700 | 1258 |
characterAfterCursor |
1259 |
"return the character one after the cursor - space if beyond line." |
|
1260 |
||
1261 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1262 |
! |
|
1263 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1264 |
characterBeforeCursor |
4700 | 1265 |
"return the character to the left of cursor - space if beyond line, nil if at the beginning." |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1266 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1267 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1268 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1269 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1270 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1271 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1272 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1273 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1274 |
characterUnderCursor |
2707 | 1275 |
"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
|
1276 |
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
|
1277 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1278 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1279 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1280 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1281 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1282 |
contents |
2213 | 1283 |
"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
|
1284 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1285 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1286 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1287 |
^ super contents. |
3313 | 1288 |
|
1289 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1290 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1291 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1292 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1293 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1294 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1295 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1296 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1297 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1298 |
keepUndoHistory ifFalse:[ |
4823 | 1299 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1300 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1301 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1302 |
|
2213 | 1303 |
contentsAsString |
1304 |
"return the contents as a String (i.e. without emphasis)" |
|
1305 |
||
1306 |
list isNil ifTrue:[^ '']. |
|
1307 |
self removeTrailingBlankLines. |
|
1308 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1309 |
ifFalse:[each string] |
1310 |
]) asStringWithCRs |
|
2213 | 1311 |
! |
1312 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1313 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1314 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1315 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1317 |
^ cursorCol |
125 | 1318 |
! |
1319 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1320 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1321 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1322 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1323 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1324 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1325 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1326 |
cursorLine |
3160 | 1327 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1328 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1329 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1330 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1331 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1332 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1333 |
cursorLineHolder |
3160 | 1334 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1335 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1336 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1337 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1338 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1339 |
|
4713 | 1340 |
lineStringBeforeCursor |
1341 |
"return the line's string before the cursor. |
|
1342 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1343 |
||
1344 |
|line| |
|
1345 |
||
1346 |
line := ((self at:cursorLine) ? '') string. |
|
1347 |
line size < (cursorCol-1) ifTrue:[ |
|
1348 |
^ line paddedTo:(cursorCol-1) |
|
1349 |
]. |
|
1350 |
^ line copyTo:(cursorCol-1) |
|
1351 |
! |
|
1352 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1353 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1354 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1355 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1356 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1357 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1358 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1359 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1360 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1361 |
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
|
1362 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1363 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1364 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1365 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1366 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1367 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1368 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1369 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1370 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1371 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1372 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1373 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1374 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1375 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1376 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1377 |
^ 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
|
1378 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1379 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1380 |
"/ 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
|
1381 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
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 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1384 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1385 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1386 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1387 |
undoSupport resetHistories. |
2955 | 1388 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1389 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1390 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1391 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1392 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1393 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1394 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1395 |
|
4609 | 1396 |
!EditTextView methodsFor:'accessing-dimensions'! |
1397 |
||
1398 |
xOfCursor |
|
4728 | 1399 |
|point| |
1400 |
||
1401 |
cursorVisibleLine isNil ifTrue:[ |
|
1402 |
"/ take the end of the selection, if any |
|
1403 |
(selectionStartLine notNil |
|
1404 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1405 |
ifTrue:[ |
|
1406 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1407 |
]. |
|
1408 |
||
1409 |
"/ point := device |
|
1410 |
"/ translatePoint:(device pointerPosition) |
|
1411 |
"/ fromView:nil |
|
1412 |
"/ toView:self. |
|
1413 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1414 |
"/ ^ point x |
|
1415 |
"/ ]. |
|
1416 |
"/ ^ 0 |
|
1417 |
^ nil |
|
1418 |
]. |
|
4609 | 1419 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1420 |
||
1421 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1422 |
! ! |
|
4590 | 1423 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1424 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1425 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1426 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1427 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1428 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1429 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1430 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1431 |
wasOn := self hideCursor. |
1993 | 1432 |
cursorFgColor := color1 onDevice:device. |
1433 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1434 |
wasOn ifTrue:[self showCursor] |
1333 | 1435 |
! |
1436 |
||
1899 | 1437 |
cursorType |
1438 |
"return the style of the text cursor. |
|
4721 | 1439 |
Currently, supported are: #none |
1440 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1441 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1442 |
|
1443 |
^ cursorType |
|
1444 |
||
1445 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1446 |
! |
|
1447 |
||
1333 | 1448 |
cursorType:aCursorTypeSymbol |
1449 |
"set the style of the text cursor. |
|
4721 | 1450 |
Currently, supported are: #none |
1451 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1452 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1453 |
|
1334 | 1454 |
cursorType := aCursorTypeSymbol. |
1333 | 1455 |
|
1456 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1457 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1458 |
! |
1459 |
||
1899 | 1460 |
cursorTypeNoFocus |
1461 |
"return the style of the text cursor when the view has no focus. |
|
1462 |
If left unspecified, this is the same as the regular cursorType." |
|
1463 |
||
1464 |
^ cursorTypeNoFocus |
|
1465 |
||
1466 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1467 |
! |
|
1468 |
||
1334 | 1469 |
cursorTypeNoFocus:aCursorTypeSymbol |
1470 |
"set the style of the text cursor when the view has no focus. |
|
1471 |
If left unspecified, this is the same as the regular cursorType." |
|
1472 |
||
1473 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1474 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1475 |
|
4048 | 1476 |
!EditTextView methodsFor:'accessing-replace'! |
1477 |
||
4746 | 1478 |
lastReplacementInfo |
1479 |
^ lastReplacementInfo |
|
1480 |
! |
|
1481 |
||
4048 | 1482 |
lastStringToReplace: aString |
4818 | 1483 |
! |
1484 |
||
1485 |
previousReplacements |
|
1486 |
"accessor for the code completion" |
|
1487 |
||
1488 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1489 |
! ! |
1490 |
||
2119 | 1491 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1492 |
|
125 | 1493 |
accept |
1494 |
"accept the current contents by executing the accept-action and/or |
|
1495 |
changeMessage." |
|
1496 |
||
1108 | 1497 |
acceptEnabled == false ifTrue:[ |
3945 | 1498 |
self beep. |
1499 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1500 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1501 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1502 |
^ self |
1108 | 1503 |
]. |
1504 |
||
125 | 1505 |
lockUpdates := true. |
1013 | 1506 |
|
1507 |
"/ |
|
1508 |
"/ ST-80 way of doing it |
|
1509 |
"/ |
|
1510 |
model notNil ifTrue:[ |
|
4142 | 1511 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
3945 | 1512 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1513 |
]. |
1514 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1515 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1516 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1517 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1518 |
"/ 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
|
1519 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1520 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1521 |
acceptAction notNil ifTrue:[ |
3945 | 1522 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1523 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1524 |
|
125 | 1525 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1526 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1527 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1528 |
! |
1529 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1530 |
argForChangeMessage |
597 | 1531 |
"return the argument to be passed with the change notification. |
1532 |
Defined as separate method for easier subclassability." |
|
1533 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1534 |
^ self contents |
597 | 1535 |
|
1536 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1537 |
! |
1538 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1539 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1540 |
"get my contents from the model. |
597 | 1541 |
Redefined to ignore updates resulting from my own changes |
1542 |
(i.e. if lockUpdates is true)." |
|
121 | 1543 |
|
1544 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1545 |
ignore updates from my own change |
121 | 1546 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1547 |
lockUpdates ifTrue:[ |
4823 | 1548 |
lockUpdates := false. |
1549 |
^ self |
|
121 | 1550 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1551 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1552 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1553 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1554 |
"/ validate the cursorLine |
3160 | 1555 |
(cursorLine notNil |
2310 | 1556 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1557 |
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
|
1558 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1559 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1560 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1561 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1562 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1563 |
acceptChannel value == true ifTrue:[ |
1564 |
self accept. |
|
1565 |
]. |
|
1566 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1567 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1568 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1569 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1570 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1571 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1572 |
! ! |
1573 |
||
1574 |
!EditTextView methodsFor:'cursor handling'! |
|
1575 |
||
4820 | 1576 |
basicCursorReturn |
1577 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1578 |
||
1579 |
|wasOn| |
|
1580 |
||
1581 |
self checkForExistingLine:(cursorLine + 1). |
|
1582 |
cursorVisibleLine notNil ifTrue:[ |
|
1583 |
nFullLinesShown notNil ifTrue:[ |
|
1584 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1585 |
] |
|
1586 |
]. |
|
1587 |
||
1588 |
wasOn := self hideCursor. |
|
1589 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1590 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1591 |
||
1592 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1593 |
! |
|
1594 |
||
2406 | 1595 |
characterPositionOfCursor |
1596 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1597 |
! |
|
1598 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1599 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1600 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1601 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1602 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1603 |
! |
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 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1606 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1607 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1608 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
|
2822 | 1610 |
(cursorCol == newCol) ifTrue:[^ self]. |
1611 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1612 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1613 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1614 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1615 |
|
1616 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1617 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1618 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1620 |
"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
|
1621 |
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
|
1622 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1623 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1624 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1625 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1626 |
|
2707 | 1627 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1628 |
cursorLine > list size ifTrue:[ |
4595 | 1629 |
wasOn := self hideCursor. |
1630 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1631 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1632 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1633 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1634 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1635 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1636 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1637 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1638 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1639 |
"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
|
1640 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1641 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1642 |
|
4595 | 1643 |
(nL := cursorLine) isNil ifTrue:[ |
1644 |
nL := firstLineShown |
|
1645 |
]. |
|
1646 |
||
1647 |
self st80EditMode ifTrue:[ |
|
1648 |
nL == list size ifTrue:[ |
|
1649 |
wasOn := self hideCursor. |
|
1650 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1651 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1652 |
self beep. |
|
1653 |
^ self. |
|
1654 |
] |
|
1655 |
]. |
|
1656 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1657 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1658 |
wasOn := self hideCursor. |
1659 |
nv := cursorVisibleLine + n - 1. |
|
1660 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1661 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1662 |
]. |
|
1663 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1664 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
] ifFalse:[ |
4595 | 1666 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1667 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1668 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1669 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1670 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1671 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1672 |
|
121 | 1673 |
cursorHome |
597 | 1674 |
"scroll to top AND move cursor to first line of text." |
121 | 1675 |
|
674 | 1676 |
self cursorLine:1 col:1 |
1677 |
||
1678 |
"/ |wasOn| |
|
1679 |
"/ |
|
1680 |
"/ wasOn := self hideCursor. |
|
1681 |
"/ self scrollToTop. |
|
1682 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1683 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1684 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1685 |
||
1686 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1687 |
! |
1688 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1689 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1690 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1691 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1692 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1693 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1694 |
] ifFalse:[ |
4823 | 1695 |
cursorLine ~~ 1 ifTrue:[ |
1696 |
self st80EditMode ifTrue:[ |
|
1697 |
self cursorUp. |
|
1698 |
self cursorToEndOfLine. |
|
1699 |
] |
|
1700 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1701 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1702 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1703 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1704 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1705 |
|
4126 | 1706 |
cursorLeft:n |
1707 |
"move cursor to left" |
|
1708 |
||
1709 |
n timesRepeat:[ |
|
1710 |
self cursorLeft |
|
1711 |
]. |
|
1712 |
! |
|
1713 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1714 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1715 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1716 |
|
676 | 1717 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1718 |
|
2822 | 1719 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1720 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1721 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1722 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1723 |
|
672 | 1724 |
(col < 1) ifTrue:[ |
4823 | 1725 |
newCol := 1 |
672 | 1726 |
] ifFalse:[ |
4823 | 1727 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1728 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1729 |
self st80EditMode ifTrue:[ |
4823 | 1730 |
(cursorLine == list size |
1731 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1732 |
newCol := (self listAt:(list size)) size + 1. |
|
1733 |
] |
|
1419 | 1734 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1735 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1736 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1737 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1738 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1739 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1740 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1741 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1742 |
"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
|
1743 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1744 |
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
|
1745 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1746 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1747 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1748 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1749 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1750 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1751 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1752 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1753 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1754 |
"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
|
1755 |
|
4820 | 1756 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1757 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1759 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1760 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1761 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1762 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1763 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1764 |
self st80EditMode ifTrue:[ |
4823 | 1765 |
l := (self listAt:cursorLine). |
1766 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1767 |
cursorLine < list size ifTrue:[ |
|
1768 |
self cursorReturn. |
|
1769 |
]. |
|
1770 |
^ self |
|
1771 |
] |
|
3160 | 1772 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1773 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1774 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1775 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1776 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1777 |
|
4126 | 1778 |
cursorRight:n |
1779 |
"move cursor to right" |
|
1780 |
||
1781 |
n timesRepeat:[ |
|
1782 |
self cursorRight |
|
1783 |
]. |
|
1784 |
! |
|
1785 |
||
1833 | 1786 |
cursorShown:aBoolean |
1787 |
"change cursor visibility |
|
1788 |
return true if cursor was visible before." |
|
1789 |
||
1790 |
|oldState| |
|
1791 |
||
4494 | 1792 |
aBoolean == cursorShown ifTrue:[ |
1793 |
^ cursorShown |
|
1794 |
]. |
|
1795 |
||
1833 | 1796 |
oldState := cursorShown. |
1797 |
||
1798 |
aBoolean ifTrue:[ |
|
4494 | 1799 |
self drawCursor. |
1833 | 1800 |
] ifFalse:[ |
4494 | 1801 |
(cursorShown and:[shown]) ifTrue: [ |
1802 |
self undrawCursor. |
|
1803 |
]. |
|
1833 | 1804 |
]. |
1805 |
cursorShown := aBoolean. |
|
1806 |
||
1807 |
^ oldState |
|
1808 |
||
1809 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1810 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1811 |
! |
|
1812 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1813 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1814 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1815 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1816 |
self cursorCol:(self nextTabAfter:cursorCol). |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1819 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1820 |
"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
|
1821 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1822 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1823 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1824 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1825 |
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
|
1826 |
cursorCol > textStart ifTrue:[ |
4823 | 1827 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1828 |
] ifFalse:[ |
4823 | 1829 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1830 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1831 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1832 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1833 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1834 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1835 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1836 |
"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
|
1837 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1838 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1839 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1840 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1841 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1842 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1843 |
(newTop < 1) ifTrue:[ |
4823 | 1844 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1846 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1847 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1848 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1850 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1851 |
|
674 | 1852 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1853 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1854 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1855 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1856 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1857 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1858 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1859 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1860 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1861 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1862 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1863 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1864 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1865 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1866 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1867 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1868 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1869 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1870 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1871 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1872 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1873 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1874 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1875 |
cursorLine >= lineNr ifTrue:[ |
4823 | 1876 |
line := self listAt:cursorLine. |
1877 |
(line isEmptyOrNil) ifTrue:[ |
|
1878 |
^ self |
|
1879 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1880 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1881 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1882 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1883 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1884 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1885 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1886 |
(newTop < 1) ifTrue:[ |
4823 | 1887 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1888 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1889 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1890 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1891 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1892 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1893 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1894 |
|
674 | 1895 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1896 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1897 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1898 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1899 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1900 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1901 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1902 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1903 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1904 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1905 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1906 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1907 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1908 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1909 |
cursorToEndOfText |
4288 | 1910 |
"move cursor to the end of the text (behind the last character in last line)" |
1911 |
||
1912 |
|wasOn newTop lastLineLength pos| |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1913 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1914 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1915 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1916 |
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
|
1917 |
(newTop < 1) ifTrue:[ |
4288 | 1918 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1919 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1920 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1921 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1922 |
self setValidatedCursorLine:list size. |
4288 | 1923 |
lastLineLength := (self listAt:cursorLine) size. |
1924 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
1925 |
self setCursorCol:(self validateCursorCol:pos inLine:cursorLine). |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1926 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1927 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 1928 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
1929 |
"Modified: / 15-07-2011 / 20:14:43 / cg" |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1930 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1931 |
|
3310 | 1932 |
cursorToEndOfWord |
1933 |
"move the cursor to the end of the word" |
|
1934 |
||
1935 |
(cursorLine > list size) ifTrue:[^ self]. |
|
1936 |
||
1937 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 1938 |
:beginLine :beginCol :endLine :endCol :style | |
1939 |
||
1940 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 1941 |
] |
1942 |
||
1943 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
1944 |
! |
|
1945 |
||
131 | 1946 |
cursorToFirstVisibleLine |
1947 |
"place cursor into the first visible line; do not scroll." |
|
1948 |
||
1949 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1950 |
! |
|
1951 |
||
1952 |
cursorToLastVisibleLine |
|
1953 |
"place cursor into the first visible line; do not scroll." |
|
1954 |
||
1955 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1956 |
! |
|
1957 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1958 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1959 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1960 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1961 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1962 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1963 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1964 |
|
3890 | 1965 |
self |
4707 | 1966 |
wordAtLine:cursorLine col:cursorCol |
1967 |
do:[ |
|
3890 | 1968 |
:beginLine :beginCol :endLine :endCol :style | |
1969 |
||
1970 |
line := endLine. |
|
1971 |
col := endCol + 1. |
|
1972 |
searching := true. |
|
4707 | 1973 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 1974 |
self wordAtLine:line col:col do:[ |
1975 |
:beginLine :beginCol :endLine :endCol :style | |
|
1976 |
||
1977 |
(line > list size) ifTrue:[ |
|
1978 |
"break out" |
|
1979 |
searching := false |
|
1980 |
] ifFalse:[ |
|
1981 |
line := endLine. |
|
1982 |
col := endCol + 1. |
|
1983 |
] |
|
1984 |
] |
|
1985 |
]. |
|
1986 |
self cursorLine:line col:col |
|
4707 | 1987 |
] |
121 | 1988 |
! |
1989 |
||
499 | 1990 |
cursorToPreviousWord |
1991 |
"move the cursor to the beginning of this or the previous word" |
|
1992 |
||
1993 |
|col line searching l| |
|
1994 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1995 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1996 |
|
1997 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 1998 |
:beginLine :beginCol :endLine :endCol :style | |
1999 |
||
2000 |
line := beginLine. |
|
2001 |
col := beginCol. |
|
2002 |
style == #wordLeft ifTrue:[ |
|
2003 |
col := col + 1 |
|
2004 |
]. |
|
2005 |
||
2006 |
(cursorLine == line |
|
2007 |
and:[cursorCol == col]) ifTrue:[ |
|
2008 |
searching := true. |
|
2009 |
||
2010 |
col > 1 ifTrue:[ |
|
2011 |
col := col - 1. |
|
2012 |
]. |
|
2013 |
||
2014 |
[searching] whileTrue:[ |
|
2015 |
(col == 1) ifTrue:[ |
|
2016 |
line == 1 ifTrue:[ |
|
2017 |
searching := false |
|
2018 |
] ifFalse:[ |
|
2019 |
line := line - 1. |
|
2020 |
l := list at:line. |
|
2021 |
col := l size + 1. |
|
2022 |
] |
|
2023 |
] ifFalse:[ |
|
2024 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2025 |
self wordAtLine:line col:col do:[ |
|
2026 |
:beginLine :beginCol :endLine :endCol :style | |
|
2027 |
||
2028 |
line := beginLine. |
|
2029 |
col := beginCol. |
|
2030 |
style == #wordLeft ifTrue:[ |
|
2031 |
col := col + 1 |
|
2032 |
]. |
|
2033 |
searching := false. |
|
2034 |
] |
|
2035 |
] ifTrue:[ |
|
2036 |
col := col - 1 |
|
2037 |
] |
|
2038 |
] |
|
2039 |
] |
|
2040 |
]. |
|
2041 |
self cursorLine:line col:col |
|
499 | 2042 |
] |
2043 |
||
2044 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2045 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2046 |
! |
|
2047 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2048 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2049 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2050 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2051 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2052 |
! |
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 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2055 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2056 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2057 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2058 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2059 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2060 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2061 |
"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
|
2062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2063 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2064 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2065 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2066 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2067 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2068 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2069 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2070 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2071 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2072 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2073 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2074 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2075 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2076 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2077 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2078 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2079 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2080 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2081 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2082 |
] |
672 | 2083 |
|
674 | 2084 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2086 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2089 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2090 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2091 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2092 |
wasOn := self hideCursor. |
2422
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 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2095 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2096 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2097 |
|
676 | 2098 |
newCol := colNr. |
2099 |
(newCol < 1) ifTrue:[ |
|
4823 | 2100 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2101 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2102 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2103 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2104 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2105 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2106 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2107 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2108 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
"put cursor to position next to x/y coordinate in view" |
121 | 2111 |
|
2112 |
|line col| |
|
2113 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2116 |
self cursorVisibleLine:line col:col. |
121 | 2117 |
! |
2118 |
||
2119 |
drawCursor |
|
2120 |
"draw the cursor if shown and cursor is visible. |
|
2121 |
(but not, if there is a selection - to avoid confusion)" |
|
2122 |
||
2123 |
shown ifTrue:[ |
|
4823 | 2124 |
cursorVisibleLine notNil ifTrue:[ |
2125 |
self hasSelection ifFalse:[ |
|
2126 |
self drawCursorCharacter |
|
2127 |
] |
|
2128 |
] |
|
121 | 2129 |
] |
2130 |
! |
|
2131 |
||
2132 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2133 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2134 |
of cursor should be drawn. |
4721 | 2135 |
Currently, supported are: #none, |
2136 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2137 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2138 |
|
2570 | 2139 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2140 |
|
2141 |
self hasSelection ifTrue:[ |
|
4580 | 2142 |
" |
2143 |
hide cursor, if there is a selection |
|
2144 |
" |
|
2145 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2146 |
]. |
2147 |
||
1334 | 2148 |
cursorType == #none ifTrue:[ |
4580 | 2149 |
^ self |
1334 | 2150 |
]. |
2151 |
||
121 | 2152 |
cursorType == #block ifTrue:[ |
4580 | 2153 |
super drawVisibleLine:cursorVisibleLine |
2154 |
col:cursorCol |
|
2155 |
with:fgColor |
|
2156 |
and:bgColor. |
|
2157 |
^ self |
|
121 | 2158 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2159 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2160 |
y := self yOfVisibleLine:cursorVisibleLine. |
2161 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2162 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2163 |
cursorType == #frame ifTrue:[ |
4580 | 2164 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2165 |
||
2166 |
char := self characterUnderCursor asString. |
|
2167 |
self paint:bgColor. |
|
2168 |
self displayRectangleX:x y:y |
|
2169 |
width:(font widthOf:char) height:fontHeight. |
|
133 | 2170 |
] ifFalse:[ |
4580 | 2171 |
self paint:bgColor. |
2172 |
cursorType == #ibeam ifTrue:[ |
|
2173 |
x1 := x - 1. |
|
2174 |
y2 := y + fontHeight - lineSpacing. |
|
2175 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2176 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2177 |
^ self |
|
2178 |
]. |
|
2179 |
||
2180 |
cursorType == #Ibeam ifTrue:[ |
|
2181 |
x1 := x - 1. |
|
2182 |
y := y + 1. |
|
2183 |
y2 := y + fontHeight - lineSpacing. |
|
2184 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2185 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2186 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2187 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2188 |
^ self |
|
2189 |
]. |
|
2190 |
||
2191 |
y := y + fontHeight - 3. |
|
2192 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2193 |
w := (fontWidth * 2 // 3) max:4. |
|
2194 |
y2 := y + w + (w//2). |
|
2195 |
] ifFalse:[ |
|
2196 |
w := (fontWidth // 2) max:4. |
|
2197 |
y2 := y + w. |
|
2198 |
]. |
|
2199 |
x1 := x - w. |
|
2200 |
x2 := x + w. |
|
2201 |
||
2202 |
oldClip := self clippingRectangleOrNil. |
|
2203 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2204 |
||
2205 |
cursorType == #caret ifTrue:[ |
|
2206 |
self lineWidth:2. |
|
2207 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2208 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2209 |
] ifFalse:[ |
|
2210 |
"anything else: solidCaret" |
|
2211 |
||
2212 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2213 |
with:(x @ y) |
|
2214 |
with:(x2 @ y2)) |
|
2215 |
]. |
|
2216 |
||
2217 |
self clippingRectangle:oldClip |
|
121 | 2218 |
]. |
133 | 2219 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2220 |
|
2088 | 2221 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2222 |
! |
2223 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2224 |
drawCursorCharacter |
3160 | 2225 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2226 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2227 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2228 |
|
3160 | 2229 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2230 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2231 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2232 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2233 |
] ifFalse:[ |
4823 | 2234 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2235 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2236 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2237 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2238 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2240 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2241 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2242 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2243 |
self hasSelection ifTrue:[ |
4823 | 2244 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 2245 |
]. |
2246 |
cursorType == #none ifTrue:[ |
|
4823 | 2247 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2248 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2249 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2250 |
|
2251 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2252 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2253 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2254 |
drawNoFocusCursor |
3160 | 2255 |
"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
|
2256 |
|
1334 | 2257 |
|cType| |
2258 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2259 |
self hasSelection ifTrue:[ |
4823 | 2260 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2261 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2262 |
|
1334 | 2263 |
cType := cursorTypeNoFocus ? cursorType. |
2264 |
cType == #none ifTrue:[ |
|
4823 | 2265 |
^ self undrawCursor |
1334 | 2266 |
]. |
2267 |
||
2268 |
cType == #block ifTrue:[ |
|
4823 | 2269 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2270 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2271 |
|
1334 | 2272 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2273 |
||
2274 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2275 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2276 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2277 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2278 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2279 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
self makeLineVisible:aLineNumber. |
2951 | 2282 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2283 |
self cursorLine:aLineNumber col:1 |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
hideCursor |
1833 | 2287 |
"make cursor invisible if currently invisible" |
2288 |
||
2289 |
^ self cursorShown:false |
|
2290 |
||
2291 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2292 |
! |
2293 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2294 |
makeCursorVisible |
3160 | 2295 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2296 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2297 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2299 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2300 |
cursorLine notNil ifTrue:[ |
4823 | 2301 |
line := cursorLine. |
2302 |
col := cursorCol. |
|
2303 |
" |
|
2304 |
if there is a selection, its better to |
|
2305 |
have its start being visible, instead of the end |
|
2306 |
" |
|
2307 |
(selectionStartLine notNil |
|
2308 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2309 |
expandingTop ~~ false ifTrue:[ |
|
2310 |
line := selectionStartLine. |
|
2311 |
col := selectionStartCol. |
|
2312 |
] ifFalse:[ |
|
2313 |
line := selectionEndLine. |
|
2314 |
col := selectionEndCol |
|
2315 |
] |
|
2316 |
]. |
|
2317 |
self makeLineVisible:line. |
|
2318 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2320 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2321 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2322 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2324 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2325 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2326 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2328 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2329 |
flag ifTrue:[self showCursor] |
121 | 2330 |
! |
2331 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2332 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2333 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2334 |
|
2815 | 2335 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2336 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2337 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2338 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2339 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2340 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2341 |
|
3303 | 2342 |
"/ self assert:(lineNr notNil). |
2343 |
||
2344 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2345 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2346 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2347 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2348 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2349 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2350 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2351 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2352 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2353 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2354 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2355 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2356 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2357 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2358 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2359 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2360 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2361 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2362 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2363 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2364 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2365 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2366 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2367 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2368 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2369 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2370 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2371 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2372 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2373 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2374 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2375 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2376 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2377 |
|
1833 | 2378 |
^ self cursorShown:true |
2379 |
||
2380 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2381 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2383 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2384 |
"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
|
2385 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2386 |
|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
|
2387 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2388 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2389 |
prevCol := cursorCol - 1. |
2390 |
||
2391 |
"/ if there is any italic stuff in the cursor line, |
|
2392 |
"/ redraw it completely (because characters overlap). |
|
2393 |
cursorCol > 1 ifTrue:[ |
|
2394 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2395 |
line hasChangeOfEmphasis ifTrue:[ |
|
2396 |
line size >= (cursorCol-1) ifTrue:[ |
|
2397 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2398 |
line size >= (cursorCol) ifTrue:[ |
|
2399 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2400 |
line size >= (cursorCol+1) ifTrue:[ |
|
2401 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2402 |
]. |
|
2403 |
]. |
|
2404 |
]. |
|
2405 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2406 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2407 |
] |
|
2408 |
] |
|
2409 |
] |
|
2410 |
]. |
|
2411 |
||
2412 |
((cursorType == #caret) |
|
2413 |
or:[cursorType == #solidCaret |
|
2414 |
or:[cursorType == #bigSolidCaret |
|
2415 |
or:[cursorType == #bigCaret |
|
2416 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2417 |
"caret-cursor touches 4 characters" |
|
2418 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2419 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2420 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2421 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2422 |
] ifFalse:[ |
|
2423 |
"care for left margin" |
|
2424 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2425 |
]. |
|
2426 |
^ self |
|
2427 |
]. |
|
2428 |
||
2429 |
cursorType == #ibeam ifTrue:[ |
|
2430 |
"ibeam-cursor touches 2 characters" |
|
2431 |
cursorCol > 1 ifTrue:[ |
|
2432 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2433 |
] ifFalse:[ |
|
2434 |
"care for left margin" |
|
2435 |
super redrawVisibleLine:cursorVisibleLine. |
|
2436 |
]. |
|
2437 |
^ self |
|
2438 |
]. |
|
2439 |
||
2440 |
"block cursor is simple - just one character under cursor" |
|
2441 |
||
2442 |
"/ however, if italic characters are involved, we must care |
|
2443 |
"/ for the chars before/after the cursor. |
|
2444 |
"/ We redraw the part of the previous character which got |
|
2445 |
"/ detroyed by the block cursor. |
|
2446 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2447 |
||
2448 |
line := self visibleAt:cursorVisibleLine. |
|
2449 |
(line notNil and:[line isText]) ifTrue:[ |
|
2450 |
cursorCol > 1 ifTrue:[ |
|
2451 |
oldClip := self clippingRectangleOrNil. |
|
2452 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2453 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2454 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
2455 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2456 |
self clippingRectangle:oldClip. |
|
2457 |
^ self. |
|
2458 |
]. |
|
2459 |
]. |
|
2460 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2461 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2462 |
|
2088 | 2463 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2464 |
! |
2465 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2466 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2467 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2468 |
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
|
2469 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2470 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2471 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2472 |
|
672 | 2473 |
validateCursorCol:col inLine:line |
674 | 2474 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2475 |
Here, no limits are enforced (and col is returned), |
2476 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2477 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2478 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2479 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2480 |
|
1419 | 2481 |
"/ in ST80 mode, |
2707 | 2482 |
"/ the cursor may not be positioned beyond the |
2483 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2484 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2485 |
self st80EditMode ifTrue:[ |
4823 | 2486 |
l := (self listAt:line). |
2487 |
max := l size + 1. |
|
2488 |
col > max ifTrue:[ |
|
2489 |
^ max |
|
2490 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2491 |
]. |
672 | 2492 |
^ col |
2493 |
||
1419 | 2494 |
"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
|
2495 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2496 |
! |
2497 |
||
2498 |
validateCursorLine:line |
|
2499 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2500 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2501 |
redefined in views which dont like the cursor to be positioned |
2502 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2503 |
skip reserved regions" |
|
2504 |
||
1419 | 2505 |
"/ |
2506 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2507 |
"/ beyond the last line |
1419 | 2508 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2509 |
self st80EditMode ifTrue:[ |
4823 | 2510 |
^ (line min:(list size)) max:1 |
1419 | 2511 |
]. |
674 | 2512 |
^ line |
2513 |
||
1419 | 2514 |
"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
|
2515 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2516 |
! |
2517 |
||
121 | 2518 |
withCursorOffDo:aBlock |
2519 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2520 |
||
2521 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2522 |
^ aBlock value |
121 | 2523 |
]. |
2524 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2525 |
aBlock ensure:[ |
4823 | 2526 |
self showCursor |
121 | 2527 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2528 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2529 |
|
2589 | 2530 |
!EditTextView methodsFor:'drag & drop'! |
2531 |
||
2532 |
allowDrop:aBoolean |
|
3236 | 2533 |
"enable/disable drop support" |
2534 |
||
2589 | 2535 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2536 |
dropTarget := nil. |
2589 | 2537 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2538 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2539 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2540 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2541 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2542 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2543 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2544 |
] |
3236 | 2545 |
]. |
2546 |
! |
|
2547 |
||
3412 | 2548 |
canDrop:aDropContext |
2549 |
"public from d&d. |
|
2550 |
I accept textObjects and fileObjects only." |
|
2551 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2552 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2553 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2554 |
^ self canDropObjects:aDropContext dropObjects |
|
2555 |
||
2556 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2557 |
! |
|
2558 |
||
2559 |
canDropObjects:aCollectionOfDropObjects |
|
2560 |
"public from d&d. |
|
2561 |
I accept textObjects and fileObjects only." |
|
2589 | 2562 |
|
2563 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2564 |
||
3412 | 2565 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2566 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2567 |
||
2568 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2569 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2570 |
! |
|
2571 |
||
2572 |
drop:aDropContext |
|
2573 |
"public from d&d. |
|
2574 |
drop objects (new API)" |
|
2575 |
||
2576 |
self dropObjects:(aDropContext dropObjects) |
|
2577 |
||
2578 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2579 |
! |
|
2580 |
||
2581 |
dropFileObject:aDropObject |
|
2589 | 2582 |
"drop objects |
3236 | 2583 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2584 |
||
4136 | 2585 |
|answer text fn pasteWhat sensor dontAskAgainHolder enforcedDropMode app| |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2586 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2587 |
pasteWhat := #name. |
3412 | 2588 |
|
2589 |
fn := aDropObject asFilename. |
|
2590 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2591 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2592 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2593 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2594 |
pasteWhat := enforcedDropMode. |
3886 | 2595 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2596 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2597 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2598 |
pasteWhat := #name. |
3886 | 2599 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2600 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2601 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2602 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2603 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2604 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2605 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2606 |
stringWithCRs:'Drop the Filename (%1)\or its Contents ?\\Hint: bypass this dialog by pressing SHIFT/CTRL or ALT during the next drop.\SHIFT/CTRL to drop the name, ALT for the contents.' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2607 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2608 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2609 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2610 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2611 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2612 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2613 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2614 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2615 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2616 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2617 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2618 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2619 |
] |
3886 | 2620 |
] |
2621 |
]. |
|
2622 |
]. |
|
2623 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2624 |
pasteWhat == #name ifTrue:[ |
3886 | 2625 |
text := fn pathName |
2626 |
] ifFalse:[ |
|
2627 |
self withWaitCursorDo:[ |
|
3799 | 2628 |
text := fn contentsOfEntireFile |
4136 | 2629 |
]. |
2630 |
(app := self application) notNil ifTrue:[ |
|
2631 |
app droppedFile:fn in:self |
|
2632 |
]. |
|
3886 | 2633 |
]. |
2634 |
||
3799 | 2635 |
self |
2636 |
undoablePaste:text |
|
2637 |
info:'Drop File'. |
|
3412 | 2638 |
|
2639 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2640 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2641 |
! |
2642 |
||
2643 |
dropObject:aDropObject |
|
2644 |
"drop objects |
|
2645 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2646 |
||
3415 | 2647 |
|text| |
2648 |
||
3412 | 2649 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2650 |
self dropFileObject:aDropObject |
3412 | 2651 |
] ifFalse:[ |
3799 | 2652 |
aDropObject isTextObject ifTrue:[ |
2653 |
text := aDropObject theObject. |
|
2654 |
text isStringCollection ifTrue:[ |
|
2655 |
text := text asStringWithoutFinalCR |
|
2656 |
]. |
|
2657 |
] ifFalse:[ |
|
2658 |
text := aDropObject theObject asString |
|
2659 |
]. |
|
2660 |
self |
|
2661 |
undoablePaste:text |
|
2662 |
info:'Drop'. |
|
3412 | 2663 |
]. |
2664 |
||
2665 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2666 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2667 |
! |
2668 |
||
2669 |
dropObjects:aCollectionOfDropObjects |
|
2670 |
"public from d&d. |
|
2671 |
drop objects (old API)" |
|
2672 |
||
3868 | 2673 |
aCollectionOfDropObjects do:[:el | |
2674 |
self dropObject:el |
|
3412 | 2675 |
]. |
2676 |
||
2677 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2678 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2679 |
! ! |
2680 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2681 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2682 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2683 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2684 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2685 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2686 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2687 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2688 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2689 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2690 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2691 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2692 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2693 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2694 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2695 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2696 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2697 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2698 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2699 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2700 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2701 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2702 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2703 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2704 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2705 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2706 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2707 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2708 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2709 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2710 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2711 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2712 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2713 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2714 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2715 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2716 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2717 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2718 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2719 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2720 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2721 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2722 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2723 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2724 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2725 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2726 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2727 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2728 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2729 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2730 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2731 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2732 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2733 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2734 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2735 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2736 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2737 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2738 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2739 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2740 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2741 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2742 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2743 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2744 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2745 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2746 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2747 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2748 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2749 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2750 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2751 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2752 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2753 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2754 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2755 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2756 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2757 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2758 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2759 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2760 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2761 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2762 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2763 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2764 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2765 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2766 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2767 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2768 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2769 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2770 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2771 |
line at:col put:ch. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2772 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2773 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2774 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2775 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2776 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2777 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2778 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2779 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2780 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2781 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2782 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2783 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2784 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2785 |
"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
|
2786 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2787 |
selectionStartLine notNil ifTrue:[ |
4823 | 2788 |
self setClipboardText:(self selection). |
2789 |
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
|
2790 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2791 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2792 |
"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
|
2793 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2794 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2795 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2796 |
"delete single character under cursor; does not merge lines" |
121 | 2797 |
|
2798 |
|wasOn| |
|
2799 |
||
2800 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2802 |
wasOn ifTrue:[self showCursor] |
2803 |
! |
|
2804 |
||
827 | 2805 |
deleteCharAtLine:lineNr col:colNr |
2806 |
"delete a single character at colNr in line lineNr" |
|
2807 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2808 |
self st80EditMode ifTrue:[ |
4823 | 2809 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2810 |
| wasOn | |
|
2811 |
wasOn := self hideCursor. |
|
2812 |
self |
|
2813 |
cursorReturn; |
|
2814 |
cursorCol:1; |
|
2815 |
deleteCharBeforeCursor. |
|
2816 |
wasOn ifTrue:[ self showCursor]. |
|
2817 |
^ self. |
|
2818 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2819 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2820 |
|
827 | 2821 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2822 |
! |
|
2823 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2824 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2825 |
"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
|
2826 |
|
4592 | 2827 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2828 |
|
2829 |
wasOn := self hideCursor. |
|
4814 | 2830 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 2831 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
2832 |
ln := originalLine := (list at:cursorLine) ? ''. |
|
2833 |
ln size < prevTab ifTrue:[ |
|
2834 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2835 |
]. |
|
2836 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2837 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2838 |
cursorCol > prevTab ifTrue:[ |
|
2839 |
self st80EditMode ifTrue:[ |
|
2840 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2841 |
"/ not allow a cursor position beyond the end of line, |
|
2842 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2843 |
originalLine size < prevTab ifTrue:[ |
|
4771 | 2844 |
self basicListAt:cursorLine put:ln |
4592 | 2845 |
] |
2846 |
]. |
|
2847 |
self cursorLine:cursorLine col:prevTab. |
|
2848 |
wasOn ifTrue:[ self showCursor ]. |
|
2849 |
^ self |
|
2850 |
]. |
|
2851 |
] ifFalse:[ |
|
2852 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2853 |
self cursorLine:cursorLine col:prevTab. |
|
2854 |
wasOn ifTrue:[ self showCursor ]. |
|
2855 |
^ self. |
|
2856 |
] |
|
2857 |
]. |
|
827 | 2858 |
]. |
2859 |
||
2491 | 2860 |
"/ (autoIndent |
2861 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2862 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2863 |
"/ ifTrue:[ |
2864 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2865 |
"/ |
|
2866 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2867 |
"/ ln := list at:cursorLine. |
|
2868 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2869 |
"/ soCol := 1 |
|
2870 |
"/ ] |
|
2871 |
"/ ] |
|
2872 |
"/ ] ifFalse:[ |
|
4592 | 2873 |
soCol := 1. |
2491 | 2874 |
"/ ]. |
2875 |
||
1419 | 2876 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2877 |
" |
2878 |
somewhere in the middle of a line |
|
2879 |
" |
|
2880 |
self cursorLeft. |
|
2881 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2882 |
] ifFalse:[ |
4592 | 2883 |
" |
2884 |
at begin of line - merge with previous line; |
|
2885 |
except for the very first line. |
|
2886 |
" |
|
2887 |
(cursorLine == 1) ifFalse:[ |
|
2888 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2889 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2890 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2891 |
"/ we are beyond the end of the text. |
|
2892 |
"/ move the cursor to the previous line. |
|
2893 |
self cursorLine:lineNrAboveCursor col:1. |
|
2894 |
] ifFalse:[ |
|
2895 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2896 |
] |
|
2897 |
] |
|
2898 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2899 |
]. |
827 | 2900 |
wasOn ifTrue:[ self showCursor ] |
2901 |
||
1419 | 2902 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2903 |
! |
2904 |
||
2905 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2906 |
"delete characters from colNr up to the end in line lineNr" |
|
2907 |
||
2908 |
|line| |
|
2909 |
||
2910 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 2911 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2912 |
] |
2913 |
||
2914 |
! |
|
2915 |
||
4458 | 2916 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2917 |
"delete characters from startCol to endCol in line lineNr" |
|
2918 |
||
2919 |
|deleted| |
|
2920 |
||
2921 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
2922 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
2923 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
2924 |
! |
|
2925 |
||
827 | 2926 |
deleteCharsAtLine:lineNr toCol:colNr |
2927 |
"delete characters from start up to colNr in line lineNr" |
|
2928 |
||
2929 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2930 |
||
2931 |
||
121 | 2932 |
! |
2933 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2934 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2935 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2937 |
self deleteLine:cursorLine |
121 | 2938 |
! |
2939 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2940 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2941 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2942 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2943 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2944 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2945 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2946 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2947 |
col1 == 0 ifTrue:[ |
4823 | 2948 |
line1 := line1 - 1. |
2949 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2950 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2951 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2952 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2953 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2954 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2955 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2956 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2957 |
|
2954 | 2958 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2959 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2960 |
joining lines if nescessary" |
|
2961 |
||
2962 |
|line newLine lineSize nMore| |
|
2963 |
||
2964 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2965 |
list isNil ifTrue:[^ self]. |
|
2966 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2967 |
||
2968 |
(startLine == endLine) ifTrue:[ |
|
4225 | 2969 |
"/ delete chars within a line |
2970 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2971 |
^ self |
|
2954 | 2972 |
]. |
2973 |
||
2974 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 2975 |
"/ delete full lines only |
2976 |
endLine > startLine ifTrue:[ |
|
2977 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2978 |
]. |
|
2979 |
^ self |
|
2954 | 2980 |
]. |
2981 |
||
2982 |
"/ delete right rest of 1st line |
|
4786 | 2983 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 2984 |
|
2985 |
"/ delete the inner lines ... |
|
2986 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 2987 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 2988 |
]. |
2989 |
||
2990 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 2991 |
"/ delete the left rest of the last line |
2992 |
||
2993 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2994 |
||
2995 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2996 |
startLine <= list size ifTrue:[ |
|
2997 |
line := list at:startLine. |
|
2998 |
lineSize := line size. |
|
2999 |
(startCol > lineSize) ifTrue:[ |
|
3000 |
newLine := line. |
|
3001 |
line isNil ifTrue:[ |
|
3002 |
newLine := String new:(startCol - 1) |
|
3003 |
] ifFalse:[ |
|
3004 |
nMore := startCol - 1 - lineSize. |
|
3005 |
nMore > 0 ifTrue:[ |
|
3006 |
newLine := line , (line species new:nMore) |
|
3007 |
] |
|
3008 |
]. |
|
3009 |
newLine ~~ line ifTrue:[ |
|
4771 | 3010 |
self basicListAt:startLine put:newLine. |
4225 | 3011 |
]. |
3012 |
"/ TODO: remember old maxwidth of linerange, |
|
3013 |
"/ only clear widthOfWidestLine, if this max |
|
3014 |
"/ length was (one of) the longest. |
|
3015 |
"/ avoids slow delete with huge texts. |
|
3016 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3017 |
self textChanged. |
|
3018 |
] |
|
3019 |
] |
|
2954 | 3020 |
]. |
3021 |
||
3022 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3023 |
self mergeLine:startLine removeBlanks:false |
|
3024 |
||
4225 | 3025 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3026 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3027 |
! |
3028 |
||
4458 | 3029 |
deleteFromLine:startLineNr toLine:endLineNr |
3030 |
"delete some lines" |
|
3031 |
||
3032 |
|deleted| |
|
3033 |
||
3034 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3035 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3036 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3037 |
! |
|
3038 |
||
827 | 3039 |
deleteLine:lineNr |
3040 |
"delete line" |
|
3041 |
||
3042 |
self deleteFromLine:lineNr toLine:lineNr |
|
3043 |
||
3044 |
||
3045 |
! |
|
3046 |
||
4458 | 3047 |
deleteLineWithoutRedraw:lineNr |
3048 |
"delete line - no redraw; |
|
3049 |
return true, if something was really deleted" |
|
3050 |
||
3051 |
|deleted ret| |
|
3052 |
||
3053 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3054 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3055 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3056 |
^ ret. |
|
3057 |
! |
|
3058 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3059 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3060 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3061 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3063 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3064 |
|
4771 | 3065 |
self checkModificationsAllowed ifFalse:[^ false]. |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3066 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3067 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3068 |
(endLine > list size) ifTrue:[ |
4771 | 3069 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3070 |
] ifFalse:[ |
4771 | 3071 |
lastLine := endLine |
3072 |
]. |
|
3073 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3074 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3075 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3076 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3077 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3078 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3079 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3080 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3081 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3082 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3083 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3084 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3085 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3086 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3087 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3088 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3089 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3090 |
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
|
3091 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3092 |
selectionStartLine notNil ifTrue:[ |
4823 | 3093 |
wasOn := self hideCursor. |
3094 |
||
3095 |
startLine := selectionStartLine. |
|
3096 |
startCol := selectionStartCol. |
|
3097 |
endLine := selectionEndLine. |
|
3098 |
endCol := selectionEndCol. |
|
3099 |
self unselectWithoutRedraw. |
|
3100 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3101 |
self setCursorLine:startLine col:startCol. |
|
3102 |
||
3103 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3104 |
] |
121 | 3105 |
! |
3106 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3107 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3108 |
"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
|
3109 |
|
2952 | 3110 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3111 |
|
3799 | 3112 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3113 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3114 |
wasOn := self hideCursor. |
3799 | 3115 |
self |
3116 |
undoableDo:[ |
|
3117 |
endCol := cursorCol-1. |
|
3118 |
endLine := cursorLine. |
|
3119 |
self cursorToPreviousWord. |
|
3120 |
beginCol := cursorCol. |
|
3121 |
beginLine := cursorLine. |
|
3122 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3123 |
] |
|
3124 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3125 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3126 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3127 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3128 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3129 |
|
4458 | 3130 |
insert:aCharacter atLine:lineNr col:colNr |
3131 |
"insert a single character at lineNr/colNr; |
|
3132 |
set emphasis to character at current position" |
|
3133 |
||
3134 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3135 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3136 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3137 |
] |
3138 |
! |
|
3139 |
||
121 | 3140 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3141 |
"insert a single character at cursor-position - advance cursor." |
121 | 3142 |
|
3143 |
|wasOn| |
|
3144 |
||
3145 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3146 |
aCharacter == Character tab ifTrue:[ |
4820 | 3147 |
"/ needs special care to advance cursor correctly |
3148 |
self insertTabAtCursor |
|
121 | 3149 |
] ifFalse:[ |
4820 | 3150 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3151 |
aCharacter == (Character cr) ifTrue:[ |
|
3152 |
self basicCursorReturn |
|
3153 |
] ifFalse:[ |
|
3154 |
self cursorRight. |
|
3155 |
]. |
|
121 | 3156 |
]. |
3157 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3158 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3159 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3160 |
! |
3161 |
||
641 | 3162 |
insertLine:aString before:lineNr |
3163 |
"insert the line aString before line lineNr" |
|
3164 |
||
3165 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3166 |
||
3167 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3168 |
! |
|
3169 |
||
155 | 3170 |
insertLines:aStringCollection before:lineNr |
3171 |
"insert a bunch before line lineNr" |
|
3172 |
||
3173 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3174 |
||
3175 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3176 |
! |
|
3177 |
||
4771 | 3178 |
insertLines:someText from:start to:end before:lineNr |
3179 |
"insert a bunch of lines before line lineNr. |
|
3180 |
The cursor position is left unchanged." |
|
3181 |
||
3182 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3183 |
srcY "{ Class: SmallInteger }" |
|
3184 |
dstY "{ Class: SmallInteger }" | |
|
3185 |
||
3186 |
autoIndent ifTrue:[ |
|
3187 |
indent := self leftIndentForLine:lineNr. |
|
3188 |
||
4812 | 3189 |
text := someText |
3190 |
collect:[:ln||line| |
|
3191 |
ln notNil ifTrue:[ |
|
3192 |
line := ln withoutLeadingSeparators. |
|
3193 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3194 |
line := (String new:indent), line |
|
3195 |
]. |
|
3196 |
line |
|
3197 |
] ifFalse:[ |
|
3198 |
nil |
|
3199 |
] |
|
3200 |
]. |
|
4771 | 3201 |
] ifFalse:[ |
3202 |
text := someText |
|
3203 |
]. |
|
3204 |
||
3205 |
visLine := self listLineToVisibleLine:lineNr. |
|
3206 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3207 |
self withoutRedrawInsertLines:text |
|
3208 |
from:start to:end |
|
3209 |
before:lineNr. |
|
3210 |
] ifFalse:[ |
|
3211 |
nLines := end - start + 1. |
|
3212 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3213 |
self withoutRedrawInsertLines:text |
|
3214 |
from:start to:end |
|
3215 |
before:lineNr. |
|
3216 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3217 |
] ifFalse:[ |
|
3218 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3219 |
and:(firstLineShown + nLines + nLinesShown). |
|
3220 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3221 |
dstY := srcY + (nLines * fontHeight). |
|
3222 |
||
3223 |
"/ |
|
3224 |
"/ scroll ... |
|
3225 |
"/ |
|
3226 |
" |
|
3227 |
stupid: must catchExpose before inserting new |
|
3228 |
stuff - since catchExpose may perform redraws |
|
3229 |
" |
|
3230 |
self catchExpose. |
|
3231 |
self withoutRedrawInsertLines:text |
|
3232 |
from:start to:end |
|
3233 |
before:lineNr. |
|
3234 |
self |
|
3235 |
copyFrom:self |
|
3236 |
x:textStartLeft y:srcY |
|
3237 |
toX:textStartLeft y:dstY |
|
3238 |
width:w |
|
3239 |
height:(height - dstY) |
|
3240 |
async:true. |
|
3241 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3242 |
self waitForExpose |
|
3243 |
]. |
|
3244 |
]. |
|
3245 |
widthOfWidestLine notNil ifTrue:[ |
|
3246 |
text do:[:line | |
|
3247 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3248 |
] |
|
3249 |
]. |
|
3250 |
self textChanged. |
|
3251 |
||
3252 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3253 |
! |
|
3254 |
||
654 | 3255 |
insertLines:lines withCR:withCr |
3160 | 3256 |
"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
|
3257 |
Cursor is moved behind insertion. |
641 | 3258 |
If withCr is true, append cr after last line" |
3259 |
||
3260 |
|start end nLines wasOn| |
|
3261 |
||
3262 |
lines notNil ifTrue:[ |
|
4649 | 3263 |
nLines := lines size. |
3264 |
(nLines == 1) ifTrue:[ |
|
3265 |
self insertStringAtCursor:(lines at:1). |
|
3266 |
withCr ifTrue:[ |
|
3267 |
self insertCharAtCursor:(Character cr) |
|
3268 |
] |
|
3269 |
] ifFalse:[ |
|
3270 |
(cursorCol ~~ 1) ifTrue:[ |
|
3271 |
self insertStringAtCursor:(lines at:1). |
|
3272 |
self insertCharAtCursor:(Character cr). |
|
3273 |
start := 2 |
|
3274 |
] ifFalse:[ |
|
3275 |
start := 1 |
|
3276 |
]. |
|
3277 |
withCr ifTrue:[ |
|
3278 |
end := nLines |
|
3279 |
] ifFalse:[ |
|
3280 |
end := nLines - 1 |
|
3281 |
]. |
|
3282 |
(start <= nLines) ifTrue:[ |
|
3283 |
(end >= start) ifTrue:[ |
|
3284 |
wasOn := self hideCursor. |
|
3285 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3286 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3287 |
wasOn ifTrue:[self showCursor]. |
|
3288 |
] |
|
3289 |
]. |
|
3290 |
withCr ifFalse:[ |
|
3291 |
"last line without cr" |
|
3292 |
self insertStringAtCursor:(lines at:nLines) |
|
3293 |
] |
|
3294 |
] |
|
641 | 3295 |
] |
654 | 3296 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3297 |
"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
|
3298 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3299 |
! |
3300 |
||
3301 |
insertLines:lines withCr:withCr |
|
3302 |
"insert a bunch of lines at cursor position. Cursor |
|
3303 |
is moved behind insertion. |
|
3304 |
If withCr is true, append cr after last line" |
|
3305 |
||
2363 | 3306 |
<resource:#obsolete> |
3307 |
||
1292 | 3308 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3309 |
self insertLines:lines withCR:withCr. |
|
3310 |
||
3311 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3312 |
! |
3313 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3314 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3315 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3317 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3318 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3319 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3320 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3321 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3322 |
self selectFromLine:startLine col:startCol |
4823 | 3323 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3324 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3325 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3326 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3327 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3328 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3329 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3330 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3331 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3332 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3333 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3334 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3335 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3336 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3337 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3338 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3339 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3340 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3341 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3342 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3343 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3344 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3345 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3346 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3347 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3348 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3349 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3350 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3351 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3352 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3353 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3354 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3355 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3356 |
[start <= end] whileTrue:[ |
4823 | 3357 |
stop := aString indexOf:(Character cr) startingAt:start. |
3358 |
stop == 0 ifTrue:[ |
|
3359 |
stop := end + 1 |
|
3360 |
]. |
|
3361 |
subString := aString copyFrom:start to:(stop - 1). |
|
3362 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3363 |
(stop <= end) ifTrue:[ |
|
3364 |
c := c + subString size. |
|
3365 |
self insert:(Character cr) atLine:l col:c. |
|
3366 |
l := l + 1. |
|
3367 |
c := 1 |
|
3368 |
]. |
|
3369 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3370 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3371 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3372 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3373 |
! |
3374 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3375 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3376 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3377 |
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
|
3378 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3379 |
aString isNil ifTrue:[ |
4823 | 3380 |
"new:" |
3381 |
self insertCharAtCursor:(Character cr). |
|
3382 |
^ self |
|
105 | 3383 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3384 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3385 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3386 |
]. |
3387 |
||
654 | 3388 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3389 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3390 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3391 |
! |
3392 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3393 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3394 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3395 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3396 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3397 |
shown ifTrue:[ |
3398 |
font hasOverlappingCharacters ifTrue:[ |
|
3399 |
self invalidateLine:lineNr. |
|
3400 |
] ifFalse:[ |
|
3401 |
self redrawLine:lineNr from:colNr |
|
3402 |
] |
|
3403 |
] |
|
3404 |
||
4191 | 3405 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3406 |
! |
3407 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3408 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3409 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3410 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3411 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3412 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3413 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3414 |
aString size > 0 ifTrue:[ |
4823 | 3415 |
wasOn := self hideCursor. |
3416 |
(aString includes:Character tab) ifTrue:[ |
|
3417 |
self checkForExistingLine:cursorLine. |
|
3418 |
oldLen := (list at:cursorLine) size. |
|
3419 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3420 |
newLen := (list at:cursorLine) size. |
|
3421 |
deltaLen := newLen - oldLen. |
|
3422 |
] ifFalse:[ |
|
3423 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3424 |
deltaLen := aString size. |
|
3425 |
]. |
|
3426 |
self setCursorCol:(cursorCol + deltaLen). |
|
3427 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3428 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3429 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3430 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3431 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3432 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3433 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3434 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3435 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3436 |
|wasOn nextTab| |
105 | 3437 |
|
121 | 3438 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3439 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3440 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3441 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3442 |
! |
3443 |
||
3542 | 3444 |
joinLines |
3890 | 3445 |
"join lines (remove line-break)" |
3446 |
||
3583 | 3447 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3448 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3449 |
self |
3890 | 3450 |
undoableDo:[ |
3451 |
|line col lineLen| |
|
3452 |
||
3453 |
line := cursorLine. |
|
3454 |
col := cursorCol. |
|
3455 |
lineLen := (list at:line) size. |
|
3456 |
col > lineLen ifTrue:[ |
|
3457 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3458 |
] ifFalse:[ |
|
3459 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3460 |
]. |
|
3461 |
self mergeLine:line removeBlanks:true. |
|
3462 |
self cursorLine:line col:col. |
|
3463 |
] |
|
3464 |
info:'Join' |
|
3542 | 3465 |
! |
3466 |
||
2952 | 3467 |
mergeLine:lineNr |
3468 |
"merge line lineNr with line lineNr+1" |
|
3469 |
||
3470 |
self mergeLine:lineNr removeBlanks:true |
|
3471 |
||
3472 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3473 |
! |
|
3474 |
||
4458 | 3475 |
mergeLine:lineNr removeBlanks:removeBlanks |
3476 |
"merge line lineNr with line lineNr+1" |
|
3477 |
||
3478 |
|len| |
|
3479 |
||
3480 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3481 |
||
3482 |
len := (self listAt:lineNr) size. |
|
3483 |
self nonUndoableDo:[ |
|
4823 | 3484 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3485 |
]. |
3486 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3487 |
! |
|
3488 |
||
2506 | 3489 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3490 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3491 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3492 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3493 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3494 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3495 |
|
2506 | 3496 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
4823 | 3497 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
3498 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
3499 |
newSelectionEnd := newSelectionEnd-1. |
|
3500 |
]. |
|
3501 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
3502 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3503 |
newSelectionEnd := newSelectionEnd-1. |
|
3504 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3505 |
] ifFalse:[ |
4823 | 3506 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
3507 |
newSelectionEnd := newSelectionEnd+1. |
|
3508 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
3509 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3510 |
newSelectionEnd := newSelectionEnd+1. |
|
3511 |
] |
|
3160 | 3512 |
]. |
3513 |
self |
|
4823 | 3514 |
selectFromLine:selectionStartLine col:selectionStartCol |
3515 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3516 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3517 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3518 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3519 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3520 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3521 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3522 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3523 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3524 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3525 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3526 |
[finished] whileFalse:[ |
4771 | 3527 |
(lastLine <= 1) ifTrue:[ |
3528 |
finished := true |
|
3529 |
] ifFalse:[ |
|
3530 |
line := list at:lastLine. |
|
3531 |
line notNil ifTrue:[ |
|
3532 |
line isBlank ifTrue:[ |
|
3533 |
self basicListAt:lastLine put:nil. |
|
3534 |
line := nil |
|
3535 |
] |
|
3536 |
]. |
|
3537 |
line notNil ifTrue:[ |
|
3538 |
finished := true |
|
3539 |
] ifFalse:[ |
|
3540 |
lastLine := lastLine - 1 |
|
3541 |
] |
|
3542 |
] |
|
118 | 3543 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3544 |
(lastLine ~~ list size) ifTrue:[ |
4771 | 3545 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3546 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3547 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3548 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3549 |
|
4458 | 3550 |
replace:aCharacter atLine:lineNr col:colNr |
3551 |
"replace a single character at lineNr/colNr" |
|
3552 |
||
3553 |
|originalChar| |
|
3554 |
||
3555 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3556 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3557 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3558 |
! |
|
3559 |
||
4713 | 3560 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3561 |
|pattern replacePattern| |
3562 |
||
3563 |
pattern := patternArg string. |
|
3564 |
replacePattern := replacePatternArg string. |
|
4630 | 3565 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3566 |
self rememberSearchPattern:pattern. |
|
3567 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3568 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3569 |
self |
3570 |
undoableDo:[ |
|
3571 |
all ifTrue:[ |
|
3572 |
self |
|
3573 |
replaceString:pattern |
|
3574 |
to:replacePattern |
|
4713 | 3575 |
ignoreCase:ignoreCase |
4630 | 3576 |
] ifFalse:[ |
3577 |
(self selectionAsString notNil |
|
4713 | 3578 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3579 |
ifTrue:[ |
4742 | 3580 |
self replaceSelectionBy:replacePattern. |
4630 | 3581 |
self |
3582 |
search:pattern |
|
4713 | 3583 |
ignoreCase:ignoreCase |
4630 | 3584 |
forward:(lastSearchDirection = #forward). |
3585 |
]. |
|
3586 |
] |
|
3587 |
] |
|
3588 |
info:'Replace' |
|
3430 | 3589 |
] |
3590 |
||
3591 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3592 |
! |
|
3593 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3594 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3595 |
"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
|
3596 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3597 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3598 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3599 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3600 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3601 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3602 |
] ifFalse:[ |
4823 | 3603 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3604 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3605 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3606 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3607 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3608 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3609 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3610 |
|
4458 | 3611 |
replaceContentsWith:newContents |
3612 |
"replace everything" |
|
3613 |
||
3614 |
|originalContents| |
|
3615 |
||
3616 |
originalContents := self contents. |
|
3617 |
self contents:newContents keepUndoHistory:true. |
|
3618 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3619 |
! |
|
3620 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3621 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3622 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3623 |
|
4701 | 3624 |
"/ sigh - insert first, to avoid troible due to shifing-in virtual line ends |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3625 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3626 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3627 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3628 |
|
4458 | 3629 |
replaceLine:lineNr with:newText |
3630 |
"replace a line at lineNr" |
|
3631 |
||
3632 |
|originalLine| |
|
3633 |
||
3634 |
originalLine := self listAt:lineNr. |
|
3635 |
originalLine isNil ifTrue:[ |
|
4823 | 3636 |
self checkForExistingLine:lineNr |
4458 | 3637 |
]. |
3638 |
self list at:lineNr put:newText. |
|
3639 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3640 |
self invalidateLine:lineNr. |
|
3641 |
||
3642 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3643 |
! |
|
3644 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3645 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3646 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3647 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3648 |
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
|
3649 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3650 |
|
1809 | 3651 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3652 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3653 |
lines notNil ifTrue:[ |
4661 | 3654 |
wasOn := self hideCursor. |
3655 |
nLines := lines size. |
|
3656 |
line := cursorLine. |
|
3657 |
col := cursorCol. |
|
3658 |
lines keysAndValuesDo:[:i :l | |
|
3659 |
self replaceString:(l ? '') atLine:line col:col. |
|
3660 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3661 |
line := line + 1. |
|
3662 |
col := 1. |
|
3663 |
] ifFalse:[ |
|
3664 |
col := col + (l size). |
|
3665 |
] |
|
3666 |
]. |
|
3667 |
self cursorLine:line col:col. |
|
3668 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3669 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3670 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3671 |
|
4661 | 3672 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3673 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3674 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3675 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3676 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3677 |
"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
|
3678 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3679 |
|
4666 | 3680 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3681 |
! |
3682 |
||
3683 |
replaceSelectionBy:something keepCursor:keep |
|
3684 |
"delete the selection (if any) and insert something, a character or string; |
|
3685 |
leave cursor after insertion or leave it, depending on keep" |
|
3686 |
||
4666 | 3687 |
self replaceSelectionBy:something keepCursor:keep select:false |
3688 |
||
3689 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3690 |
! |
|
3691 |
||
3692 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
3693 |
"delete the selection (if any) and insert something, a character or string; |
|
3694 |
leave cursor after insertion or leave it, depending on keep. |
|
3695 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3696 |
||
3697 |
|sel l c selStartLine selStartCol| |
|
105 | 3698 |
|
3699 |
l := cursorLine. |
|
3700 |
c := cursorCol. |
|
3701 |
||
4818 | 3702 |
sel := self selectionAsString. |
4666 | 3703 |
sel isNil ifTrue:[ |
3704 |
selStartLine := l. |
|
3705 |
selStartCol := c. |
|
3706 |
] ifFalse:[ |
|
3707 |
selStartLine := selectionStartLine. |
|
3708 |
selStartCol := selectionStartCol. |
|
3709 |
||
4053 | 3710 |
self setLastStringToReplace: sel. |
3711 |
||
4010 | 3712 |
self deleteSelection. |
3713 |
replacing := true. |
|
4818 | 3714 |
lastReplacementInfo rememberReplacement. |
4048 | 3715 |
lastReplacementInfo lastReplacement: ''. |
4818 | 3716 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 3717 |
undoSupport actionInfo:'replace'. |
3161 | 3718 |
]. |
3719 |
||
3720 |
something isCharacter ifTrue:[ |
|
4051 | 3721 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 3722 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 3723 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 3724 |
]. |
4010 | 3725 |
]. |
3726 |
self isInInsertMode ifTrue:[ |
|
3727 |
self insertCharAtCursor:something |
|
3728 |
] ifFalse:[ |
|
3729 |
self replaceCharAtCursor:something |
|
3730 |
] |
|
105 | 3731 |
] ifFalse:[ |
4010 | 3732 |
something isString ifTrue:[ |
4048 | 3733 |
lastReplacementInfo lastReplacement: something. |
4010 | 3734 |
self isInInsertMode ifTrue:[ |
3735 |
self insertStringAtCursor:something |
|
3736 |
] ifFalse:[ |
|
3737 |
self replaceStringAtCursor:something |
|
3738 |
] |
|
3739 |
] ifFalse:[ |
|
3740 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3741 |
]. |
|
105 | 3742 |
]. |
3743 |
keep ifTrue:[ |
|
4010 | 3744 |
self cursorLine:l col:c |
4666 | 3745 |
]. |
3746 |
selectNewText ifTrue:[ |
|
3747 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3748 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3749 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3750 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3751 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3752 |
|
4458 | 3753 |
replaceString:aString atLine:lineNr col:colNr |
3754 |
"replace multiple characters starting at lineNr/colNr. |
|
3755 |
This is not prepared to encounter special chars (except TAB) in the string." |
|
3756 |
||
3757 |
|originalString| |
|
3758 |
||
3759 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3760 |
||
3761 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3762 |
||
3763 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3764 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3765 |
! |
|
3766 |
||
4713 | 3767 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 3768 |
|continue count| |
3769 |
||
3770 |
self cursorToTop. |
|
3771 |
self selectFromBeginning. |
|
3772 |
count := 0. |
|
3773 |
continue := true. |
|
3774 |
[ continue ] whileTrue:[ |
|
4713 | 3775 |
(self selectionAsString notNil |
3776 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
3777 |
ifTrue:[ |
|
4742 | 3778 |
self replaceSelectionBy:aNewString. |
4713 | 3779 |
count := count + 1. |
3780 |
]. |
|
3781 |
self |
|
3782 |
searchFwd:aString |
|
3783 |
ignoreCase:ignoreCase |
|
3784 |
ifAbsent:[ |
|
3785 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
3786 |
bindWith:aString with:aNewString with:count). |
|
3787 |
continue := false. |
|
3788 |
]. |
|
3549 | 3789 |
]. |
3430 | 3790 |
|
3791 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3792 |
! |
|
3793 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3794 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3795 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3796 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3797 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3798 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3799 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3800 |
(aString includes:Character tab) ifTrue:[ |
4823 | 3801 |
"/ need special care for TAB (to move cursor correctly) |
3802 |
i1 := 1. |
|
3803 |
[i1 ~~ 0] whileTrue:[ |
|
3804 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3805 |
i2 ~~ 0 ifTrue:[ |
|
3806 |
i1 ~~ i2 ifTrue:[ |
|
3807 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3808 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3809 |
]. |
|
3810 |
self replaceTABAtCursor. |
|
3811 |
i2 := i2 + 1. |
|
3812 |
] ifFalse:[ |
|
3813 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3814 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3815 |
]. |
|
3816 |
i1 := i2. |
|
3817 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3818 |
] ifFalse:[ |
4823 | 3819 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3820 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3821 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3822 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3823 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3824 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3825 |
"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
|
3826 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3827 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3828 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3829 |
"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
|
3830 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3831 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3832 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3833 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3834 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3835 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3836 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3837 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3838 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3839 |
! |
3840 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3841 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3842 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3843 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3844 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3845 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3846 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3847 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3848 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3849 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3850 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3851 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3852 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3853 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3854 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3855 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3856 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3857 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3858 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3859 |
|
4458 | 3860 |
splitLine:lineNr before:colNr |
3861 |
"split the line linNr before colNr; the right part (from colNr) |
|
3862 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3863 |
||
3864 |
self basicSplitLine:lineNr before:colNr. |
|
3865 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3866 |
! |
|
3867 |
||
3868 |
withoutRedrawAt:lineNr put:aString |
|
3869 |
"replace a line at lineNr" |
|
3870 |
||
3871 |
|originalLine| |
|
3872 |
||
3873 |
originalLine := self listAt:lineNr. |
|
3874 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3875 |
super withoutRedrawAt:lineNr put:aString. |
|
3876 |
! |
|
3877 |
||
3878 |
withoutRedrawInsertLine:aString before:lineNr |
|
3879 |
"insert the argument, aString before line lineNr; the string |
|
3880 |
becomes line lineNr; everything else is moved down; the view |
|
3881 |
is not redrawn" |
|
3882 |
||
4771 | 3883 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 3884 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
3885 |
! |
|
3886 |
||
3887 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
3888 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3889 |
||
3890 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
3891 |
self isReadOnly ifFalse:[ |
|
4823 | 3892 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 3893 |
]. |
3894 |
! |
|
3895 |
||
3896 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3897 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3898 |
||
3899 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
3900 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
3901 |
! |
|
3902 |
||
3890 | 3903 |
wrapLines |
3904 |
"wrap lines (insert line-break)" |
|
3905 |
||
3906 |
|lineLength answerString string| |
|
3907 |
||
3908 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3909 |
||
3910 |
self hasSelection ifFalse:[ |
|
3911 |
self selectLine:cursorLine. |
|
3912 |
]. |
|
3913 |
string := self selectionAsString. |
|
3914 |
string isEmptyOrNil ifTrue:[ |
|
3915 |
Dialog information:(resources string:'Nothing selected.'). |
|
3916 |
^ self. |
|
3917 |
]. |
|
3918 |
||
3919 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
3920 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 3921 |
lineLength isNil ifTrue:[^ self]. |
3890 | 3922 |
lineLength < 1 ifTrue:[ |
3923 |
lineLength := 1. |
|
3924 |
]. |
|
3925 |
||
3926 |
self |
|
3927 |
undoableDo:[ |
|
3928 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
3929 |
||
3930 |
line := selectionStartLine. |
|
3931 |
col := selectionStartCol. |
|
3932 |
||
3933 |
self cutSelection. |
|
3934 |
self cursorLine:line col:col. |
|
3935 |
||
3936 |
lastGoodCol := col. |
|
3937 |
||
3938 |
inStream := string readStream. |
|
3939 |
[ inStream atEnd ] whileFalse:[ |
|
3940 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
3941 |
word := WriteStream on:(String new:10). |
|
3942 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
3943 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
3944 |
self insertCharAtCursor:(Character cr). |
|
3945 |
col := 1. |
|
3946 |
] ifFalse:[ |
|
3947 |
col ~~ 1 ifTrue:[ |
|
3948 |
self insertStringAtCursor:' '. |
|
3949 |
col := col + 1. |
|
3950 |
] |
|
3951 |
]. |
|
3952 |
self insertStringAtCursor:word contents. |
|
3953 |
col := col + word size. |
|
3954 |
]. |
|
3955 |
] |
|
3956 |
info:'Wrap' |
|
4388 | 3957 |
|
3958 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3959 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3960 |
|
2752 | 3961 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3962 |
|
2952 | 3963 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3964 |
"delete characters from startCol to endCol in line lineNr" |
3965 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
3966 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3967 |
|
4673 | 3968 |
self unselect. |
3969 |
||
3970 |
cursorLine == lineNr ifTrue:[ |
|
3971 |
cursorCol >= startCol ifTrue:[ |
|
3972 |
cursorCol >= endCol ifTrue:[ |
|
3973 |
cursorCol := startCol. |
|
3974 |
] ifFalse:[ |
|
3975 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
3976 |
] |
|
3977 |
]. |
|
3978 |
]. |
|
3979 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3980 |
line := self listAt:lineNr. |
827 | 3981 |
|
4673 | 3982 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
3983 |
||
3984 |
lineSize := line size. |
|
3985 |
||
3986 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
3987 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
3988 |
||
3989 |
stop >= start ifTrue:[ |
|
3990 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
3991 |
ifFalse:[ newLine := '' ]. |
|
3992 |
||
3993 |
stop == lineSize ifFalse:[ |
|
3994 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
3995 |
newLine := line string species fromString:newLine. |
|
4190 | 3996 |
]. |
4673 | 3997 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
3998 |
]. |
|
3999 |
||
4000 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4001 |
newLine := nil |
|
4002 |
]. |
|
4003 |
||
4004 |
prevWidth := self widthOfLine:lineNr. |
|
4005 |
||
4771 | 4006 |
self basicListAt:lineNr put:newLine. |
4673 | 4007 |
|
4008 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4009 |
"/ remember old width of this line, |
|
4010 |
"/ only clear widthOfWidestLine, if this lines |
|
4011 |
"/ length was (one of) the longest. |
|
4012 |
"/ avoids slow delete with huge texts. |
|
4013 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4014 |
||
4015 |
"/ scroll left if reqiured |
|
4016 |
viewOrigin x > 0 ifTrue:[ |
|
4017 |
newWidth := self widthOfLine:lineNr. |
|
4018 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4019 |
self scrollHorizontalTo:(newWidth |
|
4020 |
- width |
|
4021 |
+ margin + margin |
|
4022 |
+ (font widthOf:' ')) |
|
4023 |
] |
|
4190 | 4024 |
]. |
4673 | 4025 |
self textChanged. |
4026 |
] ifFalse:[ |
|
4027 |
self textChanged "/ textChangedButNoSizeChange |
|
4028 |
]. |
|
4029 |
font hasOverlappingCharacters ifTrue:[ |
|
4030 |
self invalidateLine:lineNr. |
|
4031 |
] ifFalse:[ |
|
4032 |
self redrawLine:lineNr from:start. |
|
4033 |
]. |
|
4034 |
]. |
|
827 | 4035 |
|
4191 | 4036 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4037 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4038 |
|
2952 | 4039 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4040 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4041 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4042 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4043 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4044 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4045 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4046 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4047 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4048 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4049 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4050 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4051 |
startLineNr <= list size ifTrue:[ |
4771 | 4052 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4053 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4054 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4055 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4056 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4057 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4058 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4059 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4060 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4061 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4062 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4063 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4064 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4065 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4066 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4067 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4068 |
|
4226 | 4069 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4070 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4071 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4072 |
|
2952 | 4073 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4074 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4075 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4076 |
|
2952 | 4077 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4078 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4079 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4080 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4081 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4082 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4083 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4084 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4085 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4086 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4087 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4088 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4089 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4090 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4091 |
|
2952 | 4092 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4093 |
"insert a single character at lineNr/colNr; |
827 | 4094 |
set emphasis to character at current position" |
4095 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4096 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4097 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4098 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4099 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4100 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4101 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4102 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4103 |
]. |
827 | 4104 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4105 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4106 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4107 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4108 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4109 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4110 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4111 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4112 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4113 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4114 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4115 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4116 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4117 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4118 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4119 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4120 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4121 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4122 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4123 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4124 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4125 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4126 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4127 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4128 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4129 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4130 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4131 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4132 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4133 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4134 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4135 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4136 |
]. |
827 | 4137 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4138 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4139 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4140 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4141 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4142 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4143 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4144 |
newLine at:colNr put:aCharacter. |
827 | 4145 |
|
4146 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4147 |
newLine emphasisAt:colNr put:attribute. |
827 | 4148 |
]. |
4149 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4150 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4151 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4152 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4153 |
]. |
827 | 4154 |
|
4771 | 4155 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4156 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4157 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4158 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4159 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4160 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4161 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4162 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4163 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4164 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4165 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4166 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4167 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4168 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4169 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4170 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4171 |
|
4172 |
font hasOverlappingCharacters ifTrue:[ |
|
4173 |
self invalidateLine:lineNr. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4174 |
] ifFalse:[ |
4190 | 4175 |
drawCharacterOnly ifTrue:[ |
4176 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
4177 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
4178 |
] ifFalse:[ |
|
4179 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4180 |
self redrawLine:lineNr from:colNr-1 |
|
4181 |
]. |
|
4182 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4183 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4184 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4185 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4186 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4187 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4188 |
font hasOverlappingCharacters ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4189 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4190 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4191 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4192 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4193 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4194 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4195 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4196 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4197 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4198 |
|
4191 | 4199 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4200 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4201 |
|
4771 | 4202 |
basicListAt:lineNr put:newLine |
4203 |
"redefinable for special subclasses (with virtual list)" |
|
4204 |
||
4205 |
list at:lineNr put:newLine. |
|
4206 |
! |
|
4207 |
||
4208 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4209 |
"redefinable for special subclasses (with virtual list)" |
|
4210 |
||
4211 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4212 |
! |
|
4213 |
||
2952 | 4214 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4215 |
"merge line lineNr with line lineNr+1" |
4216 |
||
827 | 4217 |
|leftPart rightPart bothParts nextLineNr i| |
4218 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4219 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4220 |
"/ empty list or beyond end of text |
4221 |
^ self |
|
827 | 4222 |
]. |
4223 |
leftPart := self listAt:lineNr. |
|
4224 |
||
4225 |
leftPart isNil ifTrue:[ |
|
4771 | 4226 |
leftPart := ''. |
4227 |
autoIndent ifTrue:[ |
|
4228 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4229 |
leftPart := String new:i |
|
4230 |
] |
|
4231 |
] |
|
827 | 4232 |
]. |
4233 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4234 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4235 |
||
4236 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4237 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4238 |
rightPart := '' |
|
4239 |
] ifFalse:[ |
|
4240 |
removeBlanks ifTrue:[ |
|
4241 |
rightPart := rightPart withoutLeadingSeparators. |
|
4242 |
] |
|
4243 |
]. |
|
4244 |
||
4245 |
bothParts := leftPart , rightPart. |
|
4246 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4247 |
self basicListAt:lineNr put:bothParts. |
|
4248 |
self redrawLine:lineNr. |
|
4249 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4250 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4251 |
|
1319 | 4252 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4253 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4254 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4255 |
|
2952 | 4256 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4257 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4258 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4259 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4260 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4261 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4262 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4263 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4264 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4265 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4266 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4267 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4268 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4269 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4270 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4271 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4272 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4273 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4274 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4275 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4276 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4277 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4278 |
(lineSize == 0) ifTrue:[ |
4190 | 4279 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4280 |
] ifFalse: [ |
4190 | 4281 |
(colNr > lineSize) ifTrue: [ |
4282 |
newLine := line species new:colNr. |
|
4283 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4284 |
] ifFalse: [ |
|
4285 |
newLine := line copy. |
|
4286 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4287 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4288 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4289 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4290 |
newLine := self withTabsExpanded:newLine. |
4291 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4292 |
]. |
4771 | 4293 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4294 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4295 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4296 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4297 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4298 |
shown ifTrue:[ |
4190 | 4299 |
font hasOverlappingCharacters ifTrue:[ |
4300 |
self invalidateLine:lineNr. |
|
4301 |
] ifFalse:[ |
|
4302 |
drawCharacterOnly ifTrue:[ |
|
4303 |
self redrawLine:lineNr col:colNr |
|
4304 |
] ifFalse:[ |
|
4305 |
self redrawLine:lineNr from:colNr |
|
4306 |
] |
|
4307 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4308 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4309 |
|
4190 | 4310 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4311 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4312 |
! |
4313 |
||
3235 | 4314 |
basicReplaceString:aString atLine:lineNr col:colNr |
4315 |
"replace multiple characters starting at lineNr/colNr. |
|
4316 |
This is not prepared to encounter special chars (except TAB) |
|
4317 |
in the string." |
|
4318 |
||
4319 |
|line lineSize newLine endCol| |
|
4320 |
||
4321 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4322 |
||
4323 |
self checkForExistingLine:lineNr. |
|
4324 |
line := list at:lineNr. |
|
4325 |
lineSize := line size. |
|
4326 |
||
4327 |
endCol := colNr + aString size - 1. |
|
4328 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4329 |
newLine := aString species new:endCol. |
3235 | 4330 |
] ifFalse: [ |
4190 | 4331 |
(endCol > lineSize) ifTrue: [ |
4332 |
aString isText ifTrue:[ |
|
4333 |
newLine := aString species new:endCol. |
|
4334 |
] ifFalse:[ |
|
4335 |
newLine := line species new:endCol. |
|
4336 |
]. |
|
4337 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4338 |
] ifFalse: [ |
|
4339 |
aString isText ifTrue:[ |
|
4340 |
newLine := aString species new:line size. |
|
4341 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4342 |
] ifFalse:[ |
|
4343 |
newLine := line copy. |
|
4344 |
] |
|
4345 |
] |
|
3235 | 4346 |
]. |
4347 |
newLine replaceFrom:colNr with:aString. |
|
4348 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4349 |
newLine := self withTabsExpanded:newLine. |
3235 | 4350 |
]. |
4771 | 4351 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4352 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4353 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4354 |
]. |
4355 |
self textChanged. |
|
4356 |
shown ifTrue:[ |
|
4190 | 4357 |
font hasOverlappingCharacters ifTrue:[ |
4358 |
self invalidateLine:lineNr. |
|
4359 |
] ifFalse:[ |
|
4360 |
self redrawLine:lineNr from:colNr |
|
4361 |
] |
|
3235 | 4362 |
] |
4363 |
||
4190 | 4364 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4365 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4366 |
! |
4367 |
||
2952 | 4368 |
basicSplitLine:lineNr before:colNr |
4369 |
"split the line linNr before colNr; the right part (from colNr) |
|
4370 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4371 |
||
3160 | 4372 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4373 |
srcY "{ Class: SmallInteger }" | |
4374 |
||
3027 | 4375 |
list isNil ifTrue:[ ^ self ]. |
4376 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4377 |
||
4378 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4379 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4380 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4381 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4382 |
^ self |
3027 | 4383 |
]. |
4384 |
||
4385 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4386 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4387 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4388 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4389 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4390 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4391 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4392 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4393 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4394 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4395 |
] |
3027 | 4396 |
]. |
4397 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4398 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4399 |
]. |
4771 | 4400 |
self basicListAt:lineNr put:leftRest. |
3027 | 4401 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4402 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4403 |
]. |
4404 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4405 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4406 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4407 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4408 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4409 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4410 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4411 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4412 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4413 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4414 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4415 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4416 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4417 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4418 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4419 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4420 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4421 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4422 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4423 |
]. |
4424 |
widthOfWidestLine := nil. "/ unknown |
|
4425 |
self textChanged. |
|
2952 | 4426 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4427 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4428 |
! |
4429 |
||
2954 | 4430 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4431 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4432 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4433 |
because the text might have been pasted from an alien view." |
|
2954 | 4434 |
|
4435 |
|newLine newLines nLines| |
|
4436 |
||
4437 |
nLines := end - start + 1. |
|
4438 |
newLines := Array new:(lines size). |
|
4439 |
start to:end do:[:index | |
|
4328 | 4440 |
newLine := lines at:index. |
4441 |
newLine notNil ifTrue:[ |
|
4442 |
newLine isString ifTrue:[ |
|
4443 |
newLine isBlank ifTrue:[ |
|
4444 |
newLine := nil |
|
4445 |
] ifFalse:[ |
|
4446 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4447 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4448 |
] |
|
4449 |
] |
|
4450 |
] |
|
4451 |
]. |
|
4452 |
newLines at:index put:newLine |
|
2954 | 4453 |
]. |
4454 |
list isNil ifTrue: [ |
|
4328 | 4455 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4456 |
] ifFalse: [ |
4328 | 4457 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4458 |
]. |
4459 |
||
4460 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4461 |
overlapping copy - if it didn't, we had to use:" |
4462 |
" |
|
4463 |
index := list size. |
|
4464 |
[index > lineNr] whileTrue: [ |
|
4328 | 4465 |
pIndex := index - 1. |
4466 |
list at:index put:(list at:pIndex). |
|
4467 |
index := pIndex |
|
2954 | 4468 |
]. |
4469 |
" |
|
4470 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4471 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4472 |
self contentsChanged |
|
4473 |
||
4328 | 4474 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4475 |
! |
4476 |
||
4477 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4478 |
"insert aString (which has no crs) at lineNr/colNr. |
4479 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4480 |
because the text might have been pasted from an alien view." |
|
2954 | 4481 |
|
4360 | 4482 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4483 |
|
4623 | 4484 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4485 |
|
4486 |
strLen := aString size. |
|
4487 |
self checkForExistingLine:lineNr. |
|
4488 |
||
4489 |
stringType := aString string species. |
|
4490 |
isText := aString isText. |
|
4491 |
line := list at:lineNr. |
|
4492 |
||
4493 |
line notNil ifTrue:[ |
|
4328 | 4494 |
lineSize := line size. |
4495 |
line isString ifFalse:[ |
|
4496 |
stringType := line species |
|
4497 |
] ifTrue:[ |
|
4360 | 4498 |
lineCharWidth := line bitsPerCharacter. |
4499 |
stringCharWidth := aString bitsPerCharacter. |
|
4500 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4501 |
stringType := line string species |
4360 | 4502 |
] ifFalse:[ |
4503 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4504 |
stringType := aString string species |
|
4505 |
] |
|
4328 | 4506 |
]. |
4507 |
line isText ifTrue:[ isText := true ] |
|
4508 |
]. |
|
2954 | 4509 |
] ifFalse:[ |
4328 | 4510 |
lineSize := 0 |
2954 | 4511 |
]. |
4512 |
||
4513 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4514 |
newLine := aString |
2954 | 4515 |
] ifFalse:[ |
4328 | 4516 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4517 |
sz := colNr + strLen - 1 |
|
4518 |
] ifFalse:[ |
|
4519 |
sz := lineSize + strLen |
|
4520 |
]. |
|
4521 |
||
4360 | 4522 |
newLine := stringType new:sz. |
4523 |
isText ifTrue:[ |
|
4524 |
newLine := Text string:newLine |
|
4328 | 4525 |
]. |
4526 |
||
4527 |
(lineSize ~~ 0) ifTrue: [ |
|
4528 |
(colNr > lineSize) ifTrue: [ |
|
4529 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4530 |
] ifFalse: [ |
|
4531 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4532 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4533 |
] |
|
4534 |
]. |
|
4535 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4536 |
]. |
4537 |
||
4538 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4539 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4540 |
]. |
4541 |
||
4771 | 4542 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4543 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4544 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4545 |
]. |
4546 |
self textChanged. |
|
4547 |
||
4360 | 4548 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4549 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4550 |
|
2752 | 4551 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4552 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4553 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4554 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4555 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4556 |
hasKeyboardFocus := true. |
2589 | 4557 |
dragIsActive := false. |
4558 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4559 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4560 |
"/ also give that guy a chance to close its popup view |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4561 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4562 |
]. |
4609 | 4563 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4564 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4565 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4566 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4567 |
|
4420 | 4568 |
"On X11, be nice and paste PRIMARY when middle click. |
4569 |
Note, that middle button on X11 is translated to button |
|
4570 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
4421
06727bd6c8e8
Make paste button symbolic
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4420
diff
changeset
|
4571 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4572 |
self undoableDo:[ |
4573 |
self paste: (self getClipboardText:#selection). |
|
4574 |
]. |
|
4575 |
^self. |
|
4576 |
]. |
|
4577 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4578 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4579 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4580 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4581 |
"/ some very old code from times, when a right-click was a paste in X11 |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4582 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4583 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4584 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4585 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4586 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4587 |
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
|
4588 |
|
4420 | 4589 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4590 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4591 |
! |
4592 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4593 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4594 |
"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
|
4595 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4596 |
|x1 x2 x2_3 newCursorCol| |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4597 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4598 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4599 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4600 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4601 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4602 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4603 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4604 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4605 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4606 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4607 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4608 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4609 |
cursorType ~~ #block ifTrue:[ |
3790 | 4610 |
clickPos notNil ifTrue:[ |
4611 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4612 |
"/ (i.e. if its an ibeam). |
|
4613 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4614 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4615 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4616 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4617 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4618 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4619 |
]. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4620 |
self cursorLine:clickLine col:newCursorCol. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4621 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4622 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4623 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4624 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4625 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4626 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4627 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4628 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4629 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4630 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4631 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4632 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4633 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4634 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4635 |
] ifFalse:[ |
4048 | 4636 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4637 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4638 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4639 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4640 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4641 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4642 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4643 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4644 |
|
2580 | 4645 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4646 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4647 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4648 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4649 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4650 |
self changeTypeOfSelectionTo:nil. |
2580 | 4651 |
|
4652 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4653 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4654 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4655 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4656 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4657 |
self validateNewSelection. |
4420 | 4658 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4659 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4660 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4661 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4662 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4663 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4664 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4665 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4666 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4667 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4668 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4669 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4670 |
selectionEndCol == 0 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4671 |
selectionEndCol := 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4672 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4673 |
self setCursorCol:selectionEndCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4674 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4675 |
self expandSelectionRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4676 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4677 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4678 |
self unselect; makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4679 |
cursorCol == 1 ifTrue:[^ self]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4680 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4681 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4682 |
self cursorRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4683 |
^ self |
2580 | 4684 |
]. |
4685 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4686 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4687 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4688 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4689 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4690 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4691 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4692 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4693 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4694 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4695 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4696 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4697 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4698 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4699 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4700 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4701 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4702 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4703 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4704 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4705 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4706 |
self setCursorCol:selectionStartCol. |
4590 | 4707 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4708 |
self setCursorCol:1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4709 |
self setCursorLine:(cursorLine - 1). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4710 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4711 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4712 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4713 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4714 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4715 |
clickCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4716 |
self expandSelectionDown. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4717 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4718 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4719 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4720 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4721 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4722 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4723 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4724 |
self cursorDown:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4725 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4726 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4727 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4728 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4729 |
^ self |
2580 | 4730 |
]. |
4731 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4732 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4733 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4734 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4735 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4736 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4737 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4738 |
selectionStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4739 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4740 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4741 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4742 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4743 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4744 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4745 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4746 |
selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4747 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4748 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4749 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4750 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4751 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4752 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4753 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4754 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4755 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4756 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4757 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4758 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4759 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4760 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4761 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4762 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4763 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4764 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4765 |
self setCursorLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4766 |
self setCursorCol:selectionStartCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4767 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4768 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4769 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4770 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4771 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4772 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4773 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4774 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4775 |
self expandSelectionUp. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4776 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4777 |
self expandSelectionLeft. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4778 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4779 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4780 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4781 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4782 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4783 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4784 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4785 |
self cursorLeft. ^self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4786 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4787 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4788 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4789 |
self cursorUp:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4790 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4791 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4792 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4793 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4794 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4795 |
]. |
2580 | 4796 |
]. |
4420 | 4797 |
|
4798 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2580 | 4799 |
! |
4800 |
||
2952 | 4801 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4802 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4803 |
|
4521 | 4804 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4805 |
#Replace #Undo #Redo #Accept |
3780 | 4806 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 4807 |
#DeleteSpaces #Join |
3780 | 4808 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 4809 |
#SelectWord #ExpandSelectionByWord |
3780 | 4810 |
#SelectToEnd #SelectFromBeginning |
4707 | 4811 |
#SelectLine #ExpandSelectionByLine |
3780 | 4812 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
4813 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4814 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
4815 |
#GotoLine #BeginOfText #EndOfText |
|
4816 |
#InsertLine #DeleteLine |
|
4817 |
#SelectLineFromBeginning |
|
4818 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
4162 | 4819 |
#OpenSpecialCharacterWindow |
3780 | 4820 |
#'F*' #'f*')> |
2017 | 4821 |
|
4730 | 4822 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
4818 | 4823 |
immediateCompletion currentUserPrefs| |
4824 |
||
4825 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4826 |
|
4701 | 4827 |
"/ experimental |
4818 | 4828 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 4829 |
(immediateCompletion |
4818 | 4830 |
or:[currentUserPrefs codeCompletionOnControlKey |
4831 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4832 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4833 |
self initializeCompletionSupport. |
4609 | 4834 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4835 |
]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4836 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4837 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4838 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4839 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4840 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4841 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4842 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4843 |
|
4818 | 4844 |
key isSymbol ifTrue:[ |
4845 |
(device modifierKeys includes:key) ifFalse:[ |
|
4846 |
lastReplacementInfo stillCollectingInput:false. |
|
4847 |
] |
|
4848 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4849 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 4850 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4851 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4852 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4853 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4854 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 4855 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4856 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4857 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4858 |
]. |
3799 | 4859 |
(key == #Undo) ifTrue:[self undo. ^self]. |
4860 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
4861 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4862 |
self learnMode ifTrue:[ |
4482 | 4863 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4864 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4865 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4866 |
|
4238 | 4867 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
4868 |
"the macro named key exists" |
|
3780 | 4869 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4870 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4871 |
|
4482 | 4872 |
key isSymbol ifFalse:[ |
4873 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
4874 |
self handleNonCommandKey:key. |
|
4875 |
^ self |
|
4876 |
]. |
|
4877 |
||
4878 |
event isNil ifTrue:[ |
|
4879 |
event := WindowGroup lastEventQuerySignal query. |
|
4880 |
]. |
|
4881 |
shiftPressed := event hasShift. |
|
4882 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
4883 |
||
4253 | 4884 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
4885 |
self deleteWordBeforeCursor. |
|
4886 |
^ self. |
|
4887 |
]. |
|
4888 |
||
3257 | 4889 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 4890 |
selectionStartLine notNil ifTrue:[ |
4891 |
((key == #BasicBackspace) |
|
4818 | 4892 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 4893 |
ifTrue:[ |
4894 |
self deleteSelection. |
|
4895 |
] ifFalse: [ |
|
4896 |
self copyAndDeleteSelection. |
|
4897 |
]. |
|
4609 | 4898 |
] ifFalse:[ |
4899 |
self makeCursorVisible. |
|
4900 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
4901 |
"/ self deleteWordBeforeCursor. |
|
4902 |
"/ ] ifFalse:[ |
|
4903 |
self deleteCharBeforeCursor. |
|
4904 |
"/ ]. |
|
3780 | 4905 |
]. |
4738 | 4906 |
true "immediateCompletion" ifTrue:[ |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4907 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:key]. |
4731 | 4908 |
]. |
3780 | 4909 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4910 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4911 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4912 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4913 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4914 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4915 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4916 |
|
3235 | 4917 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4918 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 4919 |
^ self. |
3160 | 4920 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4921 |
|
4162 | 4922 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
4923 |
CharacterSetView notNil ifTrue:[ |
|
4924 |
self specialCharacters. |
|
4925 |
^ self. |
|
4926 |
] |
|
4927 |
]. |
|
4928 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4929 |
replacing := 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 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4932 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 4933 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4934 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4935 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4936 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4937 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 4938 |
(('[fF][0-9]' match:key) |
4939 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4940 |
shiftPressed ifFalse:[ |
|
4818 | 4941 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 4942 |
fKeyMacros notNil ifTrue:[ |
4943 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4944 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4945 |
^ self |
|
4946 |
] |
|
4947 |
] |
|
4948 |
] |
|
4949 |
]. |
|
259
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 |
|
2506 | 4952 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 4953 |
self parenthizeSelectionWith:$( and:$). |
4954 |
^ self. |
|
2506 | 4955 |
]. |
4956 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 4957 |
self parenthizeSelectionWith:$" and:$". |
4958 |
^ self. |
|
2506 | 4959 |
]. |
4960 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 4961 |
self parenthizeSelectionWith:$' and:$'. |
4962 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4963 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4964 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4965 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4966 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4967 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4968 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4969 |
(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
|
4970 |
|
4521 | 4971 |
((key == #Paste) or:[key == #Insert or:[key == #PasteFromHistory]]) ifTrue:[self pasteOrReplace. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4972 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4973 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 4974 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4975 |
|
3542 | 4976 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4977 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 4978 |
(key == #ExpandSelectionByWord) ifTrue:[ |
4979 |
self makeCursorVisible. |
|
4980 |
self findNextWordAfterSelectionAndAddToSelection. |
|
4981 |
^ self |
|
4982 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4983 |
(key == #SelectWord) ifTrue:[ |
3780 | 4984 |
self makeCursorVisible. |
4985 |
self selectWordUnderCursor. |
|
4986 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4987 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4988 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4989 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4990 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4991 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4992 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4993 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4994 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4995 |
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
|
4996 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
4997 |
(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
|
4998 |
(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
|
4999 |
(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
|
5000 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5001 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5002 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5003 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5004 |
shiftPressed ifTrue: [ |
5005 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5006 |
"/ self unselect. |
|
5007 |
"/ self cursorHome. |
|
5008 |
"Jan's modification" |
|
4257 | 5009 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
5010 |
"/ Jan's modification modified by his own request ;-)) |
|
5011 |
self selectFromBeginOfLine. |
|
3780 | 5012 |
] ifFalse: [ |
5013 |
self unselect. |
|
5014 |
ctrlPressed ifTrue:[ |
|
5015 |
self cursorHome. |
|
5016 |
] ifFalse:[ |
|
5017 |
self cursorToBeginOfLine. |
|
5018 |
] |
|
5019 |
]. |
|
5020 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5021 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5022 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5023 |
shiftPressed ifTrue:[ |
5024 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5025 |
"/ self unselect. |
|
5026 |
"/ self cursorToBottom |
|
4257 | 5027 |
" Jan's modification" |
5028 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5029 |
"/ Jan's modification modified by his own request ;-)) |
|
5030 |
self selectToEndOfLine. |
|
3780 | 5031 |
] ifFalse:[ |
5032 |
self unselect. |
|
5033 |
ctrlPressed ifTrue:[ |
|
5034 |
self cursorToBottom |
|
5035 |
] ifFalse:[ |
|
5036 |
self cursorToEndOfLine. |
|
5037 |
] |
|
5038 |
]. |
|
5039 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5040 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5041 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5042 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5043 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5044 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5045 |
|
2580 | 5046 |
(key == #CursorRight |
5047 |
or:[key == #CursorDown |
|
5048 |
or:[key == #CursorLeft |
|
5049 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3780 | 5050 |
self cursorKeyPress:key shifted:shiftPressed. |
5051 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5052 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5053 |
|
3257 | 5054 |
(key == #NonInsertingReturn) ifTrue:[ |
3780 | 5055 |
self unselect. self cursorReturn. |
5056 |
^ self |
|
3257 | 5057 |
]. |
5058 |
||
5059 |
(key == #Return) ifTrue:[ |
|
3780 | 5060 |
shiftPressed ifTrue:[ |
5061 |
self unselect. self cursorReturn. |
|
5062 |
^ self |
|
5063 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5064 |
|
3780 | 5065 |
self isReadOnly ifTrue:[ |
5066 |
self unselect; makeCursorVisible. |
|
5067 |
self cursorReturn |
|
5068 |
] ifFalse:[ |
|
5069 |
self isInInsertMode ifFalse:[ |
|
5070 |
self cursorReturn. |
|
5071 |
autoIndent == true ifTrue:[ |
|
5072 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5073 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5074 |
self cursorCol:(i+1 max:1) |
5075 |
] |
|
3780 | 5076 |
] |
5077 |
] ifTrue:[ |
|
4826 | 5078 |
|left right oldIndent| |
4812 | 5079 |
|
3780 | 5080 |
"/ old version just unselected ... |
5081 |
"/ self unselect; makeCursorVisible. |
|
5082 |
||
5083 |
"/ new version deletes ... |
|
5084 |
typeOfSelection == #paste ifTrue:[ |
|
5085 |
self unselect; makeCursorVisible. |
|
5086 |
] ifFalse:[ |
|
5087 |
self copyAndDeleteSelection. |
|
5088 |
]. |
|
4816 | 5089 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5090 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5091 |
self insertCharAtCursor:(Character cr). |
5092 |
autoIndent == true ifTrue:[ |
|
4816 | 5093 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5094 |
"/ nothing to do. |
|
4812 | 5095 |
] ifFalse:[ |
5096 |
((self listAt:cursorLine) isEmptyOrNil |
|
5097 |
or:[ cursorCol == 1 ]) ifTrue:[ |
|
5098 |
i := (self leftIndentForLine:cursorLine). |
|
4823 | 5099 |
left := left withoutSeparators. |
5100 |
right := right withoutSeparators. |
|
5101 |
(left endsWith:'[') ifTrue:[ |
|
5102 |
"/ i := i + 4. |
|
4816 | 5103 |
] ifFalse:[ |
4823 | 5104 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5105 |
i := i - 4. |
5106 |
]. |
|
4812 | 5107 |
]. |
4826 | 5108 |
oldIndent := self leftIndentOfLine:cursorLine. |
5109 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5110 |
self st80EditMode ifTrue:[ |
|
5111 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5112 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5113 |
]. |
|
5114 |
]. |
|
4812 | 5115 |
self cursorCol:(i+1 max:1) |
5116 |
]. |
|
5117 |
] |
|
3780 | 5118 |
]. |
5119 |
]. |
|
5120 |
]. |
|
5121 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
]. |
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
|
5123 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5124 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5125 |
self unselect. self cursorTab. |
5126 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5127 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5128 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5129 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5130 |
||
5131 |
self hasSelection ifTrue:[ |
|
5132 |
selectStyle == #line ifTrue:[ |
|
4238 | 5133 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5134 |
macroName := #IndentBy4. |
|
5135 |
] ifFalse:[ |
|
5136 |
macroName := #UndentBy4. |
|
5137 |
]. |
|
5138 |
macroName notNil ifTrue:[ |
|
5139 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5140 |
]. |
5141 |
] |
|
5142 |
]. |
|
5143 |
||
5144 |
self unselect. |
|
5145 |
(key == #Tab) ifTrue:[ |
|
5146 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5147 |
self cursorTab. |
|
5148 |
^ self |
|
5149 |
]. |
|
5150 |
self insertTabAtCursor. |
|
5151 |
^ self |
|
5152 |
]. |
|
5153 |
self cursorBacktab. |
|
5154 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5155 |
]. |
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
|
5156 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5157 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5158 |
(key == #Delete) ifTrue:[ |
3780 | 5159 |
shiftPressed ifTrue:[ |
5160 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5161 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5162 |
self makeCursorVisible. |
|
5163 |
self deleteCharAtCursor. |
|
5164 |
]. |
|
5165 |
^ self |
|
5166 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5167 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5168 |
|
870 | 5169 |
(key == #Delete |
5170 |
or:[key == #BasicDelete]) ifTrue:[ |
|
4129 | 5171 |
selectionStartLine notNil ifTrue:[ |
4130 | 5172 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5173 |
"/ To remove text repetetively, use Cut instead. |
|
5174 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5175 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5176 |
((key == #BasicDelete) |
4818 | 5177 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5178 |
self deleteSelection. |
5179 |
] ifFalse:[ |
|
5180 |
self copyAndDeleteSelection. |
|
5181 |
]. |
|
5182 |
^ self |
|
5183 |
]. |
|
5184 |
self makeCursorVisible. |
|
5185 |
self deleteCharAtCursor. |
|
5186 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5187 |
]. |
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
|
5188 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5189 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5190 |
self unselect. |
5191 |
cursorVisibleLine == 1 ifTrue:[ |
|
5192 |
self cursorHome. |
|
5193 |
] ifFalse:[ |
|
5194 |
self cursorToFirstVisibleLine |
|
5195 |
]. |
|
5196 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5197 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5198 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5199 |
self unselect. |
5200 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5201 |
self cursorToBottom. |
|
5202 |
] ifFalse:[ |
|
5203 |
self cursorToLastVisibleLine |
|
5204 |
]. |
|
5205 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5206 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5207 |
((key == #Escape) |
3257 | 5208 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5209 |
self makeCursorVisible. |
5210 |
self unselect. self selectCursorLineFromBeginning. |
|
5211 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5212 |
]. |
3257 | 5213 |
(key == #SelectLine) ifTrue:[ |
3780 | 5214 |
self makeCursorVisible. |
5215 |
self unselect. self selectCursorLine. |
|
5216 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5217 |
]. |
3257 | 5218 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5219 |
"/ self makeCursorVisible. |
3780 | 5220 |
self selectExpandCursorLine. |
5221 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
]. |
3257 | 5223 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5224 |
self makeCursorVisible. |
5225 |
self unselect. self deleteCursorLine. |
|
5226 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5227 |
]. |
3257 | 5228 |
(key == #InsertLine) ifTrue:[ |
3780 | 5229 |
self makeCursorVisible. |
5230 |
self unselect. self insertLine:nil before:cursorLine. |
|
5231 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5232 |
]. |
3781 | 5233 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5234 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5235 |
|
3310 | 5236 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5237 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5238 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5239 |
! |
5240 |
||
2952 | 5241 |
executeKeyboardMacro:cmdMacro |
5242 |
Error handle:[:ex | |
|
4823 | 5243 |
self warn:'Error in keyboard macro: ' , ex description. |
5244 |
ex return. |
|
2952 | 5245 |
] do:[ |
4823 | 5246 |
AbortOperationRequest handle:[:ex | |
5247 |
self warn:'Keyboard macro aborted'. |
|
5248 |
ex return. |
|
5249 |
] do:[ |
|
5250 |
Parser |
|
5251 |
evaluate:cmdMacro asString |
|
5252 |
receiver:self |
|
5253 |
notifying:nil |
|
5254 |
compile:false. |
|
5255 |
]. |
|
2952 | 5256 |
]. |
5257 |
! |
|
5258 |
||
5259 |
handleNonCommandKey:keyArg |
|
4700 | 5260 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5261 |
|
5262 |
self isReadOnly ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5263 |
self flash. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5264 |
^ self. |
2952 | 5265 |
]. |
5266 |
||
5267 |
key := keyArg. |
|
5268 |
||
5269 |
typeOfSelection == #paste ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5270 |
"pasted selection will NOT be replaced by keystroke" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5271 |
self unselect |
2952 | 5272 |
]. |
5273 |
||
4700 | 5274 |
selStartLineBefore := selectionStartLine. |
5275 |
selStartColBefore := self selectionStartCol. |
|
5276 |
selEndLineBefore := selectionEndLine. |
|
5277 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5278 |
|
4481 | 5279 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
5280 |
key isCharacter ifTrue:[ |
|
5281 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
|
5282 |
] ifFalse:[ |
|
5283 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:characterEncoding. |
|
5284 |
]. |
|
2952 | 5285 |
]. |
5286 |
||
5287 |
"replace selection by what is typed in - |
|
3235 | 5288 |
if word was selected with a space, keep it. |
4700 | 5289 |
if there was no selection, the key's character is inserted" |
3235 | 5290 |
|
5291 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5292 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5293 |
]. |
2952 | 5294 |
|
5295 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5296 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5297 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5298 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5299 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5300 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5301 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5302 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5303 |
] |
3160 | 5304 |
]. |
2952 | 5305 |
selectStyle := nil. |
5306 |
||
3235 | 5307 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5308 |
selectionStartLine := selStartLineBefore. |
5309 |
selectionStartCol := selStartColBefore. |
|
5310 |
selectionEndLine := selEndLineBefore. |
|
5311 |
selectionEndCol := selEndColBefore. |
|
3235 | 5312 |
]. |
5313 |
||
2952 | 5314 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5315 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5316 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5317 |
"claus: only do it for closing parenthesis - |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5318 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5319 |
" |
2952 | 5320 |
" |
4481 | 5321 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5322 |
" |
4481 | 5323 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5324 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5325 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5326 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5327 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5328 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5329 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5330 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5331 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5332 |
self cursorLine:line col:col. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5333 |
device flush. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5334 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5335 |
"/ want to wait 200ms, but not if another keyPress |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5336 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5337 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5338 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5339 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5340 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5341 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5342 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5343 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5344 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5345 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5346 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5347 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5348 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5349 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5350 |
] |
2952 | 5351 |
]. |
5352 |
||
5353 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5354 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5355 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5356 |
"/ |
|
5357 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5358 |
"/ self selection. |
|
5359 |
"/ typeOfSelection := #paste. |
|
3160 | 5360 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5361 |
"/ ]. |
3235 | 5362 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5363 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5364 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5365 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5366 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5367 |
]. |
3235 | 5368 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5369 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5370 |
|
5371 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5372 |
! |
5373 |
||
5374 |
keyPress:key x:x y:y |
|
5375 |
"handle keyboard input" |
|
5376 |
||
4771 | 5377 |
|wasOn| |
5378 |
||
5379 |
wasOn := cursorShown. |
|
5380 |
||
5381 |
NoModificationError handle:[:ex | |
|
5382 |
self flash. |
|
5383 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
5384 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5385 |
]. |
|
5386 |
] do:[ |
|
5387 |
self undoableDo:[ |
|
5388 |
self doKeyPress:key x:x y:y |
|
5389 |
]. |
|
4242 | 5390 |
]. |
5391 |
self repairDamage |
|
5392 |
||
5393 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
2952 | 5394 |
! |
5395 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5396 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5397 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5398 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5399 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5400 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5401 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5402 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5403 |
requestAutoAccept |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5404 |
"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
|
5405 |
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
|
5406 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5407 |
acceptEnabled == false ifTrue:[ |
4823 | 5408 |
"/ nope - |
5409 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5410 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5411 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5412 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5413 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5414 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5415 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5416 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5417 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5418 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5419 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5420 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5421 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5422 |
cv notNil ifTrue:[ |
4823 | 5423 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5424 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5425 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5426 |
|
1807 | 5427 |
!EditTextView methodsFor:'focus handling'! |
5428 |
||
4818 | 5429 |
focusOut |
5430 |
super focusOut. |
|
5431 |
||
5432 |
completionSupport notNil ifTrue:[ |
|
5433 |
completionSupport release. |
|
5434 |
]. |
|
5435 |
! |
|
5436 |
||
1807 | 5437 |
hasKeyboardFocus:aBoolean |
5438 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5439 |
(otherwise, I would not know about this)" |
|
5440 |
||
5441 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5442 |
|
3160 | 5443 |
(cursorShown |
5444 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5445 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5446 |
self drawCursor |
5447 |
]. |
|
5448 |
||
5449 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5450 |
completionSupport notNil ifTrue:[ |
4821 | 5451 |
"/ this is a hack for Windows: |
5452 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5453 |
"/ then an activate is sent to the completion popup. |
|
5454 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5455 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5456 |
"/ before forcing it to be closed... |
|
5457 |
Processor addTimedBlock:[completionSupport "release" editViewLostFocus] afterMilliseconds:200. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5458 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5459 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5460 |
|
4821 | 5461 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5462 |
! |
5463 |
||
5464 |
showFocus:explicit |
|
5465 |
"in addition to however my superclass thinks how a focusView is to be |
|
5466 |
displayed, show the cursor when I got the focus" |
|
5467 |
||
5468 |
self showCursor. |
|
5469 |
self hasKeyboardFocus:true. |
|
5470 |
super showFocus:explicit |
|
5471 |
||
5472 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5473 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5474 |
|
4818 | 5475 |
unmapped |
5476 |
super unmapped. |
|
5477 |
||
5478 |
completionSupport notNil ifTrue:[ |
|
5479 |
completionSupport release. |
|
5480 |
]. |
|
5481 |
! |
|
5482 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5483 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5484 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5485 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5486 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5487 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5488 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5489 |
and:[self enabled |
4781 | 5490 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5491 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5492 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5493 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5494 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5495 |
^ false |
1807 | 5496 |
! ! |
5497 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5498 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5499 |
|
4237 | 5500 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5501 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5502 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5503 |
|
4482 | 5504 |
|cmdMacro| |
5505 |
||
5506 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5507 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5508 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5509 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5510 |
^ true |
4238 | 5511 |
|
5512 |
" |
|
4483 | 5513 |
EditTextView open |
4238 | 5514 |
contents:'bla'; |
5515 |
selectAll; |
|
5516 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5517 |
EditTextView open |
4238 | 5518 |
contents:'bla'; |
5519 |
selectAll; |
|
5520 |
executekeyboardMacroNamed:#blabla. |
|
5521 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5522 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5523 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5524 |
! |
5525 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5526 |
indent |
3221 | 5527 |
"indent a line-range - this is done by searching for the |
5528 |
last non-empty line before the selection, and changing the indent |
|
4742 | 5529 |
of the selected line-range based on that line's indent." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5530 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5531 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5533 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5534 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5535 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5536 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5537 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5538 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5539 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5540 |
self unselect. |
3160 | 5541 |
self |
3786 | 5542 |
undoableDo:[self indentFromLine:start toLine:end] |
5543 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5544 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5545 |
|
4237 | 5546 |
indentBy4 |
4742 | 5547 |
self executekeyboardMacroNamed:#IndentBy4. |
4237 | 5548 |
|
5549 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5550 |
! |
|
5551 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5552 |
indentFromLine:start toLine:end |
3221 | 5553 |
"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
|
5554 |
last non-empty line before start, and change the indent |
4742 | 5555 |
of the selected line-range based on that line's indent." |
5556 |
||
4811 | 5557 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5558 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5559 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5560 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5561 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5562 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5563 |
(delta == 0) ifTrue:[^ self]. |
4811 | 5564 |
self indentFromLine:start toLine:end by:delta |
5565 |
! |
|
5566 |
||
5567 |
indentFromLine:start toLine:end by:delta |
|
5568 |
"indent a line-range - this is done by searching for the |
|
5569 |
last non-empty line before start, and change the indent |
|
5570 |
of the selected line-range based on that line's indent." |
|
5571 |
||
5572 |
|d line spaces anyChange| |
|
5573 |
||
5574 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5575 |
(delta > 0) ifTrue:[ |
4742 | 5576 |
spaces := String new:delta |
5577 |
]. |
|
5578 |
||
5579 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5580 |
start to:end do:[:lineNr | |
4742 | 5581 |
line := self listAt:lineNr. |
5582 |
line notNil ifTrue:[ |
|
5583 |
line isBlank ifTrue:[ |
|
4771 | 5584 |
self basicListAt:lineNr put:nil |
4742 | 5585 |
] ifFalse:[ |
5586 |
(delta > 0) ifTrue:[ |
|
5587 |
line := spaces , line. |
|
5588 |
widthOfWidestLine notNil ifTrue:[ |
|
5589 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
5590 |
] |
|
5591 |
] ifFalse:[ |
|
5592 |
"check if deletion is ok" |
|
5593 |
d := delta negated + 1. |
|
5594 |
||
5595 |
line size > d ifTrue:[ |
|
5596 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
5597 |
line := line copyFrom:d |
|
5598 |
] |
|
5599 |
]. |
|
5600 |
widthOfWidestLine := nil |
|
5601 |
]. |
|
5602 |
self replaceLine:lineNr with:line. |
|
5603 |
anyChange := true. |
|
5604 |
] |
|
5605 |
] |
|
5606 |
]. |
|
5607 |
||
5608 |
anyChange ifTrue:[ self textChanged ]. |
|
5609 |
||
3221 | 5610 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5611 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5612 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5613 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5614 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5615 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5616 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5617 |
this is done by searching for the last non-empty line before it |
4823 | 5618 |
and returning its indent. |
5619 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5620 |
|
827 | 5621 |
"SHOULD GO TO ListView" |
5622 |
||
5623 |
|line lnr indent| |
|
5624 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5625 |
lnr := lineNr. |
827 | 5626 |
|
4823 | 5627 |
"/ [lnr ~~ 1] whileTrue:[ |
5628 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 5629 |
lnr := lnr - 1. |
5630 |
line := self listAt:lnr. |
|
5631 |
||
5632 |
line notNil ifTrue:[ |
|
5633 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5634 |
indent ~~ 0 ifTrue:[ |
|
5635 |
(line endsWith:$[) ifTrue:[ |
|
5636 |
^ indent + 4 - 1 |
|
5637 |
]. |
|
5638 |
^ indent - 1 |
|
5639 |
] |
|
5640 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5641 |
]. |
827 | 5642 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5643 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5644 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5645 |
! |
5646 |
||
5647 |
undentBy4 |
|
4238 | 5648 |
self executekeyboardMacroNamed:#UndentBy4. |
4237 | 5649 |
|
5650 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
105 | 5651 |
! ! |
5652 |
||
0 | 5653 |
!EditTextView methodsFor:'initialization'! |
5654 |
||
941 | 5655 |
fetchDeviceResources |
5656 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5657 |
||
5658 |
super fetchDeviceResources. |
|
5659 |
||
1993 | 5660 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
5661 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
5662 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 5663 |
|
5664 |
"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
|
5665 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5666 |
! |
5667 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5668 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5669 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5670 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5671 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5672 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5674 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5675 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5676 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5677 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5678 |
super initStyle. |
4576 | 5679 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5680 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5681 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5682 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5683 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5684 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5685 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 5686 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
5687 |
cursorTypeNoFocus isNil ifTrue:[ |
|
5688 |
cursorTypeNoFocus := cursorType. |
|
5689 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
5690 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
5691 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5692 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5693 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5694 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 5695 |
cursorType ~~ #block ifTrue:[ |
5696 |
cursorNoFocusFgColor := cursorBgColor |
|
5697 |
] ifFalse:[ |
|
5698 |
cursorNoFocusFgColor := cursorFgColor |
|
5699 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5700 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5701 |
|
2088 | 5702 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5703 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5704 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5705 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5706 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5707 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5708 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5709 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5710 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5711 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5712 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5713 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5714 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5715 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5716 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5717 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5718 |
cursorCol := 1. |
2815 | 5719 |
cursorLineHolder := 1 asValue. |
5720 |
cursorColHolder := 1 asValue. |
|
2119 | 5721 |
modifiedChannel := ValueHolder with:false. |
5722 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
5723 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5724 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5725 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5726 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5727 |
autoIndent := false. |
3235 | 5728 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5729 |
learnMode := false asValue. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5730 |
trimBlankLines := self st80EditMode not. |
2131 | 5731 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 5732 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
5733 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5734 |
"/ enable drop by default |
2589 | 5735 |
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
|
5736 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5737 |
undoSupport := UndoSupport for:self. |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5738 |
codeAspectHolder := nil asValue. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5739 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5740 |
"Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5741 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5742 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5743 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5744 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5745 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5746 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5747 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5748 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5749 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5750 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5751 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5752 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 5753 |
! |
5754 |
||
5755 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5756 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5757 |
completionSupport release |
4771 | 5758 |
]. |
5759 |
super release |
|
0 | 5760 |
! ! |
5761 |
||
2580 | 5762 |
!EditTextView methodsFor:'macros'! |
5763 |
||
5764 |
executeLearnedKeyboardMacro |
|
4673 | 5765 |
"replay the characters as learned previously" |
5766 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5767 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5768 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5769 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5770 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5771 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5772 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5773 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5774 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5775 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5776 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5777 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5778 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5779 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5780 |
]. |
2580 | 5781 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5782 |
self flash. |
2580 | 5783 |
]. |
5784 |
! |
|
5785 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5786 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5787 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5788 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5789 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5790 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5791 |
|
2580 | 5792 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5793 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5794 |
|
2580 | 5795 |
|fg bg| |
5796 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5797 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5798 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5799 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5800 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5801 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5802 |
bg := Color black. |
2580 | 5803 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5804 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5805 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 5806 |
]. |
5807 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5808 |
! |
|
5809 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5810 |
learnModeHolder |
4673 | 5811 |
"a holder returning true, if in learn mode" |
5812 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5813 |
learnMode isNil ifTrue:[ |
4673 | 5814 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5815 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5816 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5817 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5818 |
|
4673 | 5819 |
rememberLearnedMacroAs: nameString |
5820 |
Macros isNil ifTrue:[ |
|
5821 |
Macros := Dictionary new. |
|
5822 |
]. |
|
5823 |
Macros at:nameString put:learnedMacro |
|
5824 |
! |
|
5825 |
||
2580 | 5826 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5827 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5828 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5829 |
self learnMode:(self learnMode not). |
2580 | 5830 |
! ! |
5831 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
5832 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 5833 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5834 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5835 |
"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
|
5836 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5837 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5838 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5839 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5840 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5841 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5842 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
5843 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 5844 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
5845 |
] do:[ |
|
5846 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5847 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5848 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5849 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5850 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5851 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5852 |
self unselect. |
3799 | 5853 |
self |
5854 |
undoablePaste:translated |
|
5855 |
info:'Translate' |
|
3495 | 5856 |
|
5857 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5858 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5859 |
|
3517 | 5860 |
compareWithClipboard |
5861 |
"compare the selection against the clipboard contents" |
|
5862 |
||
5863 |
|t1 t2| |
|
5864 |
||
5865 |
t2 := self getClipboardText. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5866 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 5867 |
Dialog information:'Clipboard is empty.'. |
5868 |
^ self. |
|
3517 | 5869 |
]. |
5870 |
||
5871 |
self hasSelection ifTrue:[ |
|
4823 | 5872 |
t1 := self selectionAsString. |
3517 | 5873 |
] ifFalse:[ |
4823 | 5874 |
t1 := self contents asString |
3517 | 5875 |
]. |
5876 |
t1 := t1 string. |
|
5877 |
||
5878 |
t1 = t2 ifTrue:[ |
|
4823 | 5879 |
Dialog information:'Strings are equal.'. |
5880 |
^ self. |
|
3517 | 5881 |
]. |
5882 |
DiffTextView |
|
4823 | 5883 |
openOn:t1 label:'Editor' |
5884 |
and:t2 label:'Clipboard' |
|
3517 | 5885 |
! |
5886 |
||
121 | 5887 |
cut |
5888 |
"cut selection into copybuffer" |
|
5889 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5890 |
self deleteCopyToClipboard:true |
121 | 5891 |
! |
5892 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5893 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5894 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5895 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5896 |
cursorLine notNil ifTrue:[ |
4823 | 5897 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5898 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5899 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5900 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5901 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5902 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5903 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5904 |
|
4129 | 5905 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5906 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5907 |
(self checkModificationsAllowed) ifFalse:[ |
3786 | 5908 |
self flash. |
5909 |
^ self |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5910 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5911 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5912 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5913 |
sel notNil ifTrue:[ |
4129 | 5914 |
self setLastStringToReplace: sel. |
4053 | 5915 |
|
3786 | 5916 |
line := selectionStartLine. |
5917 |
col := selectionStartCol. |
|
5918 |
||
5919 |
toClipboard ifTrue:[ |
|
5920 |
" |
|
5921 |
remember in CopyBuffer |
|
5922 |
" |
|
5923 |
self setClipboardText:sel. "/ lastString. |
|
5924 |
]. |
|
5925 |
||
5926 |
" |
|
5927 |
append to DeleteHistory (if there is one) |
|
5928 |
" |
|
5929 |
history := Smalltalk at:#DeleteHistory. |
|
5930 |
history notNil ifTrue:[ |
|
5931 |
history addAll:(sel asStringCollection). |
|
5932 |
history size > 1000 ifTrue:[ |
|
5933 |
history := history copyFrom:(history size - 1000) |
|
5934 |
]. |
|
5935 |
]. |
|
5936 |
||
5937 |
" |
|
5938 |
now, delete it |
|
5939 |
" |
|
5940 |
self |
|
5941 |
undoableDo:[self deleteSelection] |
|
5942 |
info:'Delete'. |
|
4048 | 5943 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5944 |
] ifFalse:[ |
3786 | 5945 |
" |
5946 |
a cut without selection will search&cut again |
|
5947 |
" |
|
5948 |
self undoableDo:[ |
|
5949 |
self again |
|
5950 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5951 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5952 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5953 |
"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
|
5954 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5955 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5956 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5957 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5958 |
|
3781 | 5959 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5960 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 5961 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 5962 |
#ToggleAutoIndent #ToggleInsertMode |
5963 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
5964 |
<resource: #programMenu> |
1054 | 5965 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5966 |
|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
|
5967 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 5968 |
|
2460 | 5969 |
items := #( |
3781 | 5970 |
('Redo' redo Redo ) |
5971 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 5972 |
('-' ) |
5973 |
('Search...' search Find ) |
|
5974 |
('Goto Line...' gotoLine GotoLine ) |
|
5975 |
('-' ) |
|
4213 | 5976 |
('Tools' tools ) ). |
5977 |
CharacterSetView notNil ifTrue:[ |
|
5978 |
items := items , |
|
5979 |
#( |
|
5980 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
5981 |
). |
|
5982 |
]. |
|
5983 |
items := items , #( |
|
3731 | 5984 |
('-' ) |
5985 |
('Save As...' save SaveAs ) |
|
5986 |
('Print' doPrint Print ) |
|
5987 |
('=' ) |
|
4213 | 5988 |
('Misc' misc ShiftCtrl) ). |
2460 | 5989 |
|
2866 | 5990 |
miscItems := #( |
3781 | 5991 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
5992 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 5993 |
('-' ) |
5994 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 5995 |
('Join Lines' joinLines Join ) |
4388 | 5996 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 5997 |
('-' ) |
3781 | 5998 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
5999 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6000 |
('-' ) |
3811 | 6001 |
('Insert File...' insertFile ) |
6002 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6003 |
('Insert new UUID' insertUUID ) |
6004 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6005 |
('-' ) |
6006 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6007 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6008 |
('-' ) |
6009 |
). |
|
4213 | 6010 |
"/ CharacterSetView notNil ifTrue:[ |
6011 |
"/ miscItems := miscItems , |
|
6012 |
"/ #( |
|
6013 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6014 |
"/ ). |
|
6015 |
"/ ]. |
|
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
6016 |
miscItems := miscItems , |
3731 | 6017 |
#( |
6018 |
('Font...' changeFont ) |
|
2870 | 6019 |
"/ ('Encoding...' changeEncoding ) |
3731 | 6020 |
). |
2866 | 6021 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6022 |
translateItems := #( |
3731 | 6023 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6024 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6025 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6026 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6027 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6028 |
('-' ) |
|
6029 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6030 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6031 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6032 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6033 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6034 |
). |
|
3221 | 6035 |
|
6036 |
sortItems := #( |
|
3731 | 6037 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6038 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6039 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6040 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6041 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6042 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6043 |
('-' ) |
|
4373 | 6044 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6045 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6046 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6047 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6048 |
('-' ) |
6049 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6050 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6051 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6052 |
|
2762 | 6053 |
toolItems := #( |
3731 | 6054 |
('Indent' indent ) |
4287 | 6055 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6056 |
('Sort' sort ) |
6057 |
('-' ) |
|
4742 | 6058 |
('Google Spell Check' googleSpellingSuggestion ) |
6059 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6060 |
('Translate' babelFishTranslate ) |
6061 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6062 |
). |
|
2762 | 6063 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6064 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6065 |
toolItems := toolItems , #( |
6066 |
('-' ) |
|
6067 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6068 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6069 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6070 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6071 |
|
2460 | 6072 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6073 |
sub receiver:self. |
2460 | 6074 |
|
2919 | 6075 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6076 |
toolSub receiver:self. |
|
6077 |
sub subMenuAt:#tools put:toolSub. |
|
6078 |
||
3495 | 6079 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6080 |
transSub receiver:self. |
|
6081 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6082 |
||
6083 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6084 |
sortSub receiver:self. |
|
6085 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6086 |
|
2866 | 6087 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6088 |
subSub receiver:self. |
|
2952 | 6089 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6090 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6091 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
6092 |
|
2866 | 6093 |
sub subMenuAt:#misc put:subSub. |
6094 |
||
3495 | 6095 |
mainItems := #( |
3731 | 6096 |
('Undo' undo Undo ) |
6097 |
('Again' again Again ) |
|
6098 |
('-' ) |
|
6099 |
('Cut' cut Cut ) |
|
6100 |
('Copy' copySelection Copy ) |
|
6101 |
('Paste' pasteOrReplace Paste ) |
|
6102 |
('-' ) |
|
6103 |
('Accept' accept Accept ) |
|
6104 |
('=' ) |
|
6105 |
('More' others Ctrl ) |
|
6106 |
). |
|
3495 | 6107 |
main := PopUpMenu itemList:mainItems resources:resources. |
6108 |
main subMenuAt:#others put:sub. |
|
6109 |
||
6110 |
sensor := self sensor. |
|
6111 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6112 |
sensor shiftDown ifTrue:[ |
|
3731 | 6113 |
m := subSub |
6114 |
] ifFalse:[ |
|
6115 |
m := sub |
|
6116 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6117 |
] ifFalse:[ |
3731 | 6118 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6119 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6120 |
|
4742 | 6121 |
"/ the 'Smalltalk at:' code is here to |
6122 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6123 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6124 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6125 |
m disable:#googleSpellingSuggestion |
|
2676 | 6126 |
]. |
4742 | 6127 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6128 |
m disable:#internalSpellingSuggestion |
|
6129 |
]. |
|
2676 | 6130 |
|
3811 | 6131 |
HTTPInterface isNil ifTrue:[ |
6132 |
m disableAll:#(insertURL) |
|
6133 |
]. |
|
6134 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6135 |
self isReadOnly ifTrue:[ |
4475 | 6136 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6137 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6138 |
cut indent autoIndent: insertMode: |
|
3811 | 6139 |
insertFile insertFileAsStringLiteral insertURL |
6140 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6141 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6142 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
3731 | 6143 |
specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6144 |
]. |
2817 | 6145 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6146 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6147 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6148 |
self hasSelection ifFalse:[ |
3731 | 6149 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt openWorkspaceWithIt sort indent). |
2762 | 6150 |
] ifTrue:[ |
3731 | 6151 |
(Error handle:[:ex | |
6152 |
ex return:false |
|
6153 |
] do:[ |
|
4042 | 6154 |
|fn| |
6155 |
fn := self selectionAsString. |
|
6156 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6157 |
]) ifFalse:[ |
6158 |
m disableAll:#(openFileBrowserOnIt). |
|
6159 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6160 |
]. |
2569 | 6161 |
self hasUndoAction ifFalse:[ |
3731 | 6162 |
m disable:#undo. |
3115 | 6163 |
] ifTrue:[ |
3731 | 6164 |
what := undoSupport undoActionInfo. |
6165 |
what notNil ifTrue:[ |
|
6166 |
undoIdx := m indexOf:#undo. |
|
6167 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6168 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6169 |
]. |
2952 | 6170 |
self hasRedoAction ifFalse:[ |
3731 | 6171 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6172 |
] ifTrue:[ |
3731 | 6173 |
what := undoSupport redoActionInfo. |
6174 |
what notNil ifTrue:[ |
|
6175 |
redoIdx := sub indexOf:#redo. |
|
6176 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6177 |
] |
|
2952 | 6178 |
]. |
1108 | 6179 |
acceptEnabled == false ifTrue:[ |
3731 | 6180 |
m disable:#accept |
1108 | 6181 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6182 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6183 |
|
4388 | 6184 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6185 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6186 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6187 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6188 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6189 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6190 |
history := device getCopyBufferHistory copy. |
3160 | 6191 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6192 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6193 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6194 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6195 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6196 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6197 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6198 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6199 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6200 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6201 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6202 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6203 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6204 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6205 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6206 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6207 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6208 |
box label:(resources string:'Select Previous Copybuffer String'). |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6209 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6210 |
box show. |
3160 | 6211 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6212 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6213 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6214 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6215 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6216 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6217 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6218 |
self sensor shiftDown ifTrue:[ |
3855 | 6219 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6220 |
]. |
2724 | 6221 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6222 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6223 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6224 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6225 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6226 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6227 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6228 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6229 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6230 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6231 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6232 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6233 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6234 |
"Modified: / 13-07-2011 / 14:55:58 / cg" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6235 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6236 |
|
2676 | 6237 |
googleSpellingSuggestion |
6238 |
"insert the google-spelling suggestion for the selected text. |
|
6239 |
Requires that the SOAP stuff is loaded and working." |
|
6240 |
||
2677 | 6241 |
|text suggestion| |
2676 | 6242 |
|
6243 |
self withWaitCursorDo:[ |
|
3799 | 6244 |
text := self selection asString string withoutSeparators. |
6245 |
text size == 0 ifTrue:[^ self]. |
|
6246 |
||
4742 | 6247 |
"/ the 'Smalltalk at:' code is here to |
6248 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6249 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6250 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6251 |
^ self. |
|
6252 |
] do:[ |
|
4742 | 6253 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6254 |
]. |
6255 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6256 |
self information:('No spelling suggestion from Google for: ' , text). |
6257 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6258 |
^ self. |
6259 |
]. |
|
6260 |
]. |
|
6261 |
self |
|
6262 |
undoablePaste:suggestion |
|
6263 |
info:'Spelling Suggestion'. |
|
3495 | 6264 |
|
6265 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6266 |
! |
6267 |
||
3595 | 6268 |
insertDateAndTime |
6269 |
"insert the curent date and time string" |
|
6270 |
||
6271 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6272 |
self |
3786 | 6273 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6274 |
info:'Paste Date and Time' |
3595 | 6275 |
! |
6276 |
||
2676 | 6277 |
insertFile |
3160 | 6278 |
"insert contents of a file |
2676 | 6279 |
- ask user for filename using a fileSelectionBox." |
6280 |
||
3731 | 6281 |
self insertFileAsStringLiteral:false |
6282 |
! |
|
6283 |
||
6284 |
insertFileAsStringLiteral |
|
6285 |
"insert a file's contents as a string literal. |
|
6286 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6287 |
to make it a legal string literal" |
|
6288 |
||
6289 |
self insertFileAsStringLiteral:true |
|
6290 |
! |
|
6291 |
||
6292 |
insertFileAsStringLiteral:asStringLiteral |
|
6293 |
"insert contents of a file; either as-is or as a string literal. |
|
6294 |
- ask user for filename using a fileSelectionBox." |
|
6295 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6296 |
|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
|
6297 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6298 |
((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
|
6299 |
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
|
6300 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6301 |
ifTrue:[ |
3731 | 6302 |
initial := selFn pathName. |
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6303 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6304 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6305 |
[ |
3731 | 6306 |
|why| |
6307 |
||
6308 |
file := Dialog |
|
6309 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6310 |
default:initial |
|
6311 |
ok:(resources string:'Insert') |
|
6312 |
abort:(resources string:'Cancel') |
|
6313 |
pattern:nil |
|
6314 |
fromDirectory:directoryForFileDialog. |
|
6315 |
file isNil ifTrue:[ |
|
6316 |
"cancel" |
|
6317 |
^ self. |
|
6318 |
]. |
|
6319 |
file := file asFilename. |
|
6320 |
directoryForFileDialog := file. |
|
6321 |
||
6322 |
ok := file isReadable and:[file isDirectory not]. |
|
6323 |
ok ifFalse:[ |
|
6324 |
file isReadable ifFalse:[ |
|
6325 |
why := '%1 is unreadable.\\Please try again.' |
|
6326 |
] ifTrue:[ |
|
6327 |
why := '%1 is a directory.\\Please try again.' |
|
6328 |
]. |
|
6329 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6330 |
]. |
|
2909 | 6331 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6332 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6333 |
text := file contentsOfEntireFile. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6334 |
self |
3786 | 6335 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6336 |
info:'Paste File' |
3495 | 6337 |
|
6338 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6339 |
! |
|
6340 |
||
3811 | 6341 |
insertURL |
6342 |
"insert contents of a URL |
|
6343 |
- ask user for URL using a dialog." |
|
6344 |
||
6345 |
self insertURLAsStringLiteral:false |
|
6346 |
! |
|
6347 |
||
6348 |
insertURLAsStringLiteral:asStringLiteral |
|
6349 |
"insert contents of a file; either as-is or as a string literal. |
|
6350 |
- ask user for filename using a fileSelectionBox." |
|
6351 |
||
6352 |
|sel url text response initial| |
|
6353 |
||
6354 |
(sel := self selectionAsString) notEmptyOrNil |
|
6355 |
ifTrue:[ |
|
6356 |
initial := sel. |
|
6357 |
]. |
|
6358 |
||
6359 |
url := Dialog |
|
6360 |
request:(resources string:'Insert Contents of URL:') |
|
6361 |
initialAnswer:initial |
|
6362 |
okLabel:(resources string:'Insert') |
|
6363 |
title:(resources string:'URL'). |
|
6364 |
url isNil ifTrue:[ |
|
6365 |
"cancel" |
|
6366 |
^ self. |
|
6367 |
]. |
|
6368 |
response := HTTPInterface get:url. |
|
6369 |
response isErrorResponse ifTrue:[ |
|
6370 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6371 |
^ self. |
|
6372 |
]. |
|
6373 |
text := response data asString. |
|
6374 |
||
6375 |
self |
|
6376 |
undoableDo:[ |
|
6377 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6378 |
] |
|
6379 |
info:'Insert Contents of URL' |
|
6380 |
! |
|
6381 |
||
3495 | 6382 |
insertUUID |
6383 |
"insert a new UUID's string" |
|
6384 |
||
6385 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6386 |
self |
3786 | 6387 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6388 |
info:'Paste New UUID' |
3495 | 6389 |
|
6390 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6391 |
! |
6392 |
||
4742 | 6393 |
internalSpellingSuggestion |
6394 |
"insert the internal-spelling suggestion for the selected text. |
|
6395 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6396 |
||
6397 |
|text suggestions best| |
|
6398 |
||
6399 |
self withWaitCursorDo:[ |
|
6400 |
text := self selection asString string withoutSeparators. |
|
6401 |
text size == 0 ifTrue:[^ self]. |
|
6402 |
||
6403 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6404 |
suggestions size == 0 ifTrue:[ |
|
6405 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6406 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6407 |
^ self. |
|
6408 |
]. |
|
6409 |
Transcript showCR:suggestions. |
|
6410 |
best := suggestions first. |
|
6411 |
]. |
|
6412 |
self |
|
6413 |
undoablePaste:best |
|
6414 |
info:'Spelling Suggestion'. |
|
6415 |
! |
|
6416 |
||
2762 | 6417 |
openFileBrowserOnIt |
6418 |
"open a fileBrowser on the selected fileName" |
|
6419 |
||
4630 | 6420 |
|fn| |
2762 | 6421 |
|
6422 |
fn := self selectionAsString asFilename. |
|
6423 |
fn exists ifFalse:[ |
|
4042 | 6424 |
fn := self selectionAsString withoutSeparators withoutQuotes asFilename. |
6425 |
fn exists ifFalse:[ |
|
6426 |
^ self warn:'Oops - file is gone'. |
|
6427 |
]. |
|
2762 | 6428 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6429 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6430 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6431 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6432 |
! |
6433 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6434 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6435 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6436 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6437 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6438 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6439 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6440 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6441 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6442 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6443 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6444 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6445 |
paste |
1289 | 6446 |
"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
|
6447 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6448 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6449 |
self checkModificationsAllowed ifTrue:[ |
4823 | 6450 |
self withSelfAndTextForPasteDo:[:me :text | |
6451 |
me unselect. |
|
6452 |
me undoablePaste:text |
|
6453 |
] |
|
2952 | 6454 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6455 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6456 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6457 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6458 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6459 |
|
3825 | 6460 |
self paste:someText withCR:false |
6461 |
! |
|
6462 |
||
6463 |
paste:someText withCR:withCR |
|
6464 |
"paste someText at cursor" |
|
6465 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6466 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6467 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6468 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6469 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6470 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6471 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6472 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6473 |
CharacterEncoderError handle:[:ex | |
3825 | 6474 |
|code msg| |
6475 |
||
6476 |
code := ex parameter. |
|
6477 |
codingErrorReported ifFalse:[ |
|
6478 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
|
6479 |
code notNil ifTrue:[ |
|
6480 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6481 |
]. |
|
6482 |
Dialog warn:(resources stringWithCRs:msg). |
|
6483 |
codingErrorReported := true. |
|
6484 |
]. |
|
6485 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6486 |
] do:[ |
3825 | 6487 |
s isString ifTrue:[ |
6488 |
s encoding ~~ characterEncoding ifTrue:[ |
|
6489 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
6490 |
]. |
|
6491 |
||
6492 |
s := s asStringCollection. |
|
6493 |
(someText endsWith:Character cr) ifTrue:[ |
|
6494 |
"/ s := s copyWith:nil. |
|
6495 |
s := s copyWith:'' "/ an empty line at the end |
|
6496 |
||
6497 |
] |
|
6498 |
] ifFalse:[ |
|
6499 |
s isStringCollection ifTrue:[ |
|
6500 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
6501 |
] ifFalse:[ |
|
6502 |
(self |
|
6503 |
confirm:(resources |
|
6504 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6505 |
with:s class name)) ifFalse:[^ self]. |
|
6506 |
s := StringCollection with:s storeString . |
|
6507 |
"/ ^ self |
|
6508 |
]. |
|
6509 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6510 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6511 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6512 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6513 |
(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
|
6514 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6515 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6516 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6517 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6518 |
startCol := c1 := cursorCol. |
3180 | 6519 |
|
4328 | 6520 |
"do not expand tabs into spaces here - |
3180 | 6521 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
6522 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6523 |
||
3825 | 6524 |
self insertLines:s withCR:withCR. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6525 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6526 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6527 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6528 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6529 |
|
4328 | 6530 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6531 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6532 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6533 |
|
3731 | 6534 |
pasteAsStringLiteral |
6535 |
"insert clipboard string as a string literal. |
|
6536 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6537 |
to make it a legal string literal" |
|
6538 |
||
6539 |
typeOfSelection := nil. |
|
6540 |
self |
|
3786 | 6541 |
undoableDo:[ self pasteOrReplace:(self getClipboardText storeString) ] |
6542 |
info:'Paste as String Literal' |
|
3731 | 6543 |
! |
6544 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6545 |
pasteOrReplace |
1289 | 6546 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6547 |
otherwise paste at cursor position. |
6548 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6549 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6550 |
|
2724 | 6551 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6554 |
pasteOrReplace:someText |
1289 | 6555 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6556 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6557 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6558 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6559 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6560 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6561 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6562 |
self undoableDo:[ |
4823 | 6563 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
6564 |
self replace:someText |
|
6565 |
] ifFalse:[ |
|
6566 |
self paste:someText. |
|
6567 |
] |
|
3542 | 6568 |
] info:'Paste/Replace'. |
1289 | 6569 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6570 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6571 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6572 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6573 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6574 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6575 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6576 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6577 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6578 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6579 |
self checkModificationsAllowed ifFalse:[ |
4823 | 6580 |
self flash. |
6581 |
^ self |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6582 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6583 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6584 |
text notNil ifTrue:[ |
4823 | 6585 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6586 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6587 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6588 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6589 |
replace |
1289 | 6590 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6591 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6592 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6593 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6594 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6595 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 6596 |
me undoableDo:[ me replace:text ] |
6597 |
info:'Replace' |
|
2952 | 6598 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6599 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6600 |
|
121 | 6601 |
replace:someText |
1289 | 6602 |
"replace the selection by someText" |
121 | 6603 |
|
3160 | 6604 |
|selected selectedString |
6605 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 6606 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6607 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6608 |
|
3130 | 6609 |
self undoableDo:[ |
4010 | 6610 |
selected := self selection. |
6611 |
selected isNil ifTrue:[ |
|
6612 |
^ self paste:someText |
|
6613 |
]. |
|
6614 |
||
6615 |
self deleteSelection. |
|
6616 |
||
6617 |
"take care, if we replace a selection without space by a word selected |
|
6618 |
with one - in this case we usually do not want the space. |
|
6619 |
But, if we replace a word-selected selection by something without a |
|
6620 |
space, we DO want the space added." |
|
6621 |
||
6622 |
selected size == 1 ifTrue:[ |
|
6623 |
selectedString := selected at:1. |
|
6624 |
]. |
|
6625 |
||
6626 |
someText size == 1 ifTrue:[ |
|
6627 |
|cutOffSpace addSpace replacement replacementString| |
|
6628 |
||
6629 |
cutOffSpace := false. |
|
6630 |
addSpace := false. |
|
6631 |
replacement := someText copyFrom:1. |
|
6632 |
||
6633 |
selectedString notNil ifTrue:[ |
|
6634 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
6635 |
"selection has no space" |
|
6636 |
||
6637 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
6638 |
cutOffSpace := true |
|
6639 |
] |
|
6640 |
] ifTrue:[ |
|
6641 |
addSpace := true |
|
6642 |
] |
|
6643 |
]. |
|
6644 |
replacementString := replacement at:1. |
|
6645 |
cutOffSpace ifTrue:[ |
|
6646 |
(replacementString startsWith:' ') ifTrue:[ |
|
6647 |
replacementString := replacementString withoutSpaces |
|
6648 |
]. |
|
6649 |
] ifFalse:[ |
|
6650 |
selectStyle == #wordLeft ifTrue:[ |
|
6651 |
"want a space at left" |
|
6652 |
(replacementString startsWith:' ') ifFalse:[ |
|
6653 |
replacementString := replacementString withoutSpaces. |
|
6654 |
replacementString := ' ' , replacementString |
|
6655 |
] |
|
6656 |
]. |
|
6657 |
selectStyle == #wordRight ifTrue:[ |
|
6658 |
"want a space at right" |
|
6659 |
||
6660 |
(replacementString endsWith:' ') ifFalse:[ |
|
6661 |
replacementString := replacementString withoutSpaces. |
|
6662 |
replacementString := replacementString , ' ' |
|
6663 |
] |
|
6664 |
]. |
|
6665 |
]. |
|
6666 |
replacement at:1 put: replacementString. |
|
6667 |
self paste:replacement. |
|
6668 |
] ifFalse:[ |
|
6669 |
self paste:someText |
|
6670 |
]. |
|
4053 | 6671 |
self setLastStringToReplace: selectedString. |
6672 |
||
4048 | 6673 |
lastReplacementInfo lastReplacement: someText. |
4010 | 6674 |
|
6675 |
selStartLine := selectionStartLine. |
|
6676 |
selStartCol := self selectionStartCol. |
|
6677 |
selEndLine := selectionEndLine. |
|
6678 |
selEndCol := self selectionEndCol. |
|
3130 | 6679 |
] |
3542 | 6680 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
6681 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6682 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6683 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 6684 |
! |
6685 |
||
3430 | 6686 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6687 |
"search for a string - show a box to enter searchpattern |
3430 | 6688 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
6689 |
- currently no regular expressions are handled." |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6690 |
|
3430 | 6691 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
6692 |
||
6693 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
6694 |
lastSearchDirection := #forward. |
|
6695 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
6696 |
caseHolder := ign asValue. |
|
6697 |
patternHolder := '' asValue. |
|
6698 |
replacePatternHolder := '' asValue. |
|
6699 |
lastSearchPattern notNil ifTrue:[ |
|
4823 | 6700 |
initialString := lastSearchPattern |
3430 | 6701 |
]. |
6702 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 6703 |
initialString := self selectionAsString |
3430 | 6704 |
]. |
6705 |
initialString isNil ifTrue:[ |
|
4823 | 6706 |
LastSearchPatterns size > 0 ifTrue:[ |
6707 |
initialString := LastSearchPatterns first |
|
6708 |
] |
|
3430 | 6709 |
]. |
6710 |
initialString notNil ifTrue:[ |
|
4823 | 6711 |
patternHolder value:initialString. |
6712 |
replacePatternHolder value:initialString. |
|
3430 | 6713 |
]. |
6714 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6715 |
search := [:fwd | |
4823 | 6716 |
self |
6717 |
search:patternHolder value |
|
6718 |
ignoreCase:caseHolder value |
|
6719 |
forward:fwd. |
|
6720 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6721 |
replace := [:all | |
4823 | 6722 |
self |
6723 |
replace:patternHolder value |
|
6724 |
by:replacePatternHolder value |
|
6725 |
all:all |
|
6726 |
ignoreCase:caseHolder value |
|
6727 |
]. |
|
3430 | 6728 |
bindings := IdentityDictionary new. |
6729 |
bindings at:#searchPattern put:patternHolder. |
|
6730 |
bindings at:#replacePattern put:replacePatternHolder. |
|
6731 |
modal ifTrue:[ |
|
4823 | 6732 |
bindings at:#nextAction |
6733 |
put:[ |
|
6734 |
flag := true. |
|
6735 |
action := search. |
|
6736 |
searchBox doAccept. |
|
6737 |
]. |
|
6738 |
bindings at:#prevAction |
|
6739 |
put:[ |
|
6740 |
flag := false. |
|
6741 |
action := search. |
|
6742 |
searchBox doAccept. |
|
6743 |
]. |
|
6744 |
bindings at:#replaceAction |
|
6745 |
put:[ |
|
6746 |
flag := false. |
|
6747 |
action := replace. |
|
6748 |
searchBox doAccept. |
|
6749 |
]. |
|
6750 |
bindings at:#replaceAllAction |
|
6751 |
put:[ |
|
6752 |
flag := true. |
|
6753 |
action := replace. |
|
6754 |
searchBox doAccept. |
|
6755 |
]. |
|
3430 | 6756 |
] ifFalse:[ |
4823 | 6757 |
bindings at:#nextAction put:[ search value:true. ]. |
6758 |
bindings at:#prevAction put:[ search value:false. ]. |
|
6759 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
6760 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 6761 |
]. |
6762 |
bindings at:#ignoreCase put:caseHolder. |
|
6763 |
bindings at:#patternList put:LastSearchPatterns. |
|
6764 |
modal ifTrue:[ |
|
4823 | 6765 |
searchBox := SimpleDialog new. |
3430 | 6766 |
] ifFalse:[ |
4823 | 6767 |
searchBox := ApplicationModel new. |
6768 |
searchBox createBuilder. |
|
3430 | 6769 |
]. |
6770 |
searchBox resources:(self resources). |
|
6771 |
bldr := searchBox builder. |
|
6772 |
bldr addBindings:bindings. |
|
6773 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
6774 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
6775 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
6776 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
6777 |
modal ifTrue:[ |
|
4823 | 6778 |
searchBox openDialog. |
6779 |
searchBox accepted ifTrue:[ |
|
6780 |
action value:flag |
|
6781 |
]. |
|
3430 | 6782 |
] ifFalse:[ |
4823 | 6783 |
(bldr componentAt:#nextButton) isReturnButton:false. |
6784 |
(bldr componentAt:#cancelButton) |
|
6785 |
label:(resources string:'Close'); |
|
6786 |
action:[ searchBox closeRequest ]. |
|
6787 |
||
6788 |
"/ searchBox masterApplication:self application. |
|
6789 |
||
6790 |
self topView beMaster. |
|
6791 |
(searchBox window) |
|
6792 |
beSlave; |
|
6793 |
openInGroup:(self windowGroup). |
|
6794 |
||
6795 |
"/ searchBox window open. |
|
6796 |
||
6797 |
searchBox window assignKeyboardFocusToFirstInputField. |
|
3430 | 6798 |
] |
6799 |
||
6800 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6801 |
! |
|
6802 |
||
121 | 6803 |
showDeleted |
6804 |
"open a readonly editor on all deleted text" |
|
6805 |
||
6806 |
|v| |
|
6807 |
||
6808 |
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
|
6809 |
v readOnly:true. |
121 | 6810 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6811 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6812 |
|
3221 | 6813 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 6814 |
"sort/reorder the selected lines. |
6815 |
how: |
|
6816 |
#lines |
|
6817 |
#linesByFirstWord |
|
6818 |
#linesByNthWord |
|
6819 |
#linesByNthNumber |
|
6820 |
#linesByNthHexNumber |
|
6821 |
#words |
|
6822 |
#linesByLength |
|
6823 |
#reverse |
|
6824 |
" |
|
6825 |
||
6826 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 6827 |
|
6828 |
lineWise := true. |
|
6829 |
||
4763 | 6830 |
how == #reverse ifTrue:[ |
6831 |
operation := [:lines | lines reverse]. |
|
6832 |
] ifFalse:[ |
|
6833 |
operation := [:linesOrWords | |
|
6834 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
6835 |
]. |
|
6836 |
||
6837 |
how == #linesByLength ifTrue:[ |
|
6838 |
fetcher := [:l | l size]. |
|
6839 |
] ifFalse:[ |
|
6840 |
how == #lines ifTrue:[ |
|
6841 |
extractor := [:l | l withoutLeadingSeparators]. |
|
6842 |
] ifFalse:[ |
|
6843 |
how == #linesByFirstWord ifTrue:[ |
|
6844 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
6845 |
] ifFalse:[ |
|
6846 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
6847 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
6848 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
6849 |
n := Integer readFrom:nStr onError:[^ self]. |
|
6850 |
LastColumnNumberForSort := n. |
|
6851 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
6852 |
how == #linesByNthNumber ifTrue:[ |
|
6853 |
innerExtractor := extractor. |
|
6854 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
6855 |
] ifFalse:[ |
|
6856 |
how == #linesByNthHexNumber ifTrue:[ |
|
6857 |
innerExtractor := extractor. |
|
6858 |
extractor := [:l | |
|
6859 |
|s| |
|
6860 |
s := innerExtractor value:l. |
|
6861 |
(s startsWith:'16r') ifTrue:[ |
|
6862 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
6863 |
] ifFalse:[ |
|
6864 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
6865 |
] |
|
6866 |
] |
|
4753 | 6867 |
] |
4763 | 6868 |
]. |
6869 |
] ifFalse:[ |
|
6870 |
how == #words ifTrue:[ |
|
6871 |
lineWise := false. |
|
6872 |
extractor := [:w | w]. |
|
6873 |
] ifFalse:[ |
|
6874 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 6875 |
] |
4373 | 6876 |
] |
6877 |
] |
|
4763 | 6878 |
]. |
6879 |
ignoreCase ifTrue:[ |
|
6880 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
6881 |
] ifFalse:[ |
|
6882 |
fetcher := extractor. |
|
6883 |
]. |
|
6884 |
]. |
|
3221 | 6885 |
]. |
6886 |
||
6887 |
lineWise ifTrue:[ |
|
4763 | 6888 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 6889 |
start == end ifTrue:[^ self ]. |
6890 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 6891 |
lines := operation value:lines. |
4373 | 6892 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 6893 |
] ifFalse:[ |
6894 |
"process the whole selection as a string" |
|
6895 |
s := self selectionAsString. |
|
6896 |
words := s asCollectionOfWords. |
|
6897 |
words := operation value:words. |
|
6898 |
s := words asStringCollection asStringWith:Character space. |
|
6899 |
self replace:s. |
|
6900 |
]. |
|
3221 | 6901 |
self textChanged. |
4373 | 6902 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6903 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 6904 |
! |
6905 |
||
6906 |
sortSelection:how ignoreCase:ignoreCase |
|
6907 |
"sort the selected lines" |
|
6908 |
||
6909 |
|start end| |
|
6910 |
||
6911 |
selectionStartLine isNil ifTrue:[^ self]. |
|
6912 |
||
6913 |
start := selectionStartLine. |
|
6914 |
end := selectionEndLine. |
|
6915 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 6916 |
end := end - 1 |
3221 | 6917 |
]. |
6918 |
||
6919 |
self |
|
4373 | 6920 |
undoableDo:[ |
6921 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
6922 |
] |
|
3786 | 6923 |
info:'Sort' |
4373 | 6924 |
|
6925 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 6926 |
! |
6927 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6928 |
specialCharacters |
2915 | 6929 |
CharacterSetView |
4823 | 6930 |
openAsInputFor:self |
6931 |
label:'Special Character Input' |
|
6932 |
clickLabel:'Click to Insert Character'. |
|
2866 | 6933 |
! |
6934 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6935 |
undoablePaste:someText |
3495 | 6936 |
self undoablePaste:someText info:nil. |
6937 |
||
6938 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
6939 |
! |
|
6940 |
||
6941 |
undoablePaste:someText info:infoOrNil |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6942 |
self |
4823 | 6943 |
undoableDo:[ |
6944 |
self paste:someText. |
|
6945 |
] |
|
6946 |
info:infoOrNil |
|
3495 | 6947 |
|
6948 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
6949 |
! |
|
6950 |
||
6951 |
undoablePasteOrReplace:someText info:infoOrNil |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6952 |
self |
4823 | 6953 |
undoableDo:[ |
6954 |
self pasteOrReplace:someText. |
|
6955 |
] |
|
6956 |
info:infoOrNil |
|
3495 | 6957 |
|
6958 |
"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
|
6959 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6960 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6961 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6962 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6963 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6964 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6965 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6966 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6967 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6968 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6969 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6970 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6971 |
|
2724 | 6972 |
withSelfAndTextForPasteDo:aBlock |
6973 |
"common code for paste/replace of the copybuffer" |
|
6974 |
||
6975 |
|sel| |
|
6976 |
||
6977 |
self checkModificationsAllowed ifFalse:[ |
|
4823 | 6978 |
self flash. |
6979 |
^ self |
|
2724 | 6980 |
]. |
6981 |
||
6982 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
6983 |
sel notNil ifTrue:[ |
|
4823 | 6984 |
aBlock value:self value:sel. |
2724 | 6985 |
] |
105 | 6986 |
! ! |
6987 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6988 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6989 |
|
3880 | 6990 |
beep |
6991 |
UserPreferences current beepInEditor ifTrue:[ |
|
6992 |
super beep |
|
6993 |
] |
|
6994 |
! |
|
6995 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6996 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6997 |
"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
|
6998 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6999 |
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
|
7000 |
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
|
7001 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7002 |
self isReadOnly ifTrue: [ |
4823 | 7003 |
exceptionBlock isNil ifTrue:[ |
7004 |
^ false |
|
7005 |
]. |
|
7006 |
||
7007 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7008 |
^ false |
|
7009 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7010 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7011 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7012 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7013 |
"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
|
7014 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7015 |
|
2596 | 7016 |
currentSelectionBgColor |
7017 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7018 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7019 |
]. |
7020 |
^ super currentSelectionBgColor |
|
7021 |
||
7022 |
" |
|
7023 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7024 |
" |
|
7025 |
! |
|
7026 |
||
7027 |
currentSelectionFgColor |
|
7028 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7029 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7030 |
]. |
7031 |
^ super currentSelectionFgColor |
|
7032 |
! |
|
7033 |
||
3996 | 7034 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7035 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7036 |
|
7037 |
super resetVariablesBeforeNewSearch. |
|
7038 |
||
7039 |
"/ new search invalidates remembered string |
|
4048 | 7040 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7041 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7042 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7043 |
! |
7044 |
||
4053 | 7045 |
setLastStringToReplace: aString |
7046 |
||
7047 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7048 |
||
7049 |
|lastReplaceIgnoredCase| |
|
7050 |
||
4064 | 7051 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7052 |
self clearSearchAction. |
|
7053 |
||
4053 | 7054 |
lastReplacementInfo lastStringToReplace: aString. |
7055 |
lastStringFromReplaceForNextSearch := aString. |
|
7056 |
||
7057 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7058 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7059 |
ifTrue: [lastSearchIgnoredCase] |
|
7060 |
ifFalse: [nil]. |
|
4053 | 7061 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7062 |
! |
|
7063 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7064 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7065 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7066 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7067 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7068 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7069 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7070 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7071 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7072 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7073 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7074 |
textChanged |
522 | 7075 |
"my text was modified (internally). |
7076 |
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
|
7077 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7078 |
is used to notify scrollers, other views etc.). |
7079 |
||
7080 |
As some authors of this code have been very sloppy in tha past |
|
7081 |
(not sending contentsChanged, but textChanged), |
|
7082 |
we do it here despite what is written above, to ensure that scrollers update correctly." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7083 |
|
641 | 7084 |
self contentsChanged. |
1015 | 7085 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7086 |
contentsWasSaved := false |
641 | 7087 |
|
1015 | 7088 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7089 |
! |
7090 |
||
2617 | 7091 |
textChangedButNoSizeChange |
2207 | 7092 |
"my text was modified (internally). |
7093 |
Sent whenever text has been edited (not to confuse with |
|
7094 |
contentsChanged, which is triggered when the size has changed, and |
|
7095 |
is used to notify scrollers, other views etc.)" |
|
7096 |
||
7097 |
self modified:true. |
|
7098 |
contentsWasSaved := false |
|
7099 |
||
7100 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7101 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7102 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7103 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7104 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7105 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7106 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7107 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7108 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7109 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7110 |
"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
|
7111 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7112 |
|
4064 | 7113 |
hasSearchActionSelection |
7114 |
||
7115 |
^ typeOfSelection == #searchAction |
|
7116 |
! |
|
7117 |
||
1878 | 7118 |
isKeyboardConsumer |
7119 |
"return true, if the receiver is a keyboard consumer; |
|
7120 |
Return true here, redefined from SimpleView." |
|
7121 |
||
3476 | 7122 |
^ self isReadOnly not |
1878 | 7123 |
! |
7124 |
||
997 | 7125 |
specClass |
1390 | 7126 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7127 |
||
997 | 7128 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7129 |
^ super specClass |
7130 |
||
1390 | 7131 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7132 |
! |
7133 |
||
324 | 7134 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7135 |
"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
|
7136 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7137 |
"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
|
7138 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7139 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7140 |
|
7141 |
"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
|
7142 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7143 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7144 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7145 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7146 |
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
|
7147 |
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
|
7148 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7149 |
|
697 | 7150 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7151 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7152 |
w := super widthOfContents. |
697 | 7153 |
(dev := device) isNil ifTrue:[ |
4823 | 7154 |
"/ really dont know ... |
7155 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7156 |
]. |
697 | 7157 |
^ w + (font widthOn:dev) |
7158 |
||
7159 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7160 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7161 |
|
1588 | 7162 |
!EditTextView methodsFor:'realization'! |
7163 |
||
7164 |
realize |
|
7165 |
"make the view visible - scroll to make the cursor visible." |
|
7166 |
||
7167 |
super realize. |
|
7168 |
||
7169 |
self makeCursorVisible. |
|
1993 | 7170 |
cursorFgColor := cursorFgColor onDevice:device. |
7171 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7172 |
|
7173 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7174 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7175 |
! ! |
|
7176 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7177 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7178 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7179 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7180 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7181 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7182 |
cursorShown ifTrue:[ |
4823 | 7183 |
cursorVisibleLine notNil ifTrue:[ |
7184 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7185 |
self drawCursorCharacter |
|
7186 |
] |
|
7187 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7188 |
] |
105 | 7189 |
! |
7190 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7191 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7192 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7194 |
cursorShown ifTrue:[ |
4823 | 7195 |
(visLine == cursorVisibleLine) ifTrue:[ |
7196 |
self drawCursorCharacter |
|
7197 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7198 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7199 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7200 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7201 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7202 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7203 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7204 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7205 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7206 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7207 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7208 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7209 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7210 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7211 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7212 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7213 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7214 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7215 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7216 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7217 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7218 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7219 |
cursorShown ifTrue:[ |
4823 | 7220 |
(visLine == cursorVisibleLine) ifTrue:[ |
7221 |
(colNr == cursorCol) ifTrue:[ |
|
7222 |
self drawCursorCharacter. |
|
7223 |
^ self |
|
7224 |
] |
|
7225 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7226 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7227 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7228 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7229 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7230 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7231 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7232 |
"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
|
7233 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7234 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7235 |
cursorShown ifTrue:[ |
7236 |
self redrawCursorIfInVisibleLine:visLine |
|
7237 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7238 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7240 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7241 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7242 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7243 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7244 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7245 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7246 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7247 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7248 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7249 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7250 |
"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
|
7251 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7252 |
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
|
7253 |
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
|
7254 |
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
|
7255 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7256 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7257 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7258 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7259 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7260 |
"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
|
7261 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7262 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7263 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7264 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7265 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7266 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7267 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7268 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7269 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7270 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7271 |
"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
|
7272 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7273 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7274 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7275 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7276 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7277 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7278 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7279 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7280 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7281 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7282 |
"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
|
7283 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7284 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7285 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7286 |
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
|
7287 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7288 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7289 |
prevCursorState ifTrue:[ |
4823 | 7290 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7291 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7292 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7293 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7294 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7295 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7296 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7297 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7298 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7299 |
prevCursorState := cursorShown. |
1601 | 7300 |
"/ cursorShown := false. |
1591 | 7301 |
cursorShown ifTrue:[ |
4823 | 7302 |
self hideCursor |
1591 | 7303 |
] |
7304 |
||
1601 | 7305 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7306 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7307 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7308 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7309 |
"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
|
7310 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7311 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7312 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7313 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7314 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7315 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7316 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7317 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7318 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7319 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7320 |
"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
|
7321 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7322 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7323 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7324 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7325 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7326 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7327 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7328 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7329 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7330 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7331 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7332 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7333 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7334 |
|
2822 | 7335 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7336 |
! |
7337 |
||
7338 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7339 |
"do a backward search" |
|
7340 |
||
7341 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7342 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7343 |
! |
7344 |
||
7345 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7346 |
"do a backward search" |
|
7347 |
||
7348 |
cursorLine isNil ifTrue:[^ self]. |
|
7349 |
||
3160 | 7350 |
self |
4119 | 7351 |
searchBackwardFor:pattern |
7352 |
ignoreCase:ign |
|
7353 |
startingAtLine:startLine col:startCol |
|
7354 |
ifFound:[:line :col | |
|
7355 |
self cursorMovementAllowed ifTrue:[ |
|
7356 |
self cursorLine:line col:col. |
|
7357 |
]. |
|
7358 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7359 |
"/ self makeLineVisible:cursorLine |
4119 | 7360 |
typeOfSelection := #search] |
7361 |
ifAbsent:aBlock |
|
1339 | 7362 |
|
7363 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7364 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7365 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7366 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7367 |
"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
|
7368 |
|
2554 | 7369 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7370 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7371 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7372 |
searchForMatchingParenthesis |
3160 | 7373 |
"search for a matching parenthesis starting at cursor position. |
7374 |
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
|
7375 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7376 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7377 |
|
2822 | 7378 |
self cursorMovementAllowed ifFalse:[^ self]. |
7379 |
||
3160 | 7380 |
self |
4823 | 7381 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
7382 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7383 |
ifNotFound:[self showNotFound] |
|
7384 |
onError:[self beep] |
|
1339 | 7385 |
|
7386 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7387 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7388 |
|
3967 | 7389 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7390 |
"do a forward search" |
7391 |
||
7392 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7393 |
self |
7394 |
searchForwardFor:pattern |
|
7395 |
ignoreCase:ign |
|
7396 |
match: match |
|
7397 |
startingAtLine:startLine col:startCol |
|
7398 |
ifFound:[:line :col | |
|
7399 |
self cursorMovementAllowed ifTrue:[ |
|
7400 |
self cursorLine:line col:col. |
|
7401 |
]. |
|
4119 | 7402 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7403 |
"/ self makeLineVisible:cursorLine |
3967 | 7404 |
typeOfSelection := #search |
7405 |
] |
|
7406 |
ifAbsent:aBlock |
|
1339 | 7407 |
|
7408 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7409 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7410 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7411 |
|
3967 | 7412 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7413 |
"do a forward search" |
|
7414 |
||
7415 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7416 |
! |
|
7417 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7418 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7419 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7420 |
|
2822 | 7421 |
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
|
7422 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7423 |
|
3982 | 7424 |
searchPatternForSearchBar |
7425 |
||
7426 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7427 |
||
7428 |
|searchPattern| |
|
7429 |
||
4138 | 7430 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7431 |
searchPattern isNil |
7432 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7433 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7434 |
^ searchPattern |
|
7435 |
! |
|
7436 |
||
3578 | 7437 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7438 |
"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
|
7439 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7440 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7441 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7442 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7443 |
"/ |
3967 | 7444 |
"/ if the last operation was a replace, set pattern to last |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7445 |
"/ original string (for search after again) |
4121 | 7446 |
"/ for cut or delete actions allow lastReplacement with nil |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7447 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7448 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7449 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7450 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7451 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7452 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7453 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7454 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7455 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7456 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7457 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7458 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7459 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7460 |
"/ 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
|
7461 |
"/ if there was a previous search, only take the selection if |
3967 | 7462 |
"/ it did not result from a paste or from the last search itself. |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7463 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7464 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7465 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7466 |
sel notNil ifTrue:[ |
3967 | 7467 |
(lastSearchPattern isNil |
4484 | 7468 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7469 |
) ifTrue:[ |
|
3967 | 7470 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7471 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7472 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7473 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7474 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7475 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7476 |
"Modified: / 07-05-2011 / 17:25:59 / cg" |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7477 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7478 |
|
4484 | 7479 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7480 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7481 |
typeOfSelection := #search. |
|
7482 |
! |
|
7483 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7484 |
startPositionForSearchBackward |
2822 | 7485 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7486 |
! |
|
7487 |
||
7488 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7489 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7490 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7491 |
selectionStartLine notNil ifTrue:[ |
4823 | 7492 |
startLine := selectionStartLine. |
7493 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7494 |
] ifFalse:[ |
4823 | 7495 |
cursorLine isNil ifTrue:[ |
7496 |
startLine := list size. |
|
7497 |
startCol := self listAt:startLine size. |
|
7498 |
] ifFalse:[ |
|
7499 |
startLine := cursorLine min:list size. |
|
7500 |
startCol := cursorCol |
|
7501 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7502 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7503 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7504 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7505 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7506 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7507 |
startPositionForSearchForward |
2822 | 7508 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7509 |
! |
|
7510 |
||
7511 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7512 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7513 |
|
3160 | 7514 |
"/ 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
|
7515 |
"/ 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
|
7516 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7517 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7518 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7519 |
] ifFalse:[ |
4064 | 7520 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7521 |
startCol := 0 |
|
7522 |
]. |
|
7523 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7524 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7525 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7526 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7527 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7528 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7529 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7530 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7531 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7532 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7533 |
addToSelectionAfter:aBlock |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7534 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7535 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7536 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7537 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7538 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7539 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7540 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7541 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7542 |
self hasSelection ifTrue: [ |
4823 | 7543 |
startLine := selectionStartLine . |
7544 |
startCol := selectionStartCol . |
|
7545 |
endLine := selectionEndLine . |
|
7546 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7547 |
] ifFalse: [ |
4823 | 7548 |
startLine := endLine := cursorLine . |
7549 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7550 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7551 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7552 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7553 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7554 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7555 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7556 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7557 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
4823 | 7558 |
ifTrue: [ |
7559 |
startCol := cursorCol. |
|
7560 |
] ifFalse: [ |
|
7561 |
endCol := cursorCol - 1. |
|
7562 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7563 |
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
|
7564 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7565 |
|
1850 | 7566 |
autoMoveCursorToEndOfSelection |
7567 |
"return true, if the cursor should be automatically moved to the |
|
7568 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
7569 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 7570 |
not be affected by selecting" |
7571 |
||
7572 |
^ true |
|
7573 |
! |
|
7574 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7575 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7576 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 7577 |
typeOfSelection := newType. |
7578 |
selectionStartLine notNil ifTrue:[ |
|
7579 |
self |
|
7580 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
7581 |
toLine:selectionEndLine col:selectionEndCol |
|
7582 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7583 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7584 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7585 |
|
4707 | 7586 |
findNextWordAfterSelectionAndAddToSelection |
7587 |
|selStartCol selStartLine selEndCol selEndLine| |
|
7588 |
||
7589 |
selectionStartCol isNil ifTrue:[ |
|
7590 |
self selectWordUnderCursor. |
|
7591 |
^ self |
|
7592 |
]. |
|
7593 |
||
7594 |
selStartCol := selectionStartCol. |
|
7595 |
selEndCol := selectionEndCol. |
|
7596 |
selStartLine := selectionStartLine. |
|
7597 |
selEndLine := selectionEndLine. |
|
7598 |
||
7599 |
self cursorToNextWord. |
|
7600 |
self selectWordUnderCursor. |
|
7601 |
||
7602 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
7603 |
! |
|
7604 |
||
4138 | 7605 |
searchPatternFromUserSelectionOrReplace |
7606 |
||
7607 |
|sel searchPattern| |
|
7608 |
||
7609 |
"/ |
|
7610 |
"/ if the last operation was a replace, set pattern to last |
|
7611 |
"/ original string (for search after again) |
|
7612 |
"/ |
|
7613 |
(lastStringFromReplaceForNextSearch notNil |
|
7614 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
7615 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
7616 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
7617 |
] ifFalse:[ |
|
7618 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
7619 |
]. |
|
7620 |
^ searchPattern |
|
7621 |
]. |
|
7622 |
||
7623 |
"/ |
|
7624 |
"/ if there is a selection: |
|
7625 |
"/ if there was no previous search, take it as search pattern. |
|
7626 |
"/ if there was a previous search, only take the selection if |
|
7627 |
"/ it did not result from a paste. |
|
7628 |
"/ (to allow search-paste to be repeated) |
|
7629 |
"/ |
|
7630 |
sel := self selection. |
|
7631 |
sel notNil ifTrue:[ |
|
7632 |
typeOfSelection ~~ #search ifTrue:[ |
|
7633 |
typeOfSelection ~~ #paste ifTrue:[ |
|
7634 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
7635 |
searchPattern := sel asStringWithoutFinalCR. |
|
7636 |
] |
|
7637 |
]. |
|
7638 |
]. |
|
7639 |
||
7640 |
^ searchPattern |
|
7641 |
! |
|
7642 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7643 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7644 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7645 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7646 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7648 |
list isNil ifTrue:[ |
4823 | 7649 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7650 |
] ifFalse:[ |
4823 | 7651 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
7652 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7653 |
] |
1082 | 7654 |
|
7655 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7656 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7657 |
|
4117 | 7658 |
selectAllInitially |
7659 |
"select the whole text. This is called only once during the initialization |
|
7660 |
for editFields which are shown in a table or tree. |
|
7661 |
The selectAll is called via this method to allow for easier redefinition and |
|
7662 |
to distinguish auto-select from user-initiated selects." |
|
7663 |
||
7664 |
self selectAll |
|
7665 |
! |
|
7666 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7667 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7668 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7669 |
|
3160 | 7670 |
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
|
7671 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7672 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7673 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7674 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7675 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7676 |
cursorCol > 1 ifTrue:[ |
4823 | 7677 |
self selectFromLine:cursorLine col:1 |
7678 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7679 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7680 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7681 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7682 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7683 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7684 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7685 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7686 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7687 |
selectionStartLine isNil ifTrue:[ |
4823 | 7688 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7689 |
] ifFalse:[ |
4823 | 7690 |
self selectFromLine:selectionStartLine col:selectionStartCol |
7691 |
toLine:cursorLine+1 col:0. |
|
7692 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7693 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7694 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7695 |
|
4257 | 7696 |
selectFromBeginOfLine |
7697 |
"select the text from the beginning of the current line to the current cursor position." |
|
7698 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7699 |
| newCursorCol ln | |
4271 | 7700 |
|
4257 | 7701 |
list isNil ifTrue:[ |
7702 |
self unselect |
|
7703 |
] ifFalse:[ |
|
7704 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7705 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7706 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 7707 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
7708 |
cursorCol := newCursorCol. |
|
4257 | 7709 |
typeOfSelection := nil |
7710 |
] |
|
7711 |
] |
|
7712 |
||
7713 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7714 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7715 |
! |
7716 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7717 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7718 |
"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
|
7719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7720 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7721 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7722 |
list isNil ifTrue:[ |
4823 | 7723 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7724 |
] ifFalse:[ |
4823 | 7725 |
cursorCol == 0 ifTrue:[ |
7726 |
col := 0 |
|
7727 |
] ifFalse:[ |
|
7728 |
col := cursorCol - 1 |
|
7729 |
]. |
|
7730 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
7731 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7732 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7733 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7734 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7735 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7736 |
"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
|
7737 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7739 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 7740 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
4823 | 7741 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 7742 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7743 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7744 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7745 |
|
4257 | 7746 |
selectToEndOfLine |
7747 |
"select the text from the current cursor position to the end of the current line" |
|
7748 |
||
4271 | 7749 |
| newCursorCol line | |
7750 |
||
4257 | 7751 |
list isNil ifTrue:[ |
7752 |
self unselect |
|
7753 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7754 |
cursorCol >= 1 ifTrue:[ |
4271 | 7755 |
line := list at: cursorLine. |
7756 |
newCursorCol := line size. |
|
7757 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
7758 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
7759 |
||
7760 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
7761 |
cursorCol := newCursorCol. |
|
4257 | 7762 |
typeOfSelection := nil |
7763 |
] |
|
7764 |
] |
|
7765 |
||
7766 |
"Created: / 28-06-2011 / 23:07:07 / cg" |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7767 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7768 |
! |
7769 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7770 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7771 |
"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
|
7772 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7773 |
list isNil ifTrue:[ |
4823 | 7774 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7775 |
] ifFalse:[ |
4823 | 7776 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
7777 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7778 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7779 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7780 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7781 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7782 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7783 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7784 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7785 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7786 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7787 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7788 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7789 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7790 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7792 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7793 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7794 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7795 |
wasOn ifTrue:[self showCursor] |
105 | 7796 |
! ! |
7797 |
||
7798 |
!EditTextView methodsFor:'undo & again'! |
|
7799 |
||
2952 | 7800 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7801 |
^ undoSupport addUndo:action. |
2952 | 7802 |
! |
7803 |
||
105 | 7804 |
again |
7805 |
"repeat the last action (which was a cut or replace). |
|
7806 |
If current selection is not last string, search forward to |
|
3160 | 7807 |
next occurrence of it before repeating the last operation." |
105 | 7808 |
|
4048 | 7809 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 7810 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 7811 |
|
7812 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 7813 |
lastStringToReplace isNil ifTrue:[ |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7814 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7815 |
]. |
4048 | 7816 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
7817 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7818 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7819 |
self undoableDo:[ |
4010 | 7820 |
s := lastStringToReplace asString. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7821 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
7822 |
(s endsWith:Character cr) ifTrue:[s := s copyButLast:1]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7823 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 7824 |
|
4053 | 7825 |
"set lastStringToReplace as the next search string |
7826 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 7827 |
lastStringFromReplaceForNextSearch := s. |
4053 | 7828 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 7829 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7830 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7831 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7832 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7833 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7834 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7835 |
"if we are already there (after a find), ommit search" |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7836 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7837 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7838 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7839 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7840 |
self deleteSelection. |
4051 | 7841 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7842 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7843 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 7844 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7845 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7846 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7847 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7848 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7849 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7850 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7851 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7852 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7853 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7854 |
]. |
4048 | 7855 |
self |
7856 |
searchForwardFor:s |
|
7857 |
ignoreCase: lastReplaceIgnoredCase |
|
7858 |
match: lastReplaceWasMatch |
|
7859 |
startingAtLine:cursorLine col:startColForSearch |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7860 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7861 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7862 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7863 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7864 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7865 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7866 |
self selectFromLine:line col:col |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7867 |
toLine:line col:(col + s size - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7868 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7869 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7870 |
self deleteSelection. |
4051 | 7871 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7872 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
7873 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7874 |
] ifTrue:[ |
4051 | 7875 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7876 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7877 |
self insertLines:repl asStringCollection withCR:false. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7878 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7879 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7880 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7881 |
selectStyle := savedSelectStyle. |
4484 | 7882 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7883 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7884 |
] |
4048 | 7885 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7886 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7887 |
self sensor compressKeyPressEventsWithKey:#Again. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7888 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7889 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7890 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7891 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7892 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7893 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7894 |
^ true. |
501 | 7895 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
7896 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 7897 |
! |
7898 |
||
2952 | 7899 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7900 |
^ undoSupport hasRedoAction. |
2952 | 7901 |
! |
7902 |
||
7903 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7904 |
^ undoSupport hasUndoAction. |
2952 | 7905 |
! |
7906 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7907 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7908 |
"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
|
7909 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7910 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7911 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7912 |
|
2952 | 7913 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7914 |
undoSupport nonUndoableDo:aBlock. |
2952 | 7915 |
! |
7916 |
||
7917 |
redo |
|
3780 | 7918 |
"undo the last undo" |
7919 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7920 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 7921 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7922 |
] ifTrue:[ |
3780 | 7923 |
undoSupport redo. |
2952 | 7924 |
] |
7925 |
! |
|
7926 |
||
121 | 7927 |
undo |
3780 | 7928 |
"undo the last edit operation" |
7929 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7930 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 7931 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7932 |
] ifTrue:[ |
3780 | 7933 |
undoSupport undo. |
121 | 7934 |
] |
2952 | 7935 |
! |
7936 |
||
7937 |
undoableDo:aBlock |
|
3495 | 7938 |
self undoableDo:aBlock info:nil. |
7939 |
||
7940 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 7941 |
! |
7942 |
||
7943 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
7944 |
self checkModificationsAllowed ifFalse:[ |
4823 | 7945 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
7946 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
7947 |
] ifTrue:[ |
4823 | 7948 |
undoSupport undoableDo:aBlock info:aString. |
3495 | 7949 |
]. |
7950 |
||
7951 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 7952 |
! ! |
7953 |
||
7954 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
7955 |
||
7956 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
7957 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
7958 |
! |
|
7959 |
||
3115 | 7960 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 7961 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 7962 |
! |
7963 |
||
2952 | 7964 |
line:arg1 col:arg2 character:arg3 |
7965 |
^ self new line:arg1 col:arg2 character:arg3 |
|
7966 |
! |
|
7967 |
||
3115 | 7968 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 7969 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 7970 |
! |
7971 |
||
3235 | 7972 |
line:arg1 col:arg2 characters:arg3 info:info |
7973 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
7974 |
! |
|
7975 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7976 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7977 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7978 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7979 |
|
2952 | 7980 |
line:arg1 col:arg2 string:arg3 |
7981 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 7982 |
! |
7983 |
||
7984 |
line:arg1 col:arg2 string:arg3 info:info |
|
7985 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 7986 |
! |
7987 |
||
7988 |
line:arg1 string:arg3 info:info |
|
7989 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 7990 |
! |
7991 |
||
7992 |
text:arg info:info |
|
7993 |
^ (self new text:arg) info:info |
|
3115 | 7994 |
! ! |
7995 |
||
7996 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
7997 |
||
7998 |
info |
|
7999 |
^ userFriendlyInfo |
|
8000 |
! |
|
8001 |
||
8002 |
info:aString |
|
8003 |
userFriendlyInfo := aString |
|
2952 | 8004 |
! ! |
8005 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8006 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8007 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8008 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8009 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8010 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8011 |
"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
|
8012 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8013 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8014 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8015 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8016 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8017 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8018 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8019 |
|
2952 | 8020 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8021 |
||
3160 | 8022 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8023 |
"set instance variables (automatically generated)" |
8024 |
||
8025 |
self assert:(line1Arg notNil). |
|
8026 |
self assert:(col1Arg notNil). |
|
8027 |
self assert:(line2Arg notNil). |
|
8028 |
self assert:(col2Arg notNil). |
|
8029 |
||
8030 |
line1 := line1Arg. |
|
8031 |
col1 := col1Arg. |
|
8032 |
line2 := line2Arg. |
|
8033 |
col2 := col2Arg. |
|
8034 |
! ! |
|
8035 |
||
8036 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8037 |
||
3160 | 8038 |
executeIn:editor |
2952 | 8039 |
editor unselect. |
3160 | 8040 |
editor |
4823 | 8041 |
deleteFromLine:line1 |
8042 |
col:col1 |
|
8043 |
toLine:line2 |
|
8044 |
col:col2. |
|
2952 | 8045 |
editor cursorLine:line1 col:col1. |
8046 |
! ! |
|
8047 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8048 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8049 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8050 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8051 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8052 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8053 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8054 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8055 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8056 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8057 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8058 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8059 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8060 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8061 |
|
3160 | 8062 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8063 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8064 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8065 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8066 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8067 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8068 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8069 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8070 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8071 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8072 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8073 |
|
3160 | 8074 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8075 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8076 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8077 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8078 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8079 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8080 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8081 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8082 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8083 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8084 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8085 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8086 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8087 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8088 |
|
3160 | 8089 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8090 |
"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
|
8091 |
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
|
8092 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8093 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8094 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8095 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8096 |
^ true |
|
8097 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8098 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8099 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8100 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8101 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8102 |
|
3160 | 8103 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8104 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8105 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8106 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8107 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8108 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8109 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8110 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8111 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8112 |
|
3160 | 8113 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8114 |
editor unselect. |
3160 | 8115 |
editor |
4823 | 8116 |
deleteFromLine:line |
8117 |
col:col1 |
|
8118 |
toLine:line |
|
8119 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8120 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8121 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8122 |
|
3235 | 8123 |
!EditTextView::EditMode class methodsFor:'constants'! |
8124 |
||
8125 |
insertAndSelectMode |
|
8126 |
^ InsertAndSelectMode |
|
8127 |
! |
|
8128 |
||
8129 |
insertMode |
|
8130 |
^ InsertMode |
|
8131 |
! |
|
8132 |
||
8133 |
overwriteMode |
|
8134 |
^ OverwriteMode |
|
8135 |
! ! |
|
8136 |
||
8137 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8138 |
||
8139 |
isInsertAndSelectMode |
|
8140 |
^ false |
|
8141 |
! |
|
8142 |
||
8143 |
isInsertMode |
|
8144 |
^ false |
|
8145 |
! |
|
8146 |
||
8147 |
symbolicName |
|
8148 |
self subclassResponsibility |
|
8149 |
! ! |
|
8150 |
||
8151 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8152 |
||
8153 |
infoPrintString |
|
8154 |
^ 'IS' |
|
8155 |
! ! |
|
8156 |
||
8157 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8158 |
||
8159 |
isInsertAndSelectMode |
|
8160 |
^ true |
|
8161 |
! |
|
8162 |
||
8163 |
isInsertMode |
|
8164 |
^ true |
|
8165 |
! ! |
|
8166 |
||
8167 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8168 |
||
8169 |
infoPrintString |
|
8170 |
^ 'I' |
|
8171 |
! ! |
|
8172 |
||
8173 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8174 |
||
8175 |
isInsertMode |
|
8176 |
^ true |
|
8177 |
! ! |
|
8178 |
||
8179 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8180 |
||
8181 |
infoPrintString |
|
8182 |
^ 'O' |
|
8183 |
! ! |
|
8184 |
||
4048 | 8185 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8186 |
||
8187 |
lastReplaceIgnoredCase |
|
8188 |
^ lastReplaceIgnoredCase ? false |
|
8189 |
! |
|
8190 |
||
8191 |
lastReplaceIgnoredCase:something |
|
8192 |
lastReplaceIgnoredCase := something. |
|
8193 |
! |
|
8194 |
||
8195 |
lastReplaceWasMatch |
|
8196 |
^ lastReplaceWasMatch ? false |
|
8197 |
! |
|
8198 |
||
8199 |
lastReplaceWasMatch:something |
|
8200 |
lastReplaceWasMatch := something. |
|
8201 |
! |
|
8202 |
||
8203 |
lastReplacement |
|
8204 |
^ lastReplacement |
|
8205 |
! |
|
8206 |
||
8207 |
lastReplacement:something |
|
4053 | 8208 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8209 |
lastReplacement := something. |
8210 |
! |
|
8211 |
||
8212 |
lastStringToReplace |
|
8213 |
^ lastStringToReplace |
|
8214 |
! |
|
8215 |
||
8216 |
lastStringToReplace:something |
|
8217 |
lastStringToReplace := something. |
|
4818 | 8218 |
! |
8219 |
||
8220 |
previousReplacements |
|
8221 |
^ previousReplacements ? #() |
|
8222 |
! |
|
8223 |
||
8224 |
stillCollectingInput |
|
8225 |
^ stillCollectingInput |
|
8226 |
! |
|
8227 |
||
8228 |
stillCollectingInput:aBoolean |
|
8229 |
stillCollectingInput := aBoolean. |
|
8230 |
! ! |
|
8231 |
||
8232 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8233 |
||
8234 |
rememberReplacement |
|
8235 |
"remember the previous replacement (called when a new one appears). |
|
8236 |
Mostly for the benefit of the code completion..." |
|
8237 |
||
8238 |
|oldString newString| |
|
8239 |
||
8240 |
oldString := lastStringToReplace. |
|
8241 |
newString := lastReplacement. |
|
8242 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
8243 |
previousReplacements isNil ifTrue:[ |
|
8244 |
previousReplacements := OrderedCollection new. |
|
8245 |
]. |
|
8246 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
8247 |
previousReplacements addFirst:(oldString -> newString). |
|
8248 |
previousReplacements size > 20 ifTrue:[ |
|
8249 |
previousReplacements removeLast. |
|
8250 |
] |
|
8251 |
]. |
|
4048 | 8252 |
! ! |
8253 |
||
2952 | 8254 |
!EditTextView::PasteString methodsFor:'accessing'! |
8255 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8256 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8257 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8258 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8259 |
"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
|
8260 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8261 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8262 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8263 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8264 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8265 |
"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
|
8266 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8267 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8268 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8269 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8270 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8271 |
"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
|
8272 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8273 |
|
3160 | 8274 |
line:lineArg col:colArg string:stringArg |
2952 | 8275 |
self assert:(lineArg notNil). |
8276 |
self assert:(colArg notNil). |
|
8277 |
self assert:(stringArg notNil). |
|
8278 |
||
8279 |
line := lineArg. |
|
8280 |
col := colArg. |
|
8281 |
string := stringArg. |
|
8282 |
! |
|
8283 |
||
8284 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8285 |
self assert:(lineArg notNil). |
|
8286 |
self assert:(colArg notNil). |
|
8287 |
self assert:(stringArg notNil). |
|
8288 |
||
8289 |
line := lineArg. |
|
8290 |
col := colArg. |
|
8291 |
string := stringArg. |
|
8292 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8293 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8294 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8295 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8296 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8297 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8298 |
"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
|
8299 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8300 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8301 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8302 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8303 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8304 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8305 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8306 |
"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
|
8307 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8308 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8309 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8310 |
"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
|
8311 |
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
|
8312 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8313 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8314 |
previousPasteAction line == line ifTrue:[ |
4823 | 8315 |
previousPasteAction col == (self col2+1) ifTrue:[ |
8316 |
^ true |
|
8317 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8318 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8319 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8320 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8321 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8322 |
"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
|
8323 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8324 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8325 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8326 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8327 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8328 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8329 |
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
|
8330 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8331 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8332 |
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
|
8333 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8334 |
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
|
8335 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8336 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8337 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8338 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8339 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8340 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8341 |
! ! |
8342 |
||
8343 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8344 |
||
3160 | 8345 |
executeIn:editor |
2952 | 8346 |
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
|
8347 |
editor paste:string. |
2952 | 8348 |
selected ~~ true ifTrue:[ |
4823 | 8349 |
editor unselect |
2952 | 8350 |
]. |
8351 |
! ! |
|
8352 |
||
8353 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8354 |
||
3235 | 8355 |
col |
8356 |
^ col |
|
8357 |
! |
|
8358 |
||
8359 |
col1 |
|
8360 |
^ col |
|
8361 |
! |
|
8362 |
||
8363 |
col2 |
|
8364 |
^ col |
|
8365 |
! |
|
8366 |
||
8367 |
line |
|
8368 |
^ line |
|
8369 |
! |
|
8370 |
||
3160 | 8371 |
line:lineArg col:colArg character:characterArg |
2952 | 8372 |
line := lineArg. |
8373 |
col := colArg. |
|
8374 |
character := characterArg. |
|
8375 |
! ! |
|
8376 |
||
8377 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8378 |
||
3160 | 8379 |
executeIn:editor |
8380 |
editor |
|
4823 | 8381 |
replace:character |
8382 |
atLine:line |
|
8383 |
col:col. |
|
2952 | 8384 |
editor cursorLine:line col:col. |
105 | 8385 |
! ! |
8386 |
||
3235 | 8387 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8388 |
||
8389 |
characters |
|
8390 |
^ characters |
|
8391 |
! |
|
8392 |
||
8393 |
col1 |
|
8394 |
^ col1 |
|
8395 |
! |
|
8396 |
||
8397 |
col2 |
|
8398 |
^ col2 |
|
8399 |
! |
|
8400 |
||
8401 |
line |
|
8402 |
^ line |
|
8403 |
! |
|
8404 |
||
8405 |
line:lineArg col:colArg character:characterArg |
|
8406 |
line := lineArg. |
|
8407 |
col1 := col2 := colArg. |
|
8408 |
characters := characterArg asString. |
|
8409 |
! |
|
8410 |
||
8411 |
line:lineArg col:colArg characters:charactersArg |
|
8412 |
line := lineArg. |
|
8413 |
col1 := colArg. |
|
8414 |
characters := charactersArg asString. |
|
8415 |
col2 := col1 + charactersArg size - 1 |
|
8416 |
! ! |
|
8417 |
||
8418 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8419 |
||
8420 |
canCombineWithNext:anotherAction |
|
8421 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8422 |
! |
|
8423 |
||
8424 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8425 |
"I will combine only if we both are single character deletes, |
|
8426 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8427 |
(i.e. single-character typing)" |
|
8428 |
||
8429 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 8430 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
8431 |
^ true |
|
8432 |
]. |
|
3235 | 8433 |
]. |
8434 |
||
8435 |
^ false |
|
8436 |
! |
|
8437 |
||
8438 |
combineWithNext:nextReplaceAction |
|
8439 |
self assert:(line == nextReplaceAction line). |
|
8440 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8441 |
||
8442 |
col2 := nextReplaceAction col2. |
|
8443 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8444 |
characters := characters , nextReplaceAction characters. |
|
8445 |
! ! |
|
8446 |
||
8447 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8448 |
||
8449 |
executeIn:editor |
|
8450 |
editor |
|
4823 | 8451 |
replaceString:characters |
8452 |
atLine:line |
|
8453 |
col:col1. |
|
3235 | 8454 |
editor cursorLine:line col:col1. |
8455 |
! ! |
|
8456 |
||
3131 | 8457 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8458 |
||
8459 |
text:something |
|
8460 |
text := something. |
|
8461 |
! ! |
|
8462 |
||
8463 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8464 |
||
3160 | 8465 |
executeIn:editor |
3131 | 8466 |
editor contents:text |
8467 |
! ! |
|
8468 |
||
3130 | 8469 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8470 |
||
3160 | 8471 |
line:lineArg string:stringArg |
3130 | 8472 |
line := lineArg. |
8473 |
text := stringArg. |
|
8474 |
! ! |
|
8475 |
||
8476 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
8477 |
||
3160 | 8478 |
executeIn:editor |
3130 | 8479 |
editor list at:line put:text. |
8480 |
editor invalidateLine:line |
|
8481 |
! ! |
|
8482 |
||
3402 | 8483 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
8484 |
||
8485 |
line:lineArg lines:lineCollectionArg |
|
8486 |
line := lineArg. |
|
8487 |
text := lineCollectionArg. |
|
8488 |
||
8489 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
8490 |
! ! |
|
8491 |
||
8492 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
8493 |
||
8494 |
executeIn:editor |
|
8495 |
|lnr| |
|
8496 |
||
8497 |
lnr := line. |
|
8498 |
text do:[:eachLine | |
|
4823 | 8499 |
editor list at:lnr put:eachLine. |
8500 |
editor invalidateLine:lnr. |
|
8501 |
lnr := lnr + 1. |
|
3402 | 8502 |
]. |
8503 |
||
8504 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
8505 |
! ! |
|
8506 |
||
865 | 8507 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8508 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8509 |
version |
4826 | 8510 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.597 2013-11-11 20:43:18 cg Exp $' |
3945 | 8511 |
! |
8512 |
||
8513 |
version_CVS |
|
4826 | 8514 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.597 2013-11-11 20:43:18 cg Exp $' |
0 | 8515 |
! ! |
4481 | 8516 |