author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 11 Oct 2017 23:37:38 +0100 | |
branch | jv |
changeset 6215 | c6976b98f3c3 |
parent 6153 | ef289d40b266 |
child 6348 | bbae86d44915 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
5239 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextView subclass:#EditTextView |
4826 | 17 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
18 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
19 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
20 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
21 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
22 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
23 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
24 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
25 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
26 |
undoSupport lastStringFromReplaceForNextSearch |
|
27 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
28 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
29 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
30 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Views-Text' |
|
0 | 33 |
! |
34 |
||
2952 | 35 |
Object subclass:#EditAction |
4826 | 36 |
instanceVariableNames:'userFriendlyInfo' |
37 |
classVariableNames:'' |
|
38 |
poolDictionaries:'' |
|
39 |
privateIn:EditTextView |
|
2952 | 40 |
! |
41 |
||
42 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 43 |
instanceVariableNames:'line1 col1 line2 col2' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:EditTextView |
|
2952 | 47 |
! |
48 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 50 |
instanceVariableNames:'line col1 col2' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
54 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
55 |
|
3235 | 56 |
Object subclass:#EditMode |
4826 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:EditTextView |
|
3235 | 61 |
! |
62 |
||
63 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:EditTextView::EditMode |
|
3235 | 68 |
! |
69 |
||
70 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 71 |
instanceVariableNames:'' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:EditTextView::EditMode |
|
3235 | 75 |
! |
76 |
||
77 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 78 |
instanceVariableNames:'' |
79 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
80 |
poolDictionaries:'' |
|
81 |
privateIn:EditTextView::EditMode |
|
3235 | 82 |
! |
83 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
Query subclass:#ExecutingMacroQuery |
4826 | 85 |
instanceVariableNames:'' |
86 |
classVariableNames:'' |
|
87 |
poolDictionaries:'' |
|
88 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
89 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
90 |
|
4048 | 91 |
Object subclass:#LastReplacementInfo |
4826 | 92 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
93 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:EditTextView |
|
4048 | 97 |
! |
98 |
||
2952 | 99 |
EditTextView::EditAction subclass:#PasteString |
4826 | 100 |
instanceVariableNames:'line col string selected' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:EditTextView |
|
2952 | 104 |
! |
105 |
||
106 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 107 |
instanceVariableNames:'line col character' |
108 |
classVariableNames:'' |
|
109 |
poolDictionaries:'' |
|
110 |
privateIn:EditTextView |
|
2952 | 111 |
! |
112 |
||
3235 | 113 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 114 |
instanceVariableNames:'line col1 col2 characters' |
115 |
classVariableNames:'' |
|
116 |
poolDictionaries:'' |
|
117 |
privateIn:EditTextView |
|
3235 | 118 |
! |
119 |
||
3131 | 120 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 121 |
instanceVariableNames:'text' |
122 |
classVariableNames:'' |
|
123 |
poolDictionaries:'' |
|
124 |
privateIn:EditTextView |
|
3131 | 125 |
! |
126 |
||
3130 | 127 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 128 |
instanceVariableNames:'line text' |
129 |
classVariableNames:'' |
|
130 |
poolDictionaries:'' |
|
131 |
privateIn:EditTextView |
|
3130 | 132 |
! |
133 |
||
3402 | 134 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 135 |
instanceVariableNames:'line text' |
136 |
classVariableNames:'' |
|
137 |
poolDictionaries:'' |
|
138 |
privateIn:EditTextView |
|
3402 | 139 |
! |
140 |
||
5689 | 141 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
142 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
|
143 |
selectionEndLine selectionEndCol' |
|
144 |
classVariableNames:'' |
|
145 |
poolDictionaries:'' |
|
146 |
privateIn:EditTextView |
|
147 |
! |
|
148 |
||
865 | 149 |
!EditTextView class methodsFor:'documentation'! |
0 | 150 |
|
33 | 151 |
copyright |
152 |
" |
|
153 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 154 |
All Rights Reserved |
33 | 155 |
|
156 |
This software is furnished under a license and may be used |
|
157 |
only in accordance with the terms of that license and with the |
|
158 |
inclusion of the above copyright notice. This software may not |
|
159 |
be provided or otherwise made available to, or used by, any |
|
160 |
other person. No title to or ownership of the software is |
|
161 |
hereby transferred. |
|
162 |
" |
|
163 |
! |
|
164 |
||
0 | 165 |
documentation |
166 |
" |
|
167 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 168 |
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
|
169 |
acceptAction to be performed for accept |
125 | 170 |
|
171 |
If used with a model, this is informed by sending it a changeMsg with |
|
172 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
173 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 174 |
|
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
|
175 |
Please read the historic notice in the ListView class. |
0 | 176 |
|
586 | 177 |
[Instance variables:] |
0 | 178 |
|
5988 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
204 |
are #none, #block (solid-block cursor), #ibeam |
|
205 |
(vertical bar at insertion point) |
|
206 |
and #caret (caret below insertion-point). |
|
207 |
see cursorType: for an up-to-date list. |
|
208 |
||
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
|
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
4053 | 225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
5988 | 226 |
(cleared after a new selection) |
227 |
||
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Also, empty lines are represented as nil in the lines collection. |
|
246 |
Default is true. |
|
247 |
||
248 |
wordWrap <Boolean> Currently not used. |
|
249 |
||
250 |
lockUpdates <Boolean> internal, private |
|
251 |
||
252 |
prevCursorState <Boolean> temporary, private |
|
253 |
||
254 |
cursorMovementWhenUpdating |
|
255 |
<Symbol> defines where the cursor is to be positioned if the |
|
256 |
model changes its value by some outside activity |
|
257 |
(i.e. not by user input into the field). |
|
258 |
Can be one of: |
|
259 |
#keep / nil -> stay where it was |
|
260 |
#endOfText -> cursor to the end |
|
261 |
#endOfLine -> stay in the line, but move to end |
|
262 |
#beginOfText -> cursor to the beginning |
|
263 |
#beginOfLine -> stay in the line, but move to begin |
|
264 |
The default is #beginOfText |
|
265 |
||
266 |
||
267 |
||
268 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 269 |
|
270 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
271 |
userPreference values: |
5988 | 272 |
userPreferences.st80EditMode |
273 |
<Boolean> if true, cursor positioning is |
|
274 |
done as in vi or ST80; i.e. |
|
275 |
wysiwyg mode is somewhat relaxed, |
|
276 |
in that the cursor cannot be |
|
277 |
positioned behind a lines end. |
|
278 |
This is not yet completely implemented. |
|
33 | 279 |
used globals: |
280 |
||
5988 | 281 |
DeleteHistory <Text> last 1000 lines of deleted text |
282 |
(but only if this variable exists already) |
|
586 | 283 |
|
284 |
[styleSheet parameters:] |
|
121 | 285 |
|
5988 | 286 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
287 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
288 |
textCursorNoFocusForegroundColor |
|
289 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
290 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 291 |
|
292 |
[author:] |
|
5988 | 293 |
Claus Gittinger |
586 | 294 |
|
295 |
[see also:] |
|
5988 | 296 |
CodeView Workspace TextView ListView |
297 |
EditField |
|
0 | 298 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
305 |
basic setup: |
4823 | 306 |
[exBegin] |
307 |
|top textView| |
|
308 |
||
309 |
top := StandardSystemView new. |
|
310 |
top extent:300@200. |
|
311 |
||
312 |
textView := EditTextView new. |
|
313 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
314 |
top addSubView:textView. |
|
315 |
||
316 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
317 |
||
318 |
top open. |
|
319 |
[exEnd] |
|
594 | 320 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
322 |
with vertical scrollbar: |
4823 | 323 |
[exBegin] |
324 |
|top scrollView textView| |
|
325 |
||
326 |
top := StandardSystemView new. |
|
327 |
top extent:300@200. |
|
328 |
||
329 |
scrollView := ScrollableView for:EditTextView. |
|
330 |
textView := scrollView scrolledView. |
|
331 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
332 |
top addSubView:scrollView. |
|
333 |
||
334 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
335 |
||
336 |
top open. |
|
337 |
[exEnd] |
|
594 | 338 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
340 |
with horizontal & vertical scrollbars: |
4823 | 341 |
[exBegin] |
342 |
|top scrollView textView| |
|
343 |
||
344 |
top := StandardSystemView new. |
|
345 |
top extent:300@200. |
|
346 |
||
347 |
scrollView := HVScrollableView for:EditTextView. |
|
348 |
textView := scrollView scrolledView. |
|
349 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
350 |
top addSubView:scrollView. |
|
351 |
||
352 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
353 |
||
354 |
top open. |
|
355 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
358 |
set the action for accept: |
4823 | 359 |
[exBegin] |
360 |
|top textView| |
|
361 |
||
362 |
top := StandardSystemView new. |
|
363 |
top extent:300@200. |
|
364 |
||
365 |
textView := EditTextView new. |
|
366 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
367 |
top addSubView:textView. |
|
368 |
||
369 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
370 |
textView acceptAction:[:contents | |
|
371 |
Transcript showCR:'will not overwrite the file with:'. |
|
372 |
Transcript showCR:contents asString |
|
373 |
]. |
|
374 |
top open. |
|
375 |
[exEnd] |
|
594 | 376 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
378 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
379 |
non-string (text) items: |
4823 | 380 |
[exBegin] |
381 |
|top textView list| |
|
382 |
||
383 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
384 |
1 to:list size by:2 do:[:nr | |
|
385 |
list at:nr put:(Text string:(list at:nr) |
|
386 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
387 |
]. |
|
388 |
||
389 |
top := StandardSystemView new. |
|
390 |
top extent:300@200. |
|
391 |
||
392 |
textView := EditTextView new. |
|
393 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
394 |
top addSubView:textView. |
|
395 |
||
396 |
textView contents:list. |
|
397 |
top open. |
|
398 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
401 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
402 |
MVC operation: |
594 | 403 |
(the examples model here is a plug simulating a real model; |
404 |
real world applications would not use a plug ..) |
|
4823 | 405 |
[exBegin] |
406 |
|top textView model| |
|
407 |
||
408 |
model := Plug new. |
|
409 |
model respondTo:#accepted: |
|
410 |
with:[:newContents | |
|
411 |
Transcript showCR:'will not overwrite the file with:'. |
|
412 |
Transcript showCR:newContents asString |
|
413 |
]. |
|
414 |
model respondTo:#getList |
|
415 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
416 |
||
417 |
||
418 |
top := StandardSystemView new. |
|
419 |
top extent:300@200. |
|
420 |
||
421 |
textView := EditTextView new. |
|
422 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
423 |
top addSubView:textView. |
|
424 |
||
425 |
textView listMessage:#getList; |
|
426 |
model:model; |
|
427 |
changeMessage:#accepted:; |
|
428 |
aspect:#list. |
|
429 |
top open. |
|
430 |
[exEnd] |
|
594 | 431 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
433 |
two textViews on the same model: |
4823 | 434 |
[exBegin] |
435 |
|top1 textView1 top2 textView2 model currentContents| |
|
436 |
||
437 |
model := Plug new. |
|
438 |
model respondTo:#accepted: |
|
439 |
with:[:newContents | |
|
440 |
Transcript showCR:'accepted:'. |
|
441 |
Transcript showCR:newContents asString. |
|
442 |
currentContents := newContents. |
|
443 |
model changed:#contents |
|
444 |
]. |
|
445 |
model respondTo:#getList |
|
446 |
with:[Transcript showCR:'query'. |
|
447 |
currentContents]. |
|
448 |
||
449 |
||
450 |
top1 := StandardSystemView new. |
|
451 |
top1 extent:300@200. |
|
452 |
||
453 |
textView1 := EditTextView new. |
|
454 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
455 |
top1 addSubView:textView1. |
|
456 |
||
457 |
textView1 listMessage:#getList; |
|
458 |
model:model; |
|
459 |
aspect:#contents; |
|
460 |
changeMessage:#accepted:. |
|
461 |
top1 open. |
|
462 |
||
463 |
top2 := StandardSystemView new. |
|
464 |
top2 extent:300@200. |
|
465 |
||
466 |
textView2 := EditTextView new. |
|
467 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
468 |
top2 addSubView:textView2. |
|
469 |
||
470 |
textView2 listMessage:#getList; |
|
471 |
model:model; |
|
472 |
aspect:#contents; |
|
473 |
changeMessage:#accepted:. |
|
474 |
top2 open. |
|
475 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
476 |
" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
477 |
! |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
478 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
479 |
selection_and_cursor_movement |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
480 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
481 |
Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
482 |
as opposed to 'traditional' which is what how it was in St/X 'ever since' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
483 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
484 |
* Numerous off-by-one bugs |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
485 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
486 |
* Extending selection by dragging: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
487 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
488 |
1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
489 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
490 |
3. Press Shift-Left / Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
491 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
492 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
493 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
494 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
495 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
496 |
* Extending selection by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
497 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
498 |
1. Position cursor in the middle of the line |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
499 |
2. Press Shift-Home (line for beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
500 |
3. Press Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
501 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
502 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
503 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
504 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
505 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
506 |
* Selection flip by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
507 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
508 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
509 |
2. Press Shift-Home (line from beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
510 |
2. Press Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
511 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
512 |
Traditional ST/X: end of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
513 |
Standard: Selection 'flips' so part of line from column C to the end is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
514 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
515 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
516 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
517 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
518 |
2. Press Shift-End (column C to the end of line should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
519 |
2. Press Shift-Home |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
520 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
521 |
Traditional ST/X: beginning of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
522 |
Standard: Selection 'flips' so part of line from the beginning to column C is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
523 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
524 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
525 |
NOTE: This could be controlled by |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
526 |
UserPreferences current selectionExtensionMode |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
527 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
528 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
529 |
* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
530 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
531 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
532 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
533 |
3. Press Ctrl-Shift-Right, Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
534 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
535 |
Traditional ST/X: nothing happens at all |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
536 |
Standard: Selection is extended to include a space (first press) and a word right to previously selected one |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
537 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
538 |
|
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
539 |
* Indenting selected block with Tab |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
540 |
Scenario: |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
541 |
1. Select a block (i.e, make selection that pans multiple lines) |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
542 |
2. Press Tab |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
543 |
|
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
544 |
Traditional St/X: A single 'tab' is inserted |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
545 |
Standard: all lines in the selection are indented. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
546 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
547 |
" |
0 | 548 |
! ! |
549 |
||
865 | 550 |
!EditTextView class methodsFor:'defaults'! |
59 | 551 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
552 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
553 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
554 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
555 |
"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
|
556 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
557 |
|
1419 | 558 |
st80Mode |
559 |
"return true, if the st80 editing mode is turned on. |
|
560 |
This setting affects the behavior of the cursor, when positioned |
|
5909 | 561 |
beyond the end of a line or the end of the text. |
562 |
This method is here for backward compatibility, when this flag was stored |
|
563 |
in a class var. It is now in the user's settings. |
|
564 |
Please do not call it, but go to the prefs directly, to make it easier to find those getters." |
|
1419 | 565 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
566 |
^ UserPreferences current st80EditMode |
1419 | 567 |
|
568 |
" |
|
569 |
EditTextView st80Mode:true |
|
570 |
EditTextView st80Mode:false |
|
571 |
" |
|
572 |
||
573 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
574 |
! |
|
575 |
||
576 |
st80Mode:aBoolean |
|
577 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
5909 | 578 |
beyond the end of a line or the last line. |
579 |
This method is here for backward compatibility, when this flag was stored |
|
580 |
in a class var. It is now in the user's settings. |
|
581 |
Please do not call it, but go to the prefs directly, to make it easier to find those setters." |
|
1419 | 582 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
583 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 584 |
|
585 |
" |
|
586 |
EditTextView st80Mode:true |
|
587 |
EditTextView st80Mode:false |
|
588 |
" |
|
589 |
||
590 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
591 |
! |
|
592 |
||
59 | 593 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
594 |
"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
|
595 |
|
1390 | 596 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 597 |
#'textCursor.noFocusForegroundColor' |
598 |
#'textCursor.type' |
|
599 |
#'textCursor.typeNoFocus' |
|
600 |
#'editText.st80Mode')> |
|
1355 | 601 |
|
602 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
603 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
604 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
605 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
606 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
607 |
|
1419 | 608 |
" |
609 |
self updateStyleCache |
|
610 |
" |
|
611 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
612 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 613 |
! ! |
614 |
||
3431 | 615 |
!EditTextView class methodsFor:'specs'! |
616 |
||
617 |
searchReplaceDialogSpec |
|
618 |
"This resource specification was automatically generated |
|
619 |
by the UIPainter of ST/X." |
|
620 |
||
621 |
"Do not manually edit this!! If it is corrupted, |
|
622 |
the UIPainter may not be able to read the specification." |
|
623 |
||
624 |
" |
|
625 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
626 |
" |
|
627 |
||
628 |
<resource: #canvas> |
|
629 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
630 |
^ |
3431 | 631 |
#(FullSpec |
4823 | 632 |
name: searchReplaceDialogSpec |
633 |
window: |
|
3431 | 634 |
(WindowSpec |
4823 | 635 |
label: 'String Search and Replace' |
636 |
name: 'String Search and Replace' |
|
637 |
min: (Point 283 196) |
|
638 |
max: (Point 283 196) |
|
639 |
bounds: (Rectangle 0 0 279 192) |
|
640 |
) |
|
641 |
component: |
|
3431 | 642 |
(SpecCollection |
4823 | 643 |
collection: ( |
644 |
(LabelSpec |
|
645 |
label: 'Search Pattern:' |
|
646 |
name: 'label' |
|
647 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
648 |
level: 0 |
|
649 |
translateLabel: true |
|
650 |
adjust: left |
|
651 |
) |
|
652 |
(ComboBoxSpec |
|
653 |
name: 'patternComboBox' |
|
654 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
655 |
tabable: true |
|
656 |
model: searchPattern |
|
657 |
immediateAccept: false |
|
658 |
acceptOnLeave: true |
|
659 |
acceptOnReturn: true |
|
660 |
acceptOnTab: true |
|
661 |
acceptOnLostFocus: true |
|
662 |
acceptOnPointerLeave: false |
|
663 |
autoSelectInitialText: true |
|
664 |
comboList: patternList |
|
665 |
) |
|
666 |
(ComboBoxSpec |
|
667 |
name: 'replaceComboBox' |
|
668 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
669 |
tabable: true |
|
670 |
model: replacePattern |
|
671 |
immediateAccept: false |
|
672 |
acceptOnLeave: true |
|
673 |
acceptOnReturn: true |
|
674 |
acceptOnTab: true |
|
675 |
acceptOnLostFocus: true |
|
676 |
acceptOnPointerLeave: false |
|
677 |
autoSelectInitialText: true |
|
678 |
comboList: patternList |
|
679 |
) |
|
680 |
(CheckBoxSpec |
|
681 |
label: 'Ignore Case' |
|
682 |
name: 'ignoreCaseCheckBox' |
|
683 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
684 |
level: 0 |
|
685 |
tabable: true |
|
686 |
model: ignoreCase |
|
687 |
translateLabel: true |
|
688 |
) |
|
689 |
(VariableVerticalPanelSpec |
|
690 |
name: 'VariableVerticalPanel1' |
|
691 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
692 |
component: |
|
693 |
(SpecCollection |
|
694 |
collection: ( |
|
695 |
(HorizontalPanelViewSpec |
|
696 |
name: 'HorizontalPanel1' |
|
697 |
level: 0 |
|
698 |
horizontalLayout: fitSpace |
|
699 |
verticalLayout: center |
|
700 |
horizontalSpace: 3 |
|
701 |
verticalSpace: 3 |
|
702 |
ignoreInvisibleComponents: true |
|
703 |
reverseOrderIfOKAtLeft: true |
|
704 |
component: |
|
705 |
(SpecCollection |
|
706 |
collection: ( |
|
707 |
(ActionButtonSpec |
|
708 |
label: 'Replace' |
|
709 |
name: 'replaceButton' |
|
710 |
level: 2 |
|
711 |
translateLabel: true |
|
712 |
tabable: true |
|
713 |
model: replaceAction |
|
714 |
extent: (Point 134 21) |
|
715 |
) |
|
716 |
(ActionButtonSpec |
|
717 |
label: 'Replace All' |
|
718 |
name: 'replaceAllButton' |
|
719 |
level: 2 |
|
720 |
borderWidth: 1 |
|
721 |
translateLabel: true |
|
722 |
tabable: true |
|
723 |
model: replaceAllAction |
|
724 |
extent: (Point 134 21) |
|
725 |
) |
|
726 |
) |
|
727 |
||
728 |
) |
|
729 |
) |
|
730 |
(HorizontalPanelViewSpec |
|
731 |
name: 'horizontalPanelView' |
|
732 |
level: 0 |
|
733 |
horizontalLayout: fitSpace |
|
734 |
verticalLayout: center |
|
735 |
horizontalSpace: 3 |
|
736 |
verticalSpace: 3 |
|
737 |
ignoreInvisibleComponents: true |
|
738 |
reverseOrderIfOKAtLeft: true |
|
739 |
component: |
|
740 |
(SpecCollection |
|
741 |
collection: ( |
|
742 |
(ActionButtonSpec |
|
743 |
label: 'Cancel' |
|
744 |
name: 'cancelButton' |
|
745 |
level: 2 |
|
746 |
translateLabel: true |
|
747 |
tabable: true |
|
748 |
model: cancel |
|
749 |
extent: (Point 88 21) |
|
750 |
) |
|
751 |
(ActionButtonSpec |
|
752 |
label: 'Prev' |
|
753 |
name: 'prevButton' |
|
754 |
level: 2 |
|
755 |
translateLabel: true |
|
756 |
tabable: true |
|
757 |
model: prevAction |
|
758 |
extent: (Point 89 21) |
|
759 |
) |
|
760 |
(ActionButtonSpec |
|
761 |
label: 'Next' |
|
762 |
name: 'nextButton' |
|
763 |
level: 2 |
|
764 |
borderWidth: 1 |
|
765 |
translateLabel: true |
|
766 |
tabable: true |
|
767 |
model: nextAction |
|
768 |
isDefault: true |
|
769 |
extent: (Point 88 21) |
|
770 |
) |
|
771 |
) |
|
772 |
||
773 |
) |
|
774 |
) |
|
775 |
) |
|
776 |
||
777 |
) |
|
778 |
handles: (Any 0.5 1.0) |
|
779 |
) |
|
780 |
(LabelSpec |
|
781 |
label: 'Replace By:' |
|
782 |
name: 'ReplaceLabel' |
|
783 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
784 |
level: 0 |
|
785 |
translateLabel: true |
|
786 |
adjust: left |
|
787 |
) |
|
788 |
) |
|
789 |
||
790 |
) |
|
3431 | 791 |
) |
792 |
||
793 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
794 |
! ! |
|
795 |
||
2744 | 796 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
797 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
798 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
799 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
800 |
|
2019 | 801 |
"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
|
802 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
803 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
804 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
805 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
806 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
807 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
808 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
809 |
|
1390 | 810 |
cutSelection |
811 |
self cut |
|
812 |
||
813 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
814 |
! |
|
815 |
||
1590 | 816 |
deselect |
817 |
"remove the selection" |
|
818 |
||
819 |
^ self unselect |
|
820 |
||
821 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
822 |
! |
|
823 |
||
2101 | 824 |
enabled:aBoolean |
825 |
||
826 |
self readOnly:aBoolean not |
|
827 |
||
828 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
829 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
830 |
! |
|
831 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
832 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
833 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
834 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
835 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
836 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
837 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
838 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
839 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
840 |
"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
|
841 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
842 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
843 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
844 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
845 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
846 |
col < 1 ifTrue:[ |
4823 | 847 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
848 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
849 |
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
|
850 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
851 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
852 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
853 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
854 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
855 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
856 |
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
|
857 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
858 |
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
|
859 |
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
|
860 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
861 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
862 |
"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
|
863 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
864 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
865 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
866 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
867 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
868 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
870 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 871 |
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
|
872 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
873 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 874 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
875 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
876 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
877 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
878 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
879 |
v insertAndSelect:'<- hello there' at:5. |
125 | 880 |
" |
1390 | 881 |
! |
882 |
||
883 |
pasteSelection |
|
884 |
self paste |
|
885 |
||
886 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 887 |
! |
888 |
||
889 |
replaceSelectionWith:aString |
|
890 |
^ self replaceSelectionBy:aString |
|
891 |
||
892 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
893 |
! |
|
894 |
||
895 |
selectAt:pos |
|
896 |
"move the cursor before cursorPosition." |
|
897 |
||
898 |
self cursorToCharacterPosition:pos |
|
899 |
||
900 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
901 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
902 |
! |
|
903 |
||
2101 | 904 |
textHasChanged |
905 |
^ self modified |
|
906 |
||
907 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
908 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
909 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
910 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
911 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
912 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
913 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
914 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
915 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
916 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
917 |
|
4585 | 918 |
!EditTextView methodsFor:'accessing'! |
919 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
920 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
921 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
922 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
923 |
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
|
924 |
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
|
925 |
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
|
926 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
927 |
"/ 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
|
928 |
"/ 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
|
929 |
^((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
|
930 |
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
|
931 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
932 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
933 |
"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
|
934 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
935 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
936 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
937 |
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
|
938 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
939 |
"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
|
940 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
941 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
942 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
943 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
944 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
945 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
946 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
947 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
948 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
949 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
950 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
951 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
952 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
953 |
"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
|
954 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
955 |
|
4609 | 956 |
editedClass |
957 |
|cm| |
|
958 |
||
959 |
cm := self editedMethodOrClass. |
|
960 |
cm isBehavior ifTrue:[^ cm]. |
|
961 |
cm isMethod ifTrue:[^ cm mclass]. |
|
962 |
^ nil |
|
963 |
! |
|
964 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
965 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
966 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
967 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
968 |
"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
|
969 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
970 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
971 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
972 |
"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
|
973 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
974 |
"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
|
975 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
976 |
|
4609 | 977 |
editedMethod |
978 |
|cm| |
|
979 |
||
980 |
cm := self editedMethodOrClass. |
|
981 |
cm isMethod ifTrue:[^ cm]. |
|
982 |
cm isBehavior ifTrue:[^ nil]. |
|
983 |
^ nil |
|
984 |
! |
|
985 |
||
986 |
editedMethodOrClass |
|
987 |
^ nil |
|
988 |
! |
|
989 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
990 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
991 |
"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
|
992 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
993 |
"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
|
994 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
995 |
|
4585 | 996 |
hasSelectionOrTextInCursorLine |
997 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
998 |
! |
|
999 |
||
4589 | 1000 |
selectionOrTextOfCursorLine |
1001 |
^ self selectionOrTextOfCursorLine:true |
|
1002 |
! |
|
1003 |
||
4585 | 1004 |
selectionOrTextOfCursorLine:doSelect |
1005 |
|sel lNr line| |
|
1006 |
||
1007 |
sel := self selectionAsString. |
|
1008 |
sel notNil ifTrue:[^ sel]. |
|
1009 |
||
1010 |
lNr := self cursorLine. |
|
1011 |
line := self listAt:lNr. |
|
1012 |
line notEmptyOrNil ifTrue:[ |
|
1013 |
doSelect ifTrue:[ |
|
1014 |
self selectLine:lNr. |
|
1015 |
]. |
|
1016 |
^ line |
|
1017 |
]. |
|
1018 |
||
1019 |
^ nil |
|
1020 |
! ! |
|
1021 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1022 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1023 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1024 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1025 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1027 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1028 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1029 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1030 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1031 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1032 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1033 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1034 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1035 |
|
2792 | 1036 |
acceptChannel |
1037 |
"return the valueHolder holding true if text was accepted. |
|
1038 |
By placing a true into this channel, an accept can also be forced." |
|
1039 |
||
1040 |
^ acceptChannel |
|
1041 |
||
1042 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1043 |
! |
|
1044 |
||
1045 |
acceptChannel:aValueHolder |
|
1046 |
"set the valueHolder holding true if text was accepted. |
|
1047 |
By placing a true into this channel, an accept can also be forced." |
|
1048 |
||
1049 |
|prev| |
|
1050 |
||
1051 |
prev := acceptChannel. |
|
1052 |
acceptChannel := aValueHolder. |
|
1053 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1054 |
||
1055 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1056 |
! |
|
1057 |
||
1108 | 1058 |
acceptEnabled:aBoolean |
1059 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1060 |
||
1061 |
acceptEnabled := aBoolean |
|
1062 |
||
1063 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1064 |
! |
|
1065 |
||
2792 | 1066 |
accepted |
1067 |
"return true if text was accepted" |
|
1068 |
||
1069 |
^ acceptChannel value |
|
1070 |
||
1071 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1072 |
! |
|
1073 |
||
1074 |
accepted:aBoolean |
|
1075 |
"set/clear the accepted flag. |
|
1076 |
This may force my current contents to be placed into my model." |
|
1077 |
||
1078 |
acceptChannel value:aBoolean. |
|
1079 |
||
1080 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1081 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1082 |
! |
|
1083 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1084 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1085 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1086 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1087 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1088 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1089 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1090 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1091 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1092 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1093 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1094 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1095 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1096 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1097 |
|
2774 | 1098 |
cursorMovementWhenUpdating |
3160 | 1099 |
"return what is be done with the cursor, |
2774 | 1100 |
when I get a new text (via the model or the #contents/#list) |
1101 |
Allowed arguments are: |
|
4823 | 1102 |
#keep / nil -> stay where it was |
1103 |
#endOfText -> position cursor to the end |
|
1104 |
#beginOfText -> position cursor to the beginning |
|
1105 |
#endOfLine -> position cursor to the current lines end |
|
1106 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1107 |
The default is #beginOfText. |
1108 |
This may be useful for fields which get new values assigned from |
|
1109 |
the program (i.e. not from the user)" |
|
1110 |
||
1111 |
^ cursorMovementWhenUpdating |
|
1112 |
||
1113 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1114 |
! |
|
1115 |
||
2133 | 1116 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1117 |
"define what should be done with the cursor, |
2133 | 1118 |
when I get a new text (via the model or the #contents/#list) |
1119 |
Allowed arguments are: |
|
4823 | 1120 |
#keep / nil -> stay where it was |
1121 |
#endOfText -> position cursor to the end |
|
1122 |
#beginOfText -> position cursor to the beginning |
|
1123 |
#endOfLine -> position cursor to the current lines end |
|
1124 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1125 |
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
|
1126 |
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
|
1127 |
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
|
1128 |
|
2133 | 1129 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1130 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1131 |
"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
|
1132 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1133 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1134 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1135 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1136 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1137 |
|
2438 | 1138 |
dontReplaceSelectionOnInput |
4742 | 1139 |
"remember that the current selection was created by a paste operation |
1140 |
(as opposed to an explicit selection by the user). |
|
1141 |
This selection will not be replaced by followup user input, |
|
1142 |
so multiple pastes will be possible." |
|
1143 |
||
5342
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1144 |
self hasSelection ifTrue:[ |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1145 |
typeOfSelection := #paste |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1146 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1147 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1148 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1149 |
! |
1150 |
||
3235 | 1151 |
editModeHolder |
1152 |
^ editMode. |
|
1153 |
! |
|
1154 |
||
1155 |
editModeInsert |
|
1156 |
editMode value:EditMode insertMode |
|
1157 |
! |
|
1158 |
||
1159 |
editModeInsertAndSelect |
|
1160 |
editMode value:EditMode insertAndSelectMode |
|
1161 |
! |
|
1162 |
||
1163 |
editModeOverwrite |
|
1164 |
editMode value:EditMode overwriteMode |
|
1165 |
! |
|
1166 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1167 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1168 |
"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
|
1169 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1170 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1171 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1172 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1173 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1174 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1175 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1176 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1177 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1178 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1179 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1180 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1181 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1182 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1183 |
readOnly == true ifFalse:[ |
4823 | 1184 |
readOnly := true. |
1185 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1186 |
menu disableAll:#(cut paste replace indent) |
|
1187 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1188 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1189 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1190 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1191 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1192 |
|
5858 | 1193 |
generateTextAfterEndHook:aBlock |
1194 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1195 |
when the cursor is moved there. |
|
1196 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1197 |
which want to automatically generate additional lines lazily, |
|
1198 |
but which cannot afford to generate the whole text in advance |
|
1199 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1200 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1201 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1202 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1203 |
number, into which the cursor should be moved |
1204 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1205 |
to make the cursor end in the last line which was inserted)" |
5890 | 1206 |
|
5858 | 1207 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1208 |
! |
|
1209 |
||
1210 |
generateTextBeforeStartHook:aBlock |
|
1211 |
"some applications may want to dynamically generate lines above the top |
|
1212 |
line, when the cursor is moved there. |
|
1213 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1214 |
which want to automatically generate additional lines lazily, |
|
1215 |
but which cannot afford to generate the whole text in advance |
|
1216 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1217 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1218 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1219 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1220 |
number, into which the cursor should be moved |
1221 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1222 |
cursor end in the last line which was inserted)" |
5890 | 1223 |
|
5858 | 1224 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1225 |
! |
|
1226 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1227 |
insertMode:aBoolean |
3235 | 1228 |
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
|
1229 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1230 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1231 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1232 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1233 |
insertModeHolder |
3235 | 1234 |
^ BlockValue |
4823 | 1235 |
with:[:m | m isInsertMode] |
1236 |
argument:(editMode). |
|
3465 | 1237 |
|
1238 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1239 |
! |
1240 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1241 |
isInInsertMode |
3235 | 1242 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1243 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1244 |
|
5216 | 1245 |
isNotReadOnly |
1246 |
"return true, if the text is not readonly." |
|
1247 |
||
1248 |
^ self isReadOnly not |
|
1249 |
! |
|
1250 |
||
2792 | 1251 |
isReadOnly |
1252 |
"return true, if the text is readonly." |
|
1253 |
||
1254 |
^ readOnly value |
|
1255 |
||
1256 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1257 |
! |
|
1258 |
||
2796 | 1259 |
modeLabelHolder |
1260 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1261 |
||
3160 | 1262 |
^ BlockValue |
4041 | 1263 |
with:[:e :l | |
1264 |
self isReadOnly ifTrue:[ |
|
1265 |
'' |
|
1266 |
] ifFalse:[ |
|
5724 | 1267 |
l ifTrue:[ 'L' allBold withColor:#red] |
4041 | 1268 |
ifFalse:[ e infoPrintString]]] |
1269 |
argument:(self editModeHolder) |
|
1270 |
argument:(self learnModeHolder). |
|
3465 | 1271 |
|
1272 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1273 |
! |
1274 |
||
2792 | 1275 |
modified |
1276 |
"return true if text was modified" |
|
1277 |
||
1278 |
^ modifiedChannel value |
|
1279 |
! |
|
1280 |
||
1281 |
modified:aBoolean |
|
1282 |
"set/clear the modified flag" |
|
1283 |
||
1284 |
modifiedChannel value:aBoolean |
|
1285 |
||
1286 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1287 |
! |
|
1288 |
||
1289 |
modifiedChannel |
|
1290 |
"return the valueHolder holding true if text was modified" |
|
1291 |
||
1292 |
^ modifiedChannel |
|
1293 |
! |
|
1294 |
||
1295 |
modifiedChannel:aValueHolder |
|
1296 |
"set the valueHolder holding true if text was modified" |
|
1297 |
||
1298 |
|prev| |
|
1299 |
||
1300 |
prev := modifiedChannel. |
|
1301 |
modifiedChannel := aValueHolder. |
|
1302 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1303 |
||
1304 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1305 |
! |
|
1306 |
||
1307 |
readOnly |
|
1308 |
"make the text readonly. |
|
4664 | 1309 |
Obsolete because it is obfuscating (looks like a getter) |
1310 |
- use #readOnly:" |
|
2792 | 1311 |
|
1312 |
<resource:#obsolete> |
|
1313 |
||
1314 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1315 |
self readOnly:true. |
2792 | 1316 |
|
4664 | 1317 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1318 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1319 |
! |
1320 |
||
1321 |
readOnly:aBoolean |
|
1322 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1323 |
The argument may also be a valueHolder." |
|
1324 |
||
1325 |
readOnly := aBoolean |
|
1326 |
||
1327 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1328 |
! |
|
1329 |
||
4782 | 1330 |
reallyModifiedChannel |
1331 |
"return the valueHolder holding true if text was really modified. |
|
1332 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1333 |
||
1334 |
^ self modifiedChannel |
|
1335 |
! |
|
1336 |
||
5909 | 1337 |
st80EditMode |
1338 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1339 |
if off, we have the Rand-editor behavior (random access)" |
|
1340 |
||
1341 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1342 |
! |
|
1343 |
||
1344 |
st80EditMode:aBooleanOrNil |
|
4192 | 1345 |
"set/clear the st80Mode flag. |
1346 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1347 |
if off, we have the Rand-editor behavior (random access) |
1348 |
if nil, the setting follows the current userPref setting." |
|
1349 |
||
1350 |
st80Mode := aBooleanOrNil |
|
4192 | 1351 |
|
1352 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1353 |
! |
|
1354 |
||
5909 | 1355 |
st80Mode:aBooleanOrNil |
6070 | 1356 |
<resource: #obsolete> |
5909 | 1357 |
self obsoleteMethodWarning. |
1358 |
self st80EditMode:aBooleanOrNil |
|
1359 |
||
1360 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1361 |
! |
|
1362 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1363 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1364 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1365 |
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
|
1366 |
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
|
1367 |
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
|
1368 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1369 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1370 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1371 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1372 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1373 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1374 |
"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
|
1375 |
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
|
1376 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1377 |
|
3160 | 1378 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1379 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1380 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1381 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1382 |
"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
|
1383 |
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
|
1384 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1385 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1386 |
tabRequiresControl := aBoolean |
5909 | 1387 |
! |
1388 |
||
1389 |
trimBlankLines |
|
1390 |
"If on, the blank lines are trimmed to zero size; |
|
1391 |
if nil, the setting follows the current userPref setting." |
|
1392 |
||
1393 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1394 |
! |
|
1395 |
||
1396 |
trimBlankLines:aBooleanOrNil |
|
1397 |
"If on, the blank lines are trimmed to zero size; |
|
1398 |
if nil, the setting follows the current userPref setting." |
|
1399 |
||
1400 |
trimBlankLines := aBooleanOrNil. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1401 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1402 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1403 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1404 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1405 |
at:lineNr basicPut:aLine |
5413 | 1406 |
"change a line without change notification. |
1407 |
this is not undoably, unless you care for yourself" |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1408 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1409 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1410 |
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
|
1411 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1412 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1413 |
|
522 | 1414 |
at:lineNr put:aLine |
5413 | 1415 |
"replace a line by something new. |
1416 |
this is not undoably, unless you care for yourself" |
|
1417 |
||
5393 | 1418 |
|oldLine| |
1419 |
||
1420 |
oldLine := (self at:lineNr) ? ''. |
|
1421 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1422 |
super at:lineNr put:aLine. |
1423 |
self textChanged |
|
522 | 1424 |
]. |
1425 |
! |
|
1426 |
||
4700 | 1427 |
characterAfterCursor |
1428 |
"return the character one after the cursor - space if beyond line." |
|
1429 |
||
1430 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1431 |
! |
|
1432 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1433 |
characterBeforeCursor |
4700 | 1434 |
"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
|
1435 |
|
5142 | 1436 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1437 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1438 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1439 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1440 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1441 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1442 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1443 |
characterUnderCursor |
2707 | 1444 |
"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
|
1445 |
For non-block cursors, this is the character immediately to the right |
5413 | 1446 |
of the insertion-bar or caret. |
1447 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1448 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1449 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1450 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1451 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1452 |
contents |
2213 | 1453 |
"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
|
1454 |
|
5988 | 1455 |
|numLines| |
1456 |
||
1457 |
list isNil ifTrue:[^ '']. |
|
1458 |
self trimBlankLines ifTrue:[ |
|
1459 |
self removeTrailingBlankLines. |
|
1460 |
] ifFalse:[ |
|
1461 |
"/ the last line does not count, if the cursor is at |
|
1462 |
"/ the begining |
|
1463 |
cursorCol == 1 ifTrue:[ |
|
1464 |
numLines := list size. |
|
1465 |
cursorLine == numLines ifTrue:[ |
|
1466 |
numLines > 1 ifTrue:[ |
|
1467 |
(self listAt:numLines) isEmptyOrNil ifTrue:[ |
|
1468 |
list grow:numLines-1. |
|
1469 |
]. |
|
1470 |
]. |
|
1471 |
]. |
|
1472 |
]. |
|
1473 |
]. |
|
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1474 |
^ super contents. |
3313 | 1475 |
|
1476 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1477 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1478 |
|
5413 | 1479 |
contents:aStringOrStringCollectionOrNil |
1480 |
"replace the whole contents by something new. |
|
5414 | 1481 |
this is not undoably, unless you care for yourself. |
1482 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1483 |
|
1484 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1485 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1486 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1487 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1488 |
"set the contents and optionally clear the undo history. |
1489 |
The contents-change is not undoable." |
|
1490 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1491 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1492 |
keepUndoHistory ifFalse:[ |
4823 | 1493 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1494 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1495 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1496 |
|
2213 | 1497 |
contentsAsString |
1498 |
"return the contents as a String (i.e. without emphasis)" |
|
1499 |
||
1500 |
list isNil ifTrue:[^ '']. |
|
1501 |
self removeTrailingBlankLines. |
|
1502 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1503 |
ifFalse:[each string] |
1504 |
]) asStringWithCRs |
|
2213 | 1505 |
! |
1506 |
||
5067 | 1507 |
contentsAsStringWithTabs |
1508 |
"return the contents as a String (i.e. without emphasis) |
|
1509 |
and with leading spaces replaced by tab characters |
|
1510 |
(i.e. as would be written to a file)" |
|
1511 |
||
1512 |
list isNil ifTrue:[^ '']. |
|
1513 |
self removeTrailingBlankLines. |
|
1514 |
^ (list collect:[:each | |
|
1515 |
each isNil |
|
1516 |
ifTrue:[''] |
|
1517 |
ifFalse:[each string withTabs] |
|
1518 |
]) asStringWithCRs |
|
1519 |
! |
|
1520 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1521 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1522 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1523 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1524 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1525 |
^ cursorCol |
125 | 1526 |
! |
1527 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1528 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1529 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1530 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1531 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1532 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1533 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1534 |
cursorLine |
3160 | 1535 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1536 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1537 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1538 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1539 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1540 |
|
5400 | 1541 |
cursorLineAndColumnLabelHolder |
5399 | 1542 |
"return a valueHolder for the cursors line and column as an info string |
1543 |
of the form 'line : col'. |
|
1544 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1545 |
||
1546 |
^ BlockValue |
|
1547 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1548 |
argument:self cursorLineHolder |
|
1549 |
argument:self cursorColHolder |
|
1550 |
! |
|
1551 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1552 |
cursorLineHolder |
3160 | 1553 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1554 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1555 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1556 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1557 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1558 |
|
4713 | 1559 |
lineStringBeforeCursor |
1560 |
"return the line's string before the cursor. |
|
1561 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1562 |
||
1563 |
|line| |
|
1564 |
||
1565 |
line := ((self at:cursorLine) ? '') string. |
|
1566 |
line size < (cursorCol-1) ifTrue:[ |
|
1567 |
^ line paddedTo:(cursorCol-1) |
|
1568 |
]. |
|
1569 |
^ line copyTo:(cursorCol-1) |
|
1570 |
! |
|
1571 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1572 |
list:something |
5413 | 1573 |
"replace the whole contents by something new. |
1574 |
this is not undoably, unless you care for yourself. |
|
1575 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1576 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1577 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1578 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1579 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1580 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1581 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1582 |
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
|
1583 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1584 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1585 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1586 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1587 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1588 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1589 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1590 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1591 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1592 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1593 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1594 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1595 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1596 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1597 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1598 |
^ 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
|
1599 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1600 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1601 |
"/ 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
|
1602 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
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 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1605 |
setContents:something |
5413 | 1606 |
"replace the whole contents by something new |
1607 |
AND clear the remembered undo actions" |
|
1608 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1609 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1610 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1611 |
undoSupport resetHistories. |
2955 | 1612 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1613 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1614 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1615 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1616 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1617 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
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 |
|
4609 | 1620 |
!EditTextView methodsFor:'accessing-dimensions'! |
1621 |
||
1622 |
xOfCursor |
|
4728 | 1623 |
|point| |
1624 |
||
1625 |
cursorVisibleLine isNil ifTrue:[ |
|
1626 |
"/ take the end of the selection, if any |
|
1627 |
(selectionStartLine notNil |
|
1628 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1629 |
ifTrue:[ |
|
1630 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1631 |
]. |
|
1632 |
||
1633 |
"/ point := device |
|
1634 |
"/ translatePoint:(device pointerPosition) |
|
1635 |
"/ fromView:nil |
|
1636 |
"/ toView:self. |
|
1637 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1638 |
"/ ^ point x |
|
1639 |
"/ ]. |
|
1640 |
"/ ^ 0 |
|
1641 |
^ nil |
|
1642 |
]. |
|
4609 | 1643 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1644 |
||
1645 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1646 |
! ! |
|
4590 | 1647 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1648 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1649 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1650 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1651 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1652 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1653 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1654 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1655 |
wasOn := self hideCursor. |
5643 | 1656 |
cursorFgColor := color1 onDevice:device. |
1657 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1658 |
wasOn ifTrue:[self showCursor] |
1333 | 1659 |
! |
1660 |
||
1899 | 1661 |
cursorType |
1662 |
"return the style of the text cursor. |
|
4721 | 1663 |
Currently, supported are: #none |
1664 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1665 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1666 |
|
1667 |
^ cursorType |
|
1668 |
||
1669 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1670 |
! |
|
1671 |
||
1333 | 1672 |
cursorType:aCursorTypeSymbol |
1673 |
"set the style of the text cursor. |
|
4721 | 1674 |
Currently, supported are: #none |
1675 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1676 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1677 |
|
1334 | 1678 |
cursorType := aCursorTypeSymbol. |
1333 | 1679 |
|
1680 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1681 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1682 |
! |
1683 |
||
1899 | 1684 |
cursorTypeNoFocus |
1685 |
"return the style of the text cursor when the view has no focus. |
|
1686 |
If left unspecified, this is the same as the regular cursorType." |
|
1687 |
||
1688 |
^ cursorTypeNoFocus |
|
1689 |
||
1690 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1691 |
! |
|
1692 |
||
1334 | 1693 |
cursorTypeNoFocus:aCursorTypeSymbol |
1694 |
"set the style of the text cursor when the view has no focus. |
|
1695 |
If left unspecified, this is the same as the regular cursorType." |
|
1696 |
||
1697 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1698 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1699 |
|
4048 | 1700 |
!EditTextView methodsFor:'accessing-replace'! |
1701 |
||
4746 | 1702 |
lastReplacementInfo |
1703 |
^ lastReplacementInfo |
|
1704 |
! |
|
1705 |
||
4048 | 1706 |
lastStringToReplace: aString |
4818 | 1707 |
! |
1708 |
||
1709 |
previousReplacements |
|
1710 |
"accessor for the code completion" |
|
1711 |
||
1712 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1713 |
! ! |
1714 |
||
2119 | 1715 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1716 |
|
125 | 1717 |
accept |
1718 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1719 |
changeMessage. |
1720 |
Historically, ST/X used a callBack (acceptAction); |
|
1721 |
and ST80/VW used the model, into which the text is stored. |
|
1722 |
We support both; if there is a mode, it gets a value: message, |
|
1723 |
If there is an acceptAction, it is called." |
|
125 | 1724 |
|
1108 | 1725 |
acceptEnabled == false ifTrue:[ |
5937 | 1726 |
self beep. |
1727 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1728 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1729 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1730 |
^ self |
1108 | 1731 |
]. |
1732 |
||
125 | 1733 |
lockUpdates := true. |
1013 | 1734 |
|
1735 |
"/ |
|
1736 |
"/ ST-80 way of doing it |
|
1737 |
"/ |
|
1738 |
model notNil ifTrue:[ |
|
5937 | 1739 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1740 |
acceptChannel notNil ifTrue:[ |
|
1741 |
acceptChannel value:true withoutNotifying:self. |
|
5525 | 1742 |
]. |
2999 | 1743 |
]. |
1744 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1745 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1746 |
"/ ST/X way of doing things |
5937 | 1747 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1748 |
"/ 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
|
1749 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1750 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1751 |
acceptAction notNil ifTrue:[ |
5937 | 1752 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1753 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1754 |
|
125 | 1755 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1756 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1757 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1758 |
! |
1759 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1760 |
argForChangeMessage |
597 | 1761 |
"return the argument to be passed with the change notification. |
1762 |
Defined as separate method for easier subclassability." |
|
1763 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1764 |
^ self contents |
597 | 1765 |
|
1766 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1767 |
! |
1768 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1770 |
"get my contents from the model. |
597 | 1771 |
Redefined to ignore updates resulting from my own changes |
1772 |
(i.e. if lockUpdates is true)." |
|
121 | 1773 |
|
1774 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1775 |
ignore updates from my own change |
121 | 1776 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1777 |
lockUpdates ifTrue:[ |
4823 | 1778 |
lockUpdates := false. |
1779 |
^ self |
|
121 | 1780 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1781 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1782 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1783 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1784 |
"/ validate the cursorLine |
3160 | 1785 |
(cursorLine notNil |
2310 | 1786 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1787 |
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
|
1788 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1789 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1790 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1791 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1792 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1793 |
acceptChannel value == true ifTrue:[ |
1794 |
self accept. |
|
1795 |
]. |
|
1796 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1797 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1798 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1799 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1800 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1801 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1802 |
! ! |
1803 |
||
6015 | 1804 |
!EditTextView methodsFor:'commenting'! |
1805 |
||
1806 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1807 |
"helper function to comment out a block. |
|
1808 |
All lines from line1 to line2 get an end-of-line comment |
|
1809 |
in the first col |
|
1810 |
(if no eol comment is available, a bracketing comment is used)." |
|
1811 |
||
1812 |
|eolComment opening closing| |
|
1813 |
||
1814 |
eolComment := commentStrings at:1. |
|
1815 |
eolComment isNil ifTrue:[ |
|
1816 |
opening := (commentStrings at:2) at:1. |
|
1817 |
closing := (commentStrings at:2) at:2. |
|
1818 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1819 |
]. |
|
1820 |
||
1821 |
line1 to:line2 do:[:lineNr | |
|
1822 |
|l| |
|
1823 |
||
1824 |
l := self listAt:lineNr. |
|
1825 |
l isNil ifTrue:[l := '']. |
|
1826 |
eolComment notNil ifTrue:[ |
|
1827 |
l := eolComment , l |
|
1828 |
] ifFalse:[ |
|
1829 |
l := opening , l , closing |
|
1830 |
]. |
|
1831 |
self replaceLine:lineNr with:l. |
|
1832 |
widthOfWidestLine notNil ifTrue:[ |
|
1833 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1834 |
]. |
|
1835 |
]. |
|
1836 |
self textChanged. |
|
1837 |
||
1838 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1839 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1840 |
! |
|
1841 |
||
1842 |
commentSelection:commentStrings |
|
1843 |
"convenient function to comment out a block. |
|
1844 |
All lines from line1 to line2 get an end-of-line comment |
|
1845 |
in the first col." |
|
1846 |
||
1847 |
|e commentPair opening closing| |
|
1848 |
||
1849 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1850 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1851 |
||
1852 |
self |
|
1853 |
undoableDo:[ |
|
1854 |
selectionStartLine isNil ifTrue:[ |
|
1855 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1856 |
] ifFalse:[ |
|
1857 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1858 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1859 |
] ifFalse:[ |
|
1860 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1861 |
commentPair isNil ifTrue:[ |
|
1862 |
self beep. |
|
1863 |
] ifFalse:[ |
|
1864 |
opening := commentPair at:1. |
|
1865 |
closing := commentPair at:2. |
|
1866 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1867 |
||
1868 |
e := selectionEndCol. |
|
1869 |
||
1870 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1871 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1872 |
||
1873 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1874 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1875 |
toLine:selectionEndLine col:e+closing size. |
|
1876 |
] |
|
1877 |
] |
|
1878 |
]. |
|
1879 |
] |
|
1880 |
info:'Comment'. |
|
1881 |
||
1882 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1883 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1884 |
! |
|
1885 |
||
1886 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1887 |
"helper function to comment out a block. |
|
1888 |
All lines from line1 to line2 get an end-of-line comment |
|
1889 |
in the first col. |
|
1890 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1891 |
||
1892 |
|eolComment opening closing rest| |
|
1893 |
||
1894 |
eolComment := commentStrings at:1. |
|
1895 |
eolComment isNil ifTrue:[ |
|
1896 |
opening := (commentStrings at:2) at:1. |
|
1897 |
closing := (commentStrings at:2) at:2. |
|
1898 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1899 |
] ifFalse:[ |
|
1900 |
rest := eolComment size + 1. |
|
1901 |
]. |
|
1902 |
||
1903 |
line1 to:line2 do:[:lineNr | |
|
1904 |
|l| |
|
1905 |
||
1906 |
l := self listAt:lineNr. |
|
1907 |
l notNil ifTrue:[ |
|
1908 |
eolComment notNil ifTrue:[ |
|
1909 |
(l startsWith:eolComment) ifTrue:[ |
|
1910 |
l := l copyFrom:rest |
|
1911 |
] ifFalse:[ |
|
1912 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
1913 |
"/ only for single lines? |
|
1914 |
true "line1 = line2" ifTrue:[ |
|
1915 |
|numSpaces| |
|
1916 |
||
1917 |
numSpaces := l indexOfNonSeparator - 1. |
|
1918 |
l := l copyFrom:numSpaces+1+rest. |
|
1919 |
l := (String new:numSpaces),l |
|
1920 |
]. |
|
1921 |
]. |
|
1922 |
] |
|
1923 |
] ifFalse:[ |
|
1924 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
1925 |
l := l copyFrom:opening size + 1. |
|
1926 |
l := l copyButLast:closing size. |
|
1927 |
]. |
|
1928 |
]. |
|
1929 |
self replaceLine:lineNr with:l. |
|
1930 |
] |
|
1931 |
]. |
|
1932 |
||
1933 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
1934 |
self textChanged. |
|
1935 |
! |
|
1936 |
||
1937 |
uncommentSelection:commentStrings |
|
1938 |
"convenient function to comment out a block. |
|
1939 |
All lines from line1 to line2 get an end-of-line comment |
|
1940 |
in the first col." |
|
1941 |
||
1942 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
1943 |
||
1944 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1945 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1946 |
||
1947 |
self |
|
1948 |
undoableDo:[ |
|
1949 |
selectionStartLine isNil ifTrue:[ |
|
1950 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1951 |
] ifFalse:[ |
|
1952 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1953 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1954 |
] ifFalse:[ |
|
1955 |
commentPair := commentStrings at:2. |
|
1956 |
opening := commentPair at:1. |
|
1957 |
closing := commentPair at:2. |
|
1958 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1959 |
||
1960 |
sz1 := opening size. |
|
1961 |
sz2 := closing size. |
|
1962 |
||
1963 |
((self |
|
1964 |
stringAtLine:selectionStartLine |
|
1965 |
from:selectionStartCol |
|
1966 |
to:selectionStartCol+sz1 - 1) = opening |
|
1967 |
and:[(self |
|
1968 |
stringAtLine:selectionEndLine |
|
1969 |
from:selectionEndCol - sz2 + 1 |
|
1970 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1971 |
||
1972 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
1973 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1974 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1975 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1976 |
||
1977 |
e := c2 - sz2. |
|
1978 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1979 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1980 |
] |
|
1981 |
] |
|
1982 |
]. |
|
1983 |
] |
|
1984 |
info:'Uncomment'. |
|
1985 |
||
1986 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
1987 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
1988 |
! ! |
|
1989 |
||
121 | 1990 |
!EditTextView methodsFor:'cursor handling'! |
1991 |
||
4820 | 1992 |
basicCursorReturn |
1993 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1994 |
||
1995 |
|wasOn| |
|
1996 |
||
1997 |
self checkForExistingLine:(cursorLine + 1). |
|
1998 |
cursorVisibleLine notNil ifTrue:[ |
|
1999 |
nFullLinesShown notNil ifTrue:[ |
|
2000 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
2001 |
] |
|
2002 |
]. |
|
2003 |
||
2004 |
wasOn := self hideCursor. |
|
2005 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
2006 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2007 |
||
2008 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
2009 |
! |
|
2010 |
||
2406 | 2011 |
characterPositionOfCursor |
2012 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
2013 |
! |
|
2014 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2015 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2016 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2017 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2018 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2019 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2020 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2021 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2022 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2023 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2024 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2025 |
|
2822 | 2026 |
(cursorCol == newCol) ifTrue:[^ self]. |
2027 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2028 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2029 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2030 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2031 |
|
2032 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2033 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2034 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2035 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2036 |
"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
|
2037 |
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
|
2038 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2039 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2040 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2041 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2042 |
|
2707 | 2043 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2044 |
cursorLine > list size ifTrue:[ |
4595 | 2045 |
wasOn := self hideCursor. |
2046 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
2047 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2048 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2049 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2050 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2051 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
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 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2055 |
"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
|
2056 |
|
5857 | 2057 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2058 |
|
4595 | 2059 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 2060 |
nL := firstLineShown |
2061 |
]. |
|
2062 |
||
2063 |
inLastLine := (nL == list size). |
|
5890 | 2064 |
|
5857 | 2065 |
inLastLine ifTrue:[ |
5858 | 2066 |
|generateTextAfterEndHook| |
5857 | 2067 |
|
2068 |
cursorColBefore := cursorCol. |
|
5858 | 2069 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 2070 |
wasOn := self hideCursor. |
2071 |
nL := generateTextAfterEndHook value:(nL + n). |
|
2072 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
2073 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2074 |
^ self. |
|
5890 | 2075 |
]. |
4595 | 2076 |
]. |
2077 |
||
2078 |
self st80EditMode ifTrue:[ |
|
5857 | 2079 |
nL == list size ifTrue:[ |
2080 |
wasOn := self hideCursor. |
|
2081 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2082 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2083 |
self beep. |
|
2084 |
^ self. |
|
2085 |
] |
|
4595 | 2086 |
]. |
2087 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2089 |
wasOn := self hideCursor. |
2090 |
nv := cursorVisibleLine + n - 1. |
|
2091 |
(nv >= nFullLinesShown) ifTrue:[ |
|
2092 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
2093 |
]. |
|
2094 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2095 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2096 |
] ifFalse:[ |
5857 | 2097 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2098 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2099 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2100 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2101 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2102 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2103 |
|
121 | 2104 |
cursorHome |
597 | 2105 |
"scroll to top AND move cursor to first line of text." |
121 | 2106 |
|
674 | 2107 |
self cursorLine:1 col:1 |
2108 |
||
2109 |
"/ |wasOn| |
|
2110 |
"/ |
|
2111 |
"/ wasOn := self hideCursor. |
|
2112 |
"/ self scrollToTop. |
|
2113 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2114 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2115 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2116 |
||
2117 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2118 |
! |
2119 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2120 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2121 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2122 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2123 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 2124 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2125 |
] ifFalse:[ |
4823 | 2126 |
cursorLine ~~ 1 ifTrue:[ |
2127 |
self st80EditMode ifTrue:[ |
|
2128 |
self cursorUp. |
|
2129 |
self cursorToEndOfLine. |
|
2130 |
] |
|
2131 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2132 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2133 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2134 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2135 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2136 |
|
4126 | 2137 |
cursorLeft:n |
2138 |
"move cursor to left" |
|
2139 |
||
2140 |
n timesRepeat:[ |
|
2141 |
self cursorLeft |
|
2142 |
]. |
|
2143 |
! |
|
2144 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2145 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2147 |
|
5056 | 2148 |
self cursorLine:line col:col makeVisible:true |
2149 |
! |
|
2150 |
||
2151 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2152 |
"this positions onto physical - not visible - line" |
|
2153 |
||
676 | 2154 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2155 |
|
2822 | 2156 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2157 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2158 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2159 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2160 |
|
672 | 2161 |
(col < 1) ifTrue:[ |
4823 | 2162 |
newCol := 1 |
672 | 2163 |
] ifFalse:[ |
4823 | 2164 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2165 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2166 |
self st80EditMode ifTrue:[ |
4823 | 2167 |
(cursorLine == list size |
2168 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2169 |
newCol := (self listAt:(list size)) size + 1. |
|
2170 |
] |
|
1419 | 2171 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2172 |
self setValidatedCursorCol:newCol. |
5056 | 2173 |
makeVisibleBoolean ifTrue:[ |
2174 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2175 |
] ifFalse:[ |
|
2176 |
wasOn ifTrue:[self showCursor] |
|
2177 |
]. |
|
672 | 2178 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2179 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2180 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2181 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2182 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2183 |
"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
|
2184 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2185 |
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
|
2186 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2187 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2188 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2189 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2190 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2191 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2192 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2193 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2194 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2195 |
"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
|
2196 |
|
4820 | 2197 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2199 |
|
5529 | 2200 |
cursorReturn:withPossibleAutoIndent |
2201 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2202 |
||
2203 |
self basicCursorReturn |
|
2204 |
! |
|
2205 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2206 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2207 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2208 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2209 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2210 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2211 |
self st80EditMode ifTrue:[ |
4823 | 2212 |
l := (self listAt:cursorLine). |
2213 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 2214 |
cursorLine <= list size ifTrue:[ |
2215 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 2216 |
]. |
2217 |
^ self |
|
2218 |
] |
|
3160 | 2219 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2220 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2221 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2222 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2223 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2224 |
|
4126 | 2225 |
cursorRight:n |
2226 |
"move cursor to right" |
|
2227 |
||
2228 |
n timesRepeat:[ |
|
2229 |
self cursorRight |
|
2230 |
]. |
|
2231 |
! |
|
2232 |
||
1833 | 2233 |
cursorShown:aBoolean |
2234 |
"change cursor visibility |
|
2235 |
return true if cursor was visible before." |
|
2236 |
||
2237 |
|oldState| |
|
2238 |
||
4494 | 2239 |
aBoolean == cursorShown ifTrue:[ |
2240 |
^ cursorShown |
|
2241 |
]. |
|
1833 | 2242 |
oldState := cursorShown. |
2243 |
||
2244 |
aBoolean ifTrue:[ |
|
4494 | 2245 |
self drawCursor. |
1833 | 2246 |
] ifFalse:[ |
4494 | 2247 |
(cursorShown and:[shown]) ifTrue: [ |
2248 |
self undrawCursor. |
|
2249 |
]. |
|
1833 | 2250 |
]. |
2251 |
cursorShown := aBoolean. |
|
2252 |
||
2253 |
^ oldState |
|
2254 |
||
2255 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2256 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2257 |
! |
|
2258 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2259 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2260 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2263 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2264 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2265 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2266 |
"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
|
2267 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2268 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2269 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2270 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2271 |
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
|
2272 |
cursorCol > textStart ifTrue:[ |
4823 | 2273 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2274 |
] ifFalse:[ |
4823 | 2275 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2276 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2277 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2278 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2279 |
! |
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 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2282 |
"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
|
2283 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2284 |
|wasOn newTop| |
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 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2287 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2288 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2289 |
(newTop < 1) ifTrue:[ |
4823 | 2290 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2293 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2294 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2295 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2296 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2297 |
|
674 | 2298 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
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 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2301 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2302 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2303 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2304 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2305 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2306 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2307 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2308 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2309 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2310 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2311 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2312 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2313 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2314 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2315 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2316 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2317 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2318 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2319 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2320 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2321 |
cursorLine >= lineNr ifTrue:[ |
4823 | 2322 |
line := self listAt:cursorLine. |
2323 |
(line isEmptyOrNil) ifTrue:[ |
|
2324 |
^ self |
|
2325 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2326 |
]. |
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 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2329 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2330 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2331 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2332 |
(newTop < 1) ifTrue:[ |
4823 | 2333 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2334 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2335 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2336 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2337 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2339 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2340 |
|
674 | 2341 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2342 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2343 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2344 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2345 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2346 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2347 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2348 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2349 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2350 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2351 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2352 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2353 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2354 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2355 |
cursorToEndOfText |
4288 | 2356 |
"move cursor to the end of the text (behind the last character in last line)" |
2357 |
||
2358 |
|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
|
2359 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2360 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2361 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2362 |
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
|
2363 |
(newTop < 1) ifTrue:[ |
4288 | 2364 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2365 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2366 |
self scrollToLine:newTop. |
2422
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 |
self setValidatedCursorLine:list size. |
4288 | 2369 |
lastLineLength := (self listAt:cursorLine) size. |
2370 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2371 |
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
|
2372 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2373 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2374 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2375 |
"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
|
2376 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2377 |
|
3310 | 2378 |
cursorToEndOfWord |
2379 |
"move the cursor to the end of the word" |
|
2380 |
||
2381 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2382 |
||
2383 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2384 |
:beginLine :beginCol :endLine :endCol :style | |
2385 |
||
2386 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2387 |
] |
2388 |
||
2389 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2390 |
! |
|
2391 |
||
131 | 2392 |
cursorToFirstVisibleLine |
2393 |
"place cursor into the first visible line; do not scroll." |
|
2394 |
||
2395 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2396 |
! |
|
2397 |
||
2398 |
cursorToLastVisibleLine |
|
2399 |
"place cursor into the first visible line; do not scroll." |
|
2400 |
||
2401 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2402 |
! |
|
2403 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2404 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2405 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2406 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2407 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2408 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2409 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2410 |
|
3890 | 2411 |
self |
4707 | 2412 |
wordAtLine:cursorLine col:cursorCol |
2413 |
do:[ |
|
3890 | 2414 |
:beginLine :beginCol :endLine :endCol :style | |
2415 |
||
2416 |
line := endLine. |
|
2417 |
col := endCol + 1. |
|
2418 |
searching := true. |
|
4707 | 2419 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2420 |
self wordAtLine:line col:col do:[ |
2421 |
:beginLine :beginCol :endLine :endCol :style | |
|
2422 |
||
2423 |
(line > list size) ifTrue:[ |
|
2424 |
"break out" |
|
2425 |
searching := false |
|
2426 |
] ifFalse:[ |
|
2427 |
line := endLine. |
|
2428 |
col := endCol + 1. |
|
2429 |
] |
|
2430 |
] |
|
2431 |
]. |
|
2432 |
self cursorLine:line col:col |
|
4707 | 2433 |
] |
121 | 2434 |
! |
2435 |
||
499 | 2436 |
cursorToPreviousWord |
2437 |
"move the cursor to the beginning of this or the previous word" |
|
2438 |
||
2439 |
|col line searching l| |
|
2440 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2441 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2442 |
|
2443 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2444 |
:beginLine :beginCol :endLine :endCol :style | |
2445 |
||
2446 |
line := beginLine. |
|
2447 |
col := beginCol. |
|
2448 |
style == #wordLeft ifTrue:[ |
|
2449 |
col := col + 1 |
|
2450 |
]. |
|
2451 |
||
2452 |
(cursorLine == line |
|
2453 |
and:[cursorCol == col]) ifTrue:[ |
|
2454 |
searching := true. |
|
2455 |
||
2456 |
col > 1 ifTrue:[ |
|
2457 |
col := col - 1. |
|
2458 |
]. |
|
2459 |
||
2460 |
[searching] whileTrue:[ |
|
2461 |
(col == 1) ifTrue:[ |
|
2462 |
line == 1 ifTrue:[ |
|
2463 |
searching := false |
|
2464 |
] ifFalse:[ |
|
2465 |
line := line - 1. |
|
2466 |
l := list at:line. |
|
2467 |
col := l size + 1. |
|
2468 |
] |
|
2469 |
] ifFalse:[ |
|
2470 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2471 |
self wordAtLine:line col:col do:[ |
|
2472 |
:beginLine :beginCol :endLine :endCol :style | |
|
2473 |
||
2474 |
line := beginLine. |
|
2475 |
col := beginCol. |
|
2476 |
style == #wordLeft ifTrue:[ |
|
2477 |
col := col + 1 |
|
2478 |
]. |
|
2479 |
searching := false. |
|
2480 |
] |
|
2481 |
] ifTrue:[ |
|
2482 |
col := col - 1 |
|
2483 |
] |
|
2484 |
] |
|
2485 |
] |
|
2486 |
]. |
|
2487 |
self cursorLine:line col:col |
|
499 | 2488 |
] |
2489 |
||
2490 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2491 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2492 |
! |
|
2493 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2494 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2495 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2496 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2497 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2498 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2499 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2500 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2501 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2502 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2503 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2504 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2505 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2506 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2507 |
"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
|
2508 |
|
5856 | 2509 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2511 |
cursorLine isNil ifTrue:[ |
5850 | 2512 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2513 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2514 |
nl := cursorLine - n. |
5850 | 2515 |
nl < 1 ifTrue:[ |
5858 | 2516 |
|generateTextBeforeStartHook| |
5890 | 2517 |
|
5856 | 2518 |
cursorColBefore := cursorCol. |
5858 | 2519 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2520 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2521 |
]. |
5850 | 2522 |
nl := nl max:1 |
2523 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2524 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2525 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2526 |
wasOn := self hideCursor. |
2527 |
cursorVisibleLine notNil ifTrue:[ |
|
2528 |
nv := cursorVisibleLine - n. |
|
2529 |
nv < 1 ifTrue:[ |
|
2530 |
self scrollUp:(nv negated + 1) |
|
2531 |
]. |
|
2532 |
]. |
|
5856 | 2533 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2534 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2535 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
] |
672 | 2537 |
|
674 | 2538 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2539 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2540 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2541 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2542 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2543 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2544 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2545 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2546 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2547 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2548 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2549 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2550 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2551 |
|
676 | 2552 |
newCol := colNr. |
2553 |
(newCol < 1) ifTrue:[ |
|
4823 | 2554 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2555 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2556 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2557 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2558 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2559 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2560 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2561 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2562 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2563 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2564 |
"put cursor to position next to x/y coordinate in view" |
121 | 2565 |
|
2566 |
|line col| |
|
2567 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2568 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2569 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2570 |
self cursorVisibleLine:line col:col. |
121 | 2571 |
! |
2572 |
||
2573 |
drawCursor |
|
2574 |
"draw the cursor if shown and cursor is visible. |
|
2575 |
(but not, if there is a selection - to avoid confusion)" |
|
2576 |
||
2577 |
shown ifTrue:[ |
|
4823 | 2578 |
cursorVisibleLine notNil ifTrue:[ |
2579 |
self hasSelection ifFalse:[ |
|
2580 |
self drawCursorCharacter |
|
2581 |
] |
|
2582 |
] |
|
121 | 2583 |
] |
2584 |
! |
|
2585 |
||
2586 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2587 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2588 |
of cursor should be drawn. |
4721 | 2589 |
Currently, supported are: #none, |
6031 | 2590 |
#block, #frame, #ibeam, #caret, #solidCaret |
2591 |
#bigCaret and #bigSolidCaret" |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2592 |
|
2570 | 2593 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2594 |
|
2595 |
self hasSelection ifTrue:[ |
|
6031 | 2596 |
" |
2597 |
hide cursor, if there is a selection |
|
2598 |
" |
|
2599 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2600 |
]. |
2601 |
||
1334 | 2602 |
cursorType == #none ifTrue:[ |
6031 | 2603 |
^ self |
1334 | 2604 |
]. |
2605 |
||
121 | 2606 |
cursorType == #block ifTrue:[ |
6031 | 2607 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
2608 |
^ self |
|
121 | 2609 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2610 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2611 |
y := self yOfVisibleLine:cursorVisibleLine. |
2612 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2613 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2614 |
cursorType == #frame ifTrue:[ |
6031 | 2615 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2616 |
||
2617 |
char := self characterUnderCursor asString. |
|
6068 | 2618 |
gc paint:bgColor. |
2619 |
gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
|
133 | 2620 |
] ifFalse:[ |
6031 | 2621 |
self paint:bgColor. |
2622 |
cursorType == #ibeam ifTrue:[ |
|
2623 |
x1 := x - 1. |
|
2624 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2625 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2626 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
6031 | 2627 |
^ self |
2628 |
]. |
|
2629 |
||
2630 |
cursorType == #Ibeam ifTrue:[ |
|
2631 |
x1 := x - 1. |
|
2632 |
y := y + 1. |
|
2633 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2634 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2635 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
2636 |
gc displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2637 |
gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
6031 | 2638 |
^ self |
2639 |
]. |
|
2640 |
||
2641 |
y := y + fontHeight - 3. |
|
2642 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2643 |
w := (fontWidth * 2 // 3) max:4. |
|
2644 |
y2 := y + w + (w//2). |
|
2645 |
] ifFalse:[ |
|
2646 |
w := (fontWidth // 2) max:4. |
|
2647 |
y2 := y + w. |
|
2648 |
]. |
|
2649 |
x1 := x - w. |
|
2650 |
x2 := x + w. |
|
2651 |
||
2652 |
oldClip := self clippingBoundsOrNil. |
|
2653 |
self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2654 |
||
2655 |
cursorType == #caret ifTrue:[ |
|
6068 | 2656 |
gc lineWidth:2. |
2657 |
gc displayLineFromX:x1 y:y2 toX:x y:y. |
|
2658 |
gc displayLineFromX:x y:y toX:x2 y:y2. |
|
6031 | 2659 |
] ifFalse:[ |
2660 |
"anything else: solidCaret" |
|
2661 |
||
6068 | 2662 |
gc fillPolygon:(Array with:(x1 @ y2) |
2663 |
with:(x @ y) |
|
2664 |
with:(x2 @ y2)) |
|
6031 | 2665 |
]. |
2666 |
||
2667 |
self clippingBounds:oldClip |
|
121 | 2668 |
]. |
6068 | 2669 |
gc paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2670 |
|
2088 | 2671 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2672 |
! |
2673 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2674 |
drawCursorCharacter |
3160 | 2675 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2676 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2677 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2678 |
|
3160 | 2679 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2680 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2681 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2682 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2683 |
] ifFalse:[ |
4823 | 2684 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2685 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2686 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2687 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2688 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2689 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2690 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2691 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2692 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2693 |
self hasSelection ifTrue:[ |
5260 | 2694 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2695 |
]. |
2696 |
cursorType == #none ifTrue:[ |
|
4823 | 2697 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2698 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2699 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2700 |
|
2701 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2702 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2703 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2704 |
drawNoFocusCursor |
3160 | 2705 |
"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
|
2706 |
|
1334 | 2707 |
|cType| |
2708 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2709 |
self hasSelection ifTrue:[ |
4823 | 2710 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2711 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2712 |
|
1334 | 2713 |
cType := cursorTypeNoFocus ? cursorType. |
2714 |
cType == #none ifTrue:[ |
|
4823 | 2715 |
^ self undrawCursor |
1334 | 2716 |
]. |
2717 |
||
2718 |
cType == #block ifTrue:[ |
|
4823 | 2719 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2720 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2721 |
|
1334 | 2722 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2723 |
||
2724 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2725 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2726 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2727 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2728 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2729 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2730 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2731 |
self makeLineVisible:aLineNumber. |
2951 | 2732 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2733 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2734 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2735 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2736 |
hideCursor |
1833 | 2737 |
"make cursor invisible if currently invisible" |
2738 |
||
2739 |
^ self cursorShown:false |
|
2740 |
||
2741 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2742 |
! |
2743 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2744 |
makeCursorVisible |
3160 | 2745 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2746 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2747 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2748 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2749 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2750 |
cursorLine notNil ifTrue:[ |
4823 | 2751 |
line := cursorLine. |
2752 |
col := cursorCol. |
|
2753 |
" |
|
2754 |
if there is a selection, its better to |
|
2755 |
have its start being visible, instead of the end |
|
2756 |
" |
|
2757 |
(selectionStartLine notNil |
|
2758 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2759 |
expandingTop ~~ false ifTrue:[ |
|
2760 |
line := selectionStartLine. |
|
2761 |
col := selectionStartCol. |
|
2762 |
] ifFalse:[ |
|
2763 |
line := selectionEndLine. |
|
2764 |
col := selectionEndCol |
|
2765 |
] |
|
2766 |
]. |
|
2767 |
self makeLineVisible:line. |
|
2768 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2769 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2770 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2771 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2772 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2773 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2774 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2775 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2776 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2777 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2778 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2779 |
flag ifTrue:[self showCursor] |
121 | 2780 |
! |
2781 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2782 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2783 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2784 |
|
2815 | 2785 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2786 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2787 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2788 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2789 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2790 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2791 |
|
3303 | 2792 |
"/ self assert:(lineNr notNil). |
2793 |
||
2794 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2795 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2796 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2797 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2798 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2799 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2800 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2801 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2802 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2803 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2804 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2805 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2806 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2807 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2808 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2809 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2810 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2811 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2812 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2813 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2814 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2815 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2816 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2817 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2818 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2819 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2820 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2821 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2822 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2823 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2824 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2825 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2826 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2827 |
|
1833 | 2828 |
^ self cursorShown:true |
2829 |
||
2830 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2831 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2832 |
|
5761 | 2833 |
singleQuoteSelection |
2834 |
"place single quotes around the selected text" |
|
2835 |
||
2836 |
|line1 col1 line2 col2| |
|
2837 |
||
2838 |
line1 := self selectionStartLine. |
|
2839 |
col1 := self selectionStartCol. |
|
2840 |
line2 := self selectionEndLine. |
|
2841 |
col2 := self selectionEndCol. |
|
2842 |
(line1 notNil |
|
2843 |
and:[ col1 notNil |
|
2844 |
and:[ line2 notNil |
|
2845 |
and:[ col2 notNil ]]]) |
|
2846 |
ifTrue:[ |
|
2847 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
2848 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2849 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
2850 |
] ifFalse:[ |
|
2851 |
self beep. |
|
2852 |
] |
|
2853 |
||
2854 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2855 |
! |
|
2856 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2857 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2858 |
"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
|
2859 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2860 |
|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
|
2861 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2862 |
cursorVisibleLine notNil ifTrue:[ |
6031 | 2863 |
prevCol := cursorCol - 1. |
2864 |
||
2865 |
"/ if there is any italic stuff in the cursor line, |
|
2866 |
"/ redraw it completely (because characters overlap). |
|
2867 |
cursorCol > 1 ifTrue:[ |
|
2868 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2869 |
line hasChangeOfEmphasis ifTrue:[ |
|
2870 |
line size >= (cursorCol-1) ifTrue:[ |
|
2871 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2872 |
line size >= (cursorCol) ifTrue:[ |
|
2873 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2874 |
line size >= (cursorCol+1) ifTrue:[ |
|
2875 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2876 |
]. |
|
2877 |
]. |
|
2878 |
]. |
|
2879 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2880 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2881 |
] |
|
2882 |
] |
|
2883 |
] |
|
2884 |
]. |
|
2885 |
||
2886 |
((cursorType == #caret) |
|
2887 |
or:[cursorType == #solidCaret |
|
2888 |
or:[cursorType == #bigSolidCaret |
|
2889 |
or:[cursorType == #bigCaret |
|
2890 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2891 |
"caret-cursor touches 4 characters" |
|
2892 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2893 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2894 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2895 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2896 |
] ifFalse:[ |
|
2897 |
"care for left margin" |
|
2898 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2899 |
]. |
|
2900 |
^ self |
|
2901 |
]. |
|
2902 |
||
2903 |
cursorType == #ibeam ifTrue:[ |
|
2904 |
"ibeam-cursor touches 2 characters" |
|
2905 |
cursorCol > 1 ifTrue:[ |
|
2906 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2907 |
] ifFalse:[ |
|
2908 |
"care for left margin" |
|
2909 |
super redrawVisibleLine:cursorVisibleLine. |
|
2910 |
]. |
|
2911 |
^ self |
|
2912 |
]. |
|
2913 |
||
2914 |
"block cursor is simple - just one character under cursor" |
|
2915 |
||
2916 |
"/ however, if italic characters are involved, we must care |
|
2917 |
"/ for the chars before/after the cursor. |
|
2918 |
"/ We redraw the part of the previous character which got |
|
2919 |
"/ detroyed by the block cursor. |
|
2920 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2921 |
||
2922 |
line := self visibleAt:cursorVisibleLine. |
|
2923 |
(line notNil and:[line isText]) ifTrue:[ |
|
2924 |
cursorCol > 1 ifTrue:[ |
|
2925 |
oldClip := self clippingBoundsOrNil. |
|
2926 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2927 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2928 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
2929 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2930 |
self clippingBounds:oldClip. |
|
2931 |
^ self. |
|
2932 |
]. |
|
2933 |
]. |
|
2934 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2935 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2936 |
|
2088 | 2937 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2938 |
! |
2939 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2940 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2941 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2942 |
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
|
2943 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2944 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2945 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2946 |
|
672 | 2947 |
validateCursorCol:col inLine:line |
674 | 2948 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2949 |
Here, no limits are enforced (and col is returned), |
5593 | 2950 |
but it may be redefined in EditFields or views which don't like the |
674 | 2951 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2952 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2953 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2954 |
|
1419 | 2955 |
"/ in ST80 mode, |
2707 | 2956 |
"/ the cursor may not be positioned beyond the |
2957 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2958 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2959 |
self st80EditMode ifTrue:[ |
4823 | 2960 |
l := (self listAt:line). |
2961 |
max := l size + 1. |
|
2962 |
col > max ifTrue:[ |
|
2963 |
^ max |
|
2964 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2965 |
]. |
672 | 2966 |
^ col |
2967 |
||
1419 | 2968 |
"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
|
2969 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2970 |
! |
2971 |
||
2972 |
validateCursorLine:line |
|
2973 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2974 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2975 |
redefined in views which don't like the cursor to be positioned |
674 | 2976 |
behind the end of the text (vi/st-80 behavior), or want to |
2977 |
skip reserved regions" |
|
2978 |
||
1419 | 2979 |
"/ |
2980 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2981 |
"/ beyond the last line |
2982 |
"/ (but it must be posible to place it on one line below the last one |
|
2983 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2984 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2985 |
self st80EditMode ifTrue:[ |
5367 | 2986 |
^ (line min:(list size + 1)) max:1 |
1419 | 2987 |
]. |
674 | 2988 |
^ line |
2989 |
||
1419 | 2990 |
"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
|
2991 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2992 |
! |
2993 |
||
121 | 2994 |
withCursorOffDo:aBlock |
2995 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2996 |
||
2997 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2998 |
^ aBlock value |
121 | 2999 |
]. |
3000 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
3001 |
aBlock ensure:[ |
4823 | 3002 |
self showCursor |
121 | 3003 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3004 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3005 |
|
2589 | 3006 |
!EditTextView methodsFor:'drag & drop'! |
3007 |
||
3008 |
allowDrop:aBoolean |
|
3236 | 3009 |
"enable/disable drop support" |
3010 |
||
2589 | 3011 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3012 |
dropTarget := nil. |
2589 | 3013 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3014 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3015 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3016 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3017 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3018 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3019 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3020 |
] |
3236 | 3021 |
]. |
3022 |
! |
|
3023 |
||
3412 | 3024 |
canDrop:aDropContext |
3025 |
"public from d&d. |
|
3026 |
I accept textObjects and fileObjects only." |
|
3027 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
3028 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 3029 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
3030 |
^ self canDropObjects:aDropContext dropObjects |
|
3031 |
||
3032 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
3033 |
! |
|
3034 |
||
3035 |
canDropObjects:aCollectionOfDropObjects |
|
3036 |
"public from d&d. |
|
3037 |
I accept textObjects and fileObjects only." |
|
2589 | 3038 |
|
3039 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
3040 |
||
3412 | 3041 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
3042 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
3043 |
||
3044 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
3045 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
3046 |
! |
|
3047 |
||
3048 |
drop:aDropContext |
|
3049 |
"public from d&d. |
|
3050 |
drop objects (new API)" |
|
3051 |
||
3052 |
self dropObjects:(aDropContext dropObjects) |
|
3053 |
||
3054 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
3055 |
! |
|
3056 |
||
3057 |
dropFileObject:aDropObject |
|
2589 | 3058 |
"drop objects |
3236 | 3059 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3060 |
||
4136 | 3061 |
|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
|
3062 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3063 |
pasteWhat := #name. |
3412 | 3064 |
|
3065 |
fn := aDropObject asFilename. |
|
3066 |
(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
|
3067 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3068 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3069 |
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
|
3070 |
pasteWhat := enforcedDropMode. |
3886 | 3071 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3072 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3073 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3074 |
pasteWhat := #name. |
3886 | 3075 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3076 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3077 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3078 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3079 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3080 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3081 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3082 |
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
|
3083 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3084 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3085 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3086 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3087 |
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
|
3088 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3089 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3090 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3091 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3092 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3093 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3094 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3095 |
] |
3886 | 3096 |
] |
3097 |
]. |
|
3098 |
]. |
|
3099 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3100 |
pasteWhat == #name ifTrue:[ |
3886 | 3101 |
text := fn pathName |
3102 |
] ifFalse:[ |
|
3103 |
self withWaitCursorDo:[ |
|
5063 | 3104 |
text := fn contentsAsString |
4136 | 3105 |
]. |
3106 |
(app := self application) notNil ifTrue:[ |
|
3107 |
app droppedFile:fn in:self |
|
3108 |
]. |
|
3886 | 3109 |
]. |
3110 |
||
3799 | 3111 |
self |
3112 |
undoablePaste:text |
|
3113 |
info:'Drop File'. |
|
3412 | 3114 |
|
3115 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3116 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3117 |
! |
3118 |
||
3119 |
dropObject:aDropObject |
|
3120 |
"drop objects |
|
3121 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3122 |
||
3415 | 3123 |
|text| |
3124 |
||
3412 | 3125 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 3126 |
self dropFileObject:aDropObject |
3412 | 3127 |
] ifFalse:[ |
3799 | 3128 |
aDropObject isTextObject ifTrue:[ |
3129 |
text := aDropObject theObject. |
|
3130 |
text isStringCollection ifTrue:[ |
|
3131 |
text := text asStringWithoutFinalCR |
|
3132 |
]. |
|
3133 |
] ifFalse:[ |
|
3134 |
text := aDropObject theObject asString |
|
3135 |
]. |
|
3136 |
self |
|
3137 |
undoablePaste:text |
|
3138 |
info:'Drop'. |
|
3412 | 3139 |
]. |
3140 |
||
3141 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3142 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3143 |
! |
3144 |
||
3145 |
dropObjects:aCollectionOfDropObjects |
|
3146 |
"public from d&d. |
|
3147 |
drop objects (old API)" |
|
3148 |
||
3868 | 3149 |
aCollectionOfDropObjects do:[:el | |
3150 |
self dropObject:el |
|
3412 | 3151 |
]. |
3152 |
||
3153 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3154 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3155 |
! ! |
3156 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3157 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3158 |
|
5761 | 3159 |
applyConverterToSelection:converter |
3160 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3161 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3162 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3163 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3164 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3165 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3166 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3167 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3168 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3169 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3170 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3171 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3172 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3173 |
line1 to:line2 do:[:lineNr | |
5761 | 3174 |
|line col1 col2 newLine| |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3175 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3176 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3177 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3178 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3179 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3180 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3181 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3182 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3183 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3184 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3185 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3186 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3187 |
]. |
5761 | 3188 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
3189 |
self withoutRedrawAt:lineNr put:newLine. |
|
3190 |
self invalidateLine:lineNr. |
|
3191 |
]. |
|
3192 |
]. |
|
3193 |
] |
|
3194 |
||
3195 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
3196 |
! |
|
3197 |
||
3198 |
convertSelectionToLowercase |
|
3199 |
"to-lower selected text" |
|
3200 |
||
3201 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3202 |
col1 to:col2 do:[:col | |
|
3203 |
|ch| |
|
3204 |
||
3205 |
ch := line at:col. |
|
3206 |
line at:col put:ch asLowercase. |
|
3207 |
]. |
|
3208 |
line. |
|
3209 |
]. |
|
3210 |
||
3211 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3212 |
! |
|
3213 |
||
3214 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3215 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3216 |
||
3217 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
3218 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
|
3219 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3220 |
||
3221 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3222 |
col1 to:col2 do:[:col | |
|
3223 |
|ch| |
|
3224 |
||
3225 |
ch := line at:col. |
|
3226 |
ch isUppercase ifTrue:[ |
|
3227 |
isAllLower := false. |
|
3228 |
col == col1 ifTrue:[ |
|
3229 |
isLowerFirst := false. |
|
3230 |
]. |
|
3231 |
] ifFalse:[ |
|
3232 |
ch isLowercase ifTrue:[ |
|
3233 |
isAllUpper := false. |
|
3234 |
col == col1 ifTrue:[ |
|
3235 |
isUpperFirst := false. |
|
3236 |
]. |
|
3237 |
] |
|
3238 |
]. |
|
3239 |
]. |
|
3240 |
||
3241 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3242 |
isLowerFirst ifTrue:[ |
|
3243 |
makeUppercaseFirst := true. |
|
3244 |
] ifFalse:[ |
|
3245 |
"/ must remember where we come from - otherwise, we end up |
|
3246 |
"/ in upperFirst - lowerFirst cycle. |
|
3247 |
"/ think about a good place to store this state |
|
3248 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3249 |
makeLowercaseFirst := true. |
|
3250 |
] ifFalse:[ |
|
3251 |
isAllUpper ifTrue:[ |
|
3252 |
makeLowercase := true. |
|
3253 |
] ifFalse:[ |
|
3254 |
makeUppercase := true. |
|
3255 |
] |
|
3256 |
] |
|
3257 |
]. |
|
3258 |
makeUppercaseFirst ifTrue:[ |
|
3259 |
line at:col1 put:(line at:col1) asUppercase. |
|
3260 |
] ifFalse:[ |
|
3261 |
makeLowercaseFirst ifTrue:[ |
|
3262 |
line at:col1 put:(line at:col1) asLowercase. |
|
3263 |
] ifFalse:[ |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3264 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3265 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3266 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3267 |
ch := line at:col. |
5761 | 3268 |
ch := makeLowercase |
3269 |
ifTrue:[ ch asLowercase ] |
|
3270 |
ifFalse:[ |
|
3271 |
makeUppercase |
|
3272 |
ifTrue:[ ch asUppercase ] |
|
3273 |
ifFalse:[ |
|
3274 |
col == col1 |
|
3275 |
ifTrue:[ ch asUppercase ] |
|
3276 |
ifFalse:[ ch asLowercase ] |
|
3277 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3278 |
]. |
5761 | 3279 |
line at:col put:ch. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3280 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3281 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3282 |
]. |
5761 | 3283 |
line |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3284 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3285 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3286 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3287 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3288 |
! |
|
3289 |
||
3290 |
convertSelectionToUppercase |
|
3291 |
"to-upper selected text" |
|
3292 |
||
3293 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3294 |
col1 to:col2 do:[:col | |
|
3295 |
|ch| |
|
3296 |
||
3297 |
ch := line at:col. |
|
3298 |
line at:col put:ch asUppercase. |
|
3299 |
]. |
|
3300 |
line. |
|
3301 |
]. |
|
3302 |
||
3303 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3304 |
! |
|
3305 |
||
3306 |
convertSelectionToUppercaseFirst |
|
3307 |
"to-upperFirst selected text" |
|
3308 |
||
3309 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3310 |
|state| |
|
3311 |
||
3312 |
state := #first. |
|
3313 |
col1 to:col2 do:[:col | |
|
3314 |
|ch| |
|
3315 |
||
3316 |
ch := line at:col. |
|
3317 |
ch isSeparator ifFalse:[ |
|
3318 |
state == #first ifTrue:[ |
|
3319 |
line at:col put:ch asUppercase. |
|
3320 |
state := #skipRest |
|
3321 |
] |
|
3322 |
] ifTrue:[ |
|
3323 |
state := #first |
|
3324 |
] |
|
3325 |
]. |
|
3326 |
line. |
|
3327 |
]. |
|
3328 |
||
3329 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3330 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3331 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3332 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3333 |
"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
|
3334 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3335 |
selectionStartLine notNil ifTrue:[ |
4823 | 3336 |
self setClipboardText:(self selection). |
3337 |
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
|
3338 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3339 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3340 |
"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
|
3341 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3342 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3343 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3344 |
"delete single character under cursor; does not merge lines" |
121 | 3345 |
|
3346 |
|wasOn| |
|
3347 |
||
3348 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3349 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3350 |
wasOn ifTrue:[self showCursor] |
3351 |
! |
|
3352 |
||
827 | 3353 |
deleteCharAtLine:lineNr col:colNr |
3354 |
"delete a single character at colNr in line lineNr" |
|
3355 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3356 |
self st80EditMode ifTrue:[ |
4823 | 3357 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3358 |
| wasOn | |
|
3359 |
wasOn := self hideCursor. |
|
3360 |
self |
|
3361 |
cursorReturn; |
|
3362 |
cursorCol:1; |
|
3363 |
deleteCharBeforeCursor. |
|
3364 |
wasOn ifTrue:[ self showCursor]. |
|
3365 |
^ self. |
|
3366 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3367 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3368 |
|
827 | 3369 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3370 |
! |
|
3371 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3372 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3373 |
"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
|
3374 |
|
4592 | 3375 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3376 |
|
6050 | 3377 |
list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete. |
3378 |
||
121 | 3379 |
wasOn := self hideCursor. |
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3380 |
|
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3381 |
"JV@2012-01-06: Do not play with autoindent iff cursor is at the very beginning of the line" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3382 |
(autoIndent |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3383 |
and:[cursorCol ~~ 1 |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3384 |
and:[ (tabPositions includes:cursorCol) |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3385 |
]]) ifTrue:[ |
6050 | 3386 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3387 |
"JV@2011-12-10: The list can be shorter than cursorLine, |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3388 |
trailing because empty lines are not physically in the list." |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3389 |
(list size >= cursorLine) ifTrue:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3390 |
ln := originalLine := (list at:cursorLine) ? ''. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3391 |
] ifFalse:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3392 |
ln := originalLine := ''. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3393 |
]. |
6050 | 3394 |
ln size < prevTab ifTrue:[ |
3395 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3396 |
]. |
|
3397 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3398 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3399 |
cursorCol > prevTab ifTrue:[ |
|
3400 |
self st80EditMode ifTrue:[ |
|
3401 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3402 |
"/ not allow a cursor position beyond the end of line, |
|
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3403 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
6050 | 3404 |
originalLine size < prevTab ifTrue:[ |
3405 |
self checkForExistingLine:cursorLine. |
|
3406 |
self basicListAt:cursorLine put:ln |
|
3407 |
] |
|
3408 |
]. |
|
3409 |
self cursorLine:cursorLine col:prevTab. |
|
3410 |
wasOn ifTrue:[ self showCursor ]. |
|
3411 |
^ self |
|
3412 |
]. |
|
3413 |
] ifFalse:[ |
|
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3414 |
"/ cg: this is ugly behavior; deleting multiple chars at the beginning |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3415 |
"/ is annoying. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3416 |
"/ therefore, only do it, if there are only blanks after the cursor |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3417 |
"/ (ln copyFrom:prevTab+1 to:((cursorCol-1) min:ln size)) isBlank ifTrue:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3418 |
"/ self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3419 |
"/ self cursorLine:cursorLine col:prevTab. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3420 |
"/ wasOn ifTrue:[ self showCursor ]. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3421 |
"/ ^ self. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3422 |
"/ ] |
6050 | 3423 |
] |
3424 |
]. |
|
827 | 3425 |
]. |
3426 |
||
2491 | 3427 |
"/ (autoIndent |
3428 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3429 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3430 |
"/ ifTrue:[ |
3431 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3432 |
"/ |
|
3433 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3434 |
"/ ln := list at:cursorLine. |
|
3435 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3436 |
"/ soCol := 1 |
|
3437 |
"/ ] |
|
3438 |
"/ ] |
|
3439 |
"/ ] ifFalse:[ |
|
6050 | 3440 |
soCol := 1. |
2491 | 3441 |
"/ ]. |
3442 |
||
1419 | 3443 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
6050 | 3444 |
" |
3445 |
somewhere in the middle of a line |
|
3446 |
" |
|
3447 |
self cursorLeft. |
|
3448 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3449 |
] ifFalse:[ |
6050 | 3450 |
" |
3451 |
at begin of line - merge with previous line; |
|
3452 |
except for the very first line. |
|
3453 |
" |
|
3454 |
(cursorLine == 1) ifFalse:[ |
|
3455 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3456 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3457 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3458 |
"/ we are beyond the end of the text. |
|
3459 |
"/ move the cursor to the previous line. |
|
3460 |
self cursorLine:lineNrAboveCursor col:1. |
|
3461 |
] ifFalse:[ |
|
3462 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3463 |
] |
|
3464 |
] |
|
3465 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3466 |
]. |
827 | 3467 |
wasOn ifTrue:[ self showCursor ] |
3468 |
||
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3469 |
"Modified: / 16-01-1998 / 22:33:04 / cg" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3470 |
"Modified: / 12-01-2017 / 22:38:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3471 |
"Modified (comment): / 13-01-2017 / 22:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
827 | 3472 |
! |
3473 |
||
3474 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3475 |
"delete characters from colNr up to the end in line lineNr" |
|
3476 |
||
3477 |
|line| |
|
3478 |
||
3479 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3480 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3481 |
] |
3482 |
||
3483 |
! |
|
3484 |
||
4458 | 3485 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3486 |
"delete characters from startCol to endCol in line lineNr" |
|
3487 |
||
3488 |
|deleted| |
|
3489 |
||
3490 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3491 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3492 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3493 |
! |
|
3494 |
||
827 | 3495 |
deleteCharsAtLine:lineNr toCol:colNr |
3496 |
"delete characters from start up to colNr in line lineNr" |
|
3497 |
||
3498 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3499 |
||
3500 |
||
121 | 3501 |
! |
3502 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3503 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3504 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3505 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3506 |
self deleteLine:cursorLine |
121 | 3507 |
! |
3508 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3509 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3510 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3511 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3512 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3513 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3514 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3515 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3516 |
col1 == 0 ifTrue:[ |
4823 | 3517 |
line1 := line1 - 1. |
3518 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3519 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3520 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3521 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3522 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3523 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3524 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3525 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3526 |
|
2954 | 3527 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3528 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3529 |
joining lines if nescessary" |
|
3530 |
||
3531 |
|line newLine lineSize nMore| |
|
3532 |
||
3533 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3534 |
list isNil ifTrue:[^ self]. |
|
3535 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3536 |
||
3537 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3538 |
"/ delete chars within a line |
3539 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3540 |
^ self |
|
2954 | 3541 |
]. |
3542 |
||
3543 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3544 |
"/ delete full lines only |
3545 |
endLine > startLine ifTrue:[ |
|
3546 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3547 |
]. |
|
3548 |
^ self |
|
2954 | 3549 |
]. |
3550 |
||
3551 |
"/ delete right rest of 1st line |
|
4786 | 3552 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3553 |
|
3554 |
"/ delete the inner lines ... |
|
3555 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3556 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3557 |
]. |
3558 |
||
3559 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3560 |
"/ delete the left rest of the last line |
3561 |
||
3562 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3563 |
||
3564 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3565 |
startLine <= list size ifTrue:[ |
|
3566 |
line := list at:startLine. |
|
3567 |
lineSize := line size. |
|
3568 |
(startCol > lineSize) ifTrue:[ |
|
3569 |
newLine := line. |
|
3570 |
line isNil ifTrue:[ |
|
3571 |
newLine := String new:(startCol - 1) |
|
3572 |
] ifFalse:[ |
|
3573 |
nMore := startCol - 1 - lineSize. |
|
3574 |
nMore > 0 ifTrue:[ |
|
3575 |
newLine := line , (line species new:nMore) |
|
3576 |
] |
|
3577 |
]. |
|
3578 |
newLine ~~ line ifTrue:[ |
|
4771 | 3579 |
self basicListAt:startLine put:newLine. |
4225 | 3580 |
]. |
3581 |
"/ TODO: remember old maxwidth of linerange, |
|
3582 |
"/ only clear widthOfWidestLine, if this max |
|
3583 |
"/ length was (one of) the longest. |
|
3584 |
"/ avoids slow delete with huge texts. |
|
3585 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3586 |
self textChanged. |
|
3587 |
] |
|
3588 |
] |
|
2954 | 3589 |
]. |
3590 |
||
3591 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3592 |
self mergeLine:startLine removeBlanks:false |
|
3593 |
||
4225 | 3594 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3595 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3596 |
! |
3597 |
||
4458 | 3598 |
deleteFromLine:startLineNr toLine:endLineNr |
3599 |
"delete some lines" |
|
3600 |
||
3601 |
|deleted| |
|
3602 |
||
3603 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3604 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3605 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3606 |
! |
|
3607 |
||
827 | 3608 |
deleteLine:lineNr |
3609 |
"delete line" |
|
3610 |
||
3611 |
self deleteFromLine:lineNr toLine:lineNr |
|
3612 |
||
3613 |
||
3614 |
! |
|
3615 |
||
4458 | 3616 |
deleteLineWithoutRedraw:lineNr |
3617 |
"delete line - no redraw; |
|
3618 |
return true, if something was really deleted" |
|
3619 |
||
3620 |
|deleted ret| |
|
3621 |
||
3622 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3623 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3624 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3625 |
^ ret. |
|
3626 |
! |
|
3627 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3628 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3629 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3630 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3631 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3632 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3633 |
|
4771 | 3634 |
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
|
3635 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3637 |
(endLine > list size) ifTrue:[ |
4771 | 3638 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3639 |
] ifFalse:[ |
4771 | 3640 |
lastLine := endLine |
3641 |
]. |
|
3642 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3643 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3644 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3645 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3646 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3647 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3648 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3649 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3650 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3651 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3652 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3653 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3654 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3655 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3657 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3658 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3659 |
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
|
3660 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3661 |
selectionStartLine notNil ifTrue:[ |
4823 | 3662 |
wasOn := self hideCursor. |
3663 |
||
3664 |
startLine := selectionStartLine. |
|
3665 |
startCol := selectionStartCol. |
|
3666 |
endLine := selectionEndLine. |
|
3667 |
endCol := selectionEndCol. |
|
3668 |
self unselectWithoutRedraw. |
|
3669 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3670 |
self setCursorLine:startLine col:startCol. |
|
3671 |
||
3672 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3673 |
] |
121 | 3674 |
! |
3675 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3676 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3677 |
"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
|
3678 |
|
2952 | 3679 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3680 |
|
3799 | 3681 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3682 |
cursorCol <= 1 ifTrue:[ |
3683 |
self deleteCharBeforeCursor. |
|
3684 |
^ self |
|
3685 |
]. |
|
3799 | 3686 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3687 |
wasOn := self hideCursor. |
3799 | 3688 |
self |
3689 |
undoableDo:[ |
|
3690 |
endCol := cursorCol-1. |
|
3691 |
endLine := cursorLine. |
|
3692 |
self cursorToPreviousWord. |
|
3693 |
beginCol := cursorCol. |
|
3694 |
beginLine := cursorLine. |
|
3695 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3696 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3697 |
] |
3698 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3699 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3700 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3701 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3702 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3703 |
|
5761 | 3704 |
indentSelectionBy1 |
3705 |
"indent selected line-range |
|
3706 |
by 1 space (i.e. to the right)" |
|
3707 |
||
3708 |
self indentBy:1 |
|
3709 |
||
3710 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3711 |
! |
|
3712 |
||
4458 | 3713 |
insert:aCharacter atLine:lineNr col:colNr |
3714 |
"insert a single character at lineNr/colNr; |
|
3715 |
set emphasis to character at current position" |
|
3716 |
||
3717 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3718 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3719 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3720 |
] |
3721 |
! |
|
3722 |
||
121 | 3723 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3724 |
"insert a single character at cursor-position - advance cursor." |
121 | 3725 |
|
3726 |
|wasOn| |
|
3727 |
||
3728 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3729 |
aCharacter == Character tab ifTrue:[ |
4820 | 3730 |
"/ needs special care to advance cursor correctly |
3731 |
self insertTabAtCursor |
|
121 | 3732 |
] ifFalse:[ |
4820 | 3733 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3734 |
aCharacter == (Character cr) ifTrue:[ |
|
3735 |
self basicCursorReturn |
|
3736 |
] ifFalse:[ |
|
3737 |
self cursorRight. |
|
3738 |
]. |
|
121 | 3739 |
]. |
3740 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3741 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3742 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3743 |
! |
3744 |
||
641 | 3745 |
insertLine:aString before:lineNr |
3746 |
"insert the line aString before line lineNr" |
|
3747 |
||
3748 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3749 |
||
3750 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3751 |
! |
|
3752 |
||
155 | 3753 |
insertLines:aStringCollection before:lineNr |
3754 |
"insert a bunch before line lineNr" |
|
3755 |
||
3756 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3757 |
||
3758 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3759 |
! |
|
3760 |
||
4771 | 3761 |
insertLines:someText from:start to:end before:lineNr |
3762 |
"insert a bunch of lines before line lineNr. |
|
3763 |
The cursor position is left unchanged." |
|
3764 |
||
3765 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3766 |
srcY "{ Class: SmallInteger }" |
|
3767 |
dstY "{ Class: SmallInteger }" | |
|
3768 |
||
5357 | 3769 |
"wrong when pasting multiple lines" |
3770 |
false "autoIndent" ifTrue:[ |
|
4771 | 3771 |
indent := self leftIndentForLine:lineNr. |
3772 |
||
4812 | 3773 |
text := someText |
3774 |
collect:[:ln||line| |
|
3775 |
ln notNil ifTrue:[ |
|
3776 |
line := ln withoutLeadingSeparators. |
|
3777 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3778 |
line := (String new:indent), line |
|
3779 |
]. |
|
3780 |
line |
|
3781 |
] ifFalse:[ |
|
3782 |
nil |
|
3783 |
] |
|
3784 |
]. |
|
4771 | 3785 |
] ifFalse:[ |
3786 |
text := someText |
|
3787 |
]. |
|
3788 |
||
3789 |
visLine := self listLineToVisibleLine:lineNr. |
|
3790 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3791 |
self withoutRedrawInsertLines:text |
|
3792 |
from:start to:end |
|
3793 |
before:lineNr. |
|
3794 |
] ifFalse:[ |
|
3795 |
nLines := end - start + 1. |
|
3796 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3797 |
self withoutRedrawInsertLines:text |
|
3798 |
from:start to:end |
|
3799 |
before:lineNr. |
|
3800 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3801 |
] ifFalse:[ |
|
3802 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3803 |
and:(firstLineShown + nLines + nLinesShown). |
|
3804 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3805 |
dstY := srcY + (nLines * fontHeight). |
|
3806 |
||
3807 |
"/ |
|
3808 |
"/ scroll ... |
|
3809 |
"/ |
|
3810 |
" |
|
3811 |
stupid: must catchExpose before inserting new |
|
3812 |
stuff - since catchExpose may perform redraws |
|
3813 |
" |
|
3814 |
self catchExpose. |
|
3815 |
self withoutRedrawInsertLines:text |
|
3816 |
from:start to:end |
|
3817 |
before:lineNr. |
|
3818 |
self |
|
3819 |
copyFrom:self |
|
3820 |
x:textStartLeft y:srcY |
|
3821 |
toX:textStartLeft y:dstY |
|
3822 |
width:w |
|
3823 |
height:(height - dstY) |
|
3824 |
async:true. |
|
3825 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3826 |
self waitForExpose |
|
3827 |
]. |
|
3828 |
]. |
|
3829 |
widthOfWidestLine notNil ifTrue:[ |
|
3830 |
text do:[:line | |
|
3831 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3832 |
] |
|
3833 |
]. |
|
3834 |
self textChanged. |
|
3835 |
||
3836 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3837 |
! |
|
3838 |
||
654 | 3839 |
insertLines:lines withCR:withCr |
3160 | 3840 |
"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
|
3841 |
Cursor is moved behind insertion. |
641 | 3842 |
If withCr is true, append cr after last line" |
3843 |
||
3844 |
|start end nLines wasOn| |
|
3845 |
||
3846 |
lines notNil ifTrue:[ |
|
4649 | 3847 |
nLines := lines size. |
3848 |
(nLines == 1) ifTrue:[ |
|
3849 |
self insertStringAtCursor:(lines at:1). |
|
3850 |
withCr ifTrue:[ |
|
3851 |
self insertCharAtCursor:(Character cr) |
|
3852 |
] |
|
3853 |
] ifFalse:[ |
|
3854 |
(cursorCol ~~ 1) ifTrue:[ |
|
3855 |
self insertStringAtCursor:(lines at:1). |
|
3856 |
self insertCharAtCursor:(Character cr). |
|
3857 |
start := 2 |
|
3858 |
] ifFalse:[ |
|
3859 |
start := 1 |
|
3860 |
]. |
|
3861 |
withCr ifTrue:[ |
|
3862 |
end := nLines |
|
3863 |
] ifFalse:[ |
|
3864 |
end := nLines - 1 |
|
3865 |
]. |
|
3866 |
(start <= nLines) ifTrue:[ |
|
3867 |
(end >= start) ifTrue:[ |
|
3868 |
wasOn := self hideCursor. |
|
3869 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3870 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3871 |
wasOn ifTrue:[self showCursor]. |
|
3872 |
] |
|
3873 |
]. |
|
3874 |
withCr ifFalse:[ |
|
3875 |
"last line without cr" |
|
3876 |
self insertStringAtCursor:(lines at:nLines) |
|
3877 |
] |
|
3878 |
] |
|
641 | 3879 |
] |
654 | 3880 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3881 |
"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
|
3882 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3883 |
! |
3884 |
||
3885 |
insertLines:lines withCr:withCr |
|
3886 |
"insert a bunch of lines at cursor position. Cursor |
|
3887 |
is moved behind insertion. |
|
3888 |
If withCr is true, append cr after last line" |
|
3889 |
||
2363 | 3890 |
<resource:#obsolete> |
3891 |
||
1292 | 3892 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3893 |
self insertLines:lines withCR:withCr. |
|
3894 |
||
3895 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3896 |
! |
3897 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3898 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3899 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3900 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3901 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3902 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3903 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3904 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3905 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3906 |
self selectFromLine:startLine col:startCol |
4823 | 3907 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3908 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3909 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3910 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3911 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3912 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3913 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3914 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3915 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3916 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3917 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3918 |
col == 0 ifTrue:[ |
3919 |
line > 1 ifTrue:[ |
|
3920 |
line := line - 1. |
|
5216 | 3921 |
col := (self listAt:line) size + 1. |
5060 | 3922 |
] ifFalse:[ |
3923 |
col := 1. |
|
3924 |
] |
|
3925 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3926 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3927 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3928 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3929 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3930 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3931 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3932 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3933 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3934 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3935 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3936 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3937 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3938 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3939 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3940 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3941 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3942 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3943 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3944 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3945 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3946 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3947 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
[start <= end] whileTrue:[ |
4823 | 3949 |
stop := aString indexOf:(Character cr) startingAt:start. |
3950 |
stop == 0 ifTrue:[ |
|
3951 |
stop := end + 1 |
|
3952 |
]. |
|
3953 |
subString := aString copyFrom:start to:(stop - 1). |
|
3954 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3955 |
(stop <= end) ifTrue:[ |
|
3956 |
c := c + subString size. |
|
3957 |
self insert:(Character cr) atLine:l col:c. |
|
3958 |
l := l + 1. |
|
3959 |
c := 1 |
|
3960 |
]. |
|
3961 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3962 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3963 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3964 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3965 |
! |
3966 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3967 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3968 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3969 |
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
|
3970 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3971 |
aString isNil ifTrue:[ |
4823 | 3972 |
"new:" |
3973 |
self insertCharAtCursor:(Character cr). |
|
3974 |
^ self |
|
105 | 3975 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3976 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3977 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3978 |
]. |
3979 |
||
654 | 3980 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3981 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3982 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3983 |
! |
3984 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3985 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3986 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3987 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3988 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3989 |
shown ifTrue:[ |
4889 | 3990 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3991 |
self invalidateLine:lineNr. |
3992 |
] ifFalse:[ |
|
3993 |
self redrawLine:lineNr from:colNr |
|
3994 |
] |
|
3995 |
] |
|
3996 |
||
4191 | 3997 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3998 |
! |
3999 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4000 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4001 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4002 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4003 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4004 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4005 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4006 |
aString size > 0 ifTrue:[ |
4823 | 4007 |
wasOn := self hideCursor. |
4008 |
(aString includes:Character tab) ifTrue:[ |
|
4009 |
self checkForExistingLine:cursorLine. |
|
4010 |
oldLen := (list at:cursorLine) size. |
|
4011 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
4012 |
newLen := (list at:cursorLine) size. |
|
4013 |
deltaLen := newLen - oldLen. |
|
4014 |
] ifFalse:[ |
|
4015 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
4016 |
deltaLen := aString size. |
|
4017 |
]. |
|
4018 |
self setCursorCol:(cursorCol + deltaLen). |
|
4019 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4021 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4022 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4023 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4024 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4025 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4026 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4027 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4028 |
|wasOn nextTab| |
105 | 4029 |
|
121 | 4030 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4031 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4032 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4033 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 4034 |
! |
4035 |
||
3542 | 4036 |
joinLines |
3890 | 4037 |
"join lines (remove line-break)" |
4038 |
||
3583 | 4039 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
4040 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
4041 |
self |
3890 | 4042 |
undoableDo:[ |
4043 |
|line col lineLen| |
|
4044 |
||
4045 |
line := cursorLine. |
|
4046 |
col := cursorCol. |
|
4047 |
lineLen := (list at:line) size. |
|
4048 |
col > lineLen ifTrue:[ |
|
4049 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
4050 |
] ifFalse:[ |
|
4051 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
4052 |
]. |
|
4053 |
self mergeLine:line removeBlanks:true. |
|
4054 |
self cursorLine:line col:col. |
|
4055 |
] |
|
4056 |
info:'Join' |
|
3542 | 4057 |
! |
4058 |
||
2952 | 4059 |
mergeLine:lineNr |
4060 |
"merge line lineNr with line lineNr+1" |
|
4061 |
||
4062 |
self mergeLine:lineNr removeBlanks:true |
|
4063 |
||
4064 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
4065 |
! |
|
4066 |
||
4458 | 4067 |
mergeLine:lineNr removeBlanks:removeBlanks |
4068 |
"merge line lineNr with line lineNr+1" |
|
4069 |
||
4070 |
|len| |
|
4071 |
||
4072 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4073 |
||
4074 |
len := (self listAt:lineNr) size. |
|
4075 |
self nonUndoableDo:[ |
|
4823 | 4076 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4077 |
]. |
4078 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4079 |
! |
|
4080 |
||
5761 | 4081 |
parenthizeSelection |
4082 |
"place parenthesis around the selected text. |
|
4083 |
if already parenthized, de-parenthize it" |
|
4084 |
||
4085 |
self parenthizeSelectionWith:$( and:$) |
|
4086 |
||
4087 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
4088 |
! |
|
4089 |
||
2506 | 4090 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4091 |
"if already parenthized, de-parenthize it" |
4092 |
||
5560 | 4093 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4094 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4095 |
self hasSelection ifFalse:[^ self]. |
5560 | 4096 |
startLine := selectionStartLine. |
4097 |
endLine := selectionEndLine. |
|
4098 |
startCol := selectionStartCol. |
|
4099 |
endCol := selectionEndCol. |
|
4100 |
||
4101 |
newSelectionEnd := endCol. |
|
4102 |
||
4103 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
4104 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
4105 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 4106 |
newSelectionEnd := newSelectionEnd-1. |
4107 |
]. |
|
5560 | 4108 |
self deleteCharAtLine:startLine col:startCol. |
4109 |
startLine == endLine ifTrue:[ |
|
4823 | 4110 |
newSelectionEnd := newSelectionEnd-1. |
4111 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4112 |
] ifFalse:[ |
5560 | 4113 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 4114 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 4115 |
self insert:openingCharacter atLine:startLine col:startCol. |
4116 |
startLine == endLine ifTrue:[ |
|
4823 | 4117 |
newSelectionEnd := newSelectionEnd+1. |
4118 |
] |
|
3160 | 4119 |
]. |
4120 |
self |
|
5560 | 4121 |
selectFromLine:startLine col:startCol |
4122 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4123 |
|
4124 |
"Modified (comment): / 06-06-2016 / 11:00:37 / cg" |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4125 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4126 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4127 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4128 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4130 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4131 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4132 |
|
5114 | 4133 |
NoModificationError handle:[:ex | |
4134 |
^ self |
|
4135 |
] do:[ |
|
4136 |
lastLine := list size. |
|
4137 |
finished := false. |
|
4138 |
[finished] whileFalse:[ |
|
4139 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 4140 |
finished := true |
4141 |
] ifFalse:[ |
|
5114 | 4142 |
line := list at:lastLine. |
4143 |
line notNil ifTrue:[ |
|
4144 |
line isBlank ifTrue:[ |
|
4145 |
self basicListAt:lastLine put:nil. |
|
4146 |
line := nil |
|
4147 |
] |
|
4148 |
]. |
|
4149 |
line notNil ifTrue:[ |
|
4150 |
finished := true |
|
4151 |
] ifFalse:[ |
|
4152 |
lastLine := lastLine - 1 |
|
4153 |
] |
|
4771 | 4154 |
] |
5114 | 4155 |
]. |
4156 |
(lastLine ~~ list size) ifTrue:[ |
|
4157 |
list grow:lastLine. |
|
4158 |
"/ self textChanged |
|
4771 | 4159 |
] |
118 | 4160 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4161 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4162 |
|
4458 | 4163 |
replace:aCharacter atLine:lineNr col:colNr |
4164 |
"replace a single character at lineNr/colNr" |
|
4165 |
||
4166 |
|originalChar| |
|
4167 |
||
4168 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4169 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4170 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4171 |
! |
|
4172 |
||
4713 | 4173 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4174 |
|pattern replacePattern| |
4175 |
||
4176 |
pattern := patternArg string. |
|
4177 |
replacePattern := replacePatternArg string. |
|
4630 | 4178 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
4179 |
self rememberSearchPattern:pattern. |
|
4180 |
self rememberSearchPattern:replacePattern. |
|
4713 | 4181 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 4182 |
self |
4183 |
undoableDo:[ |
|
4184 |
all ifTrue:[ |
|
4185 |
self |
|
4186 |
replaceString:pattern |
|
4187 |
to:replacePattern |
|
4713 | 4188 |
ignoreCase:ignoreCase |
4630 | 4189 |
] ifFalse:[ |
4190 |
(self selectionAsString notNil |
|
4713 | 4191 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 4192 |
ifTrue:[ |
4742 | 4193 |
self replaceSelectionBy:replacePattern. |
4630 | 4194 |
self |
4195 |
search:pattern |
|
4713 | 4196 |
ignoreCase:ignoreCase |
4630 | 4197 |
forward:(lastSearchDirection = #forward). |
4198 |
]. |
|
4199 |
] |
|
4200 |
] |
|
4201 |
info:'Replace' |
|
3430 | 4202 |
] |
4203 |
||
4204 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4205 |
! |
|
4206 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4207 |
replaceCharAtCursor:aCharacter |
5413 | 4208 |
"undoably replace a single character at cursor-position - advance cursor" |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4209 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4210 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4211 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4212 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4213 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 4214 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4215 |
] ifFalse:[ |
4823 | 4216 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4217 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4218 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4219 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4220 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4221 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4222 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4223 |
|
4458 | 4224 |
replaceContentsWith:newContents |
5413 | 4225 |
"undoably replace everything" |
4458 | 4226 |
|
4227 |
|originalContents| |
|
4228 |
||
4229 |
originalContents := self contents. |
|
4230 |
self contents:newContents keepUndoHistory:true. |
|
4231 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4232 |
! |
|
4233 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4234 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4235 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4236 |
|
5216 | 4237 |
"/ sigh - insert first, to avoid trouble due to shifing-in virtual line ends |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4238 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4239 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4240 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4241 |
|
4458 | 4242 |
replaceLine:lineNr with:newText |
5413 | 4243 |
"undoably replace a line at lineNr" |
4458 | 4244 |
|
4245 |
|originalLine| |
|
4246 |
||
4247 |
originalLine := self listAt:lineNr. |
|
4248 |
originalLine isNil ifTrue:[ |
|
4823 | 4249 |
self checkForExistingLine:lineNr |
4458 | 4250 |
]. |
4251 |
self list at:lineNr put:newText. |
|
4252 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4253 |
self invalidateLine:lineNr. |
|
4254 |
||
4255 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4256 |
! |
|
4257 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4258 |
replaceLines:lines withCR:withCr |
5413 | 4259 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4260 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4261 |
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
|
4262 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4263 |
|
1809 | 4264 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4265 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4266 |
lines notNil ifTrue:[ |
4661 | 4267 |
wasOn := self hideCursor. |
4268 |
nLines := lines size. |
|
4269 |
line := cursorLine. |
|
4270 |
col := cursorCol. |
|
4271 |
lines keysAndValuesDo:[:i :l | |
|
4272 |
self replaceString:(l ? '') atLine:line col:col. |
|
4273 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4274 |
line := line + 1. |
|
4275 |
col := 1. |
|
4276 |
] ifFalse:[ |
|
4277 |
col := col + (l size). |
|
4278 |
] |
|
4279 |
]. |
|
4280 |
self cursorLine:line col:col. |
|
4281 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4282 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4283 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4284 |
|
4661 | 4285 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4286 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4287 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4288 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4289 |
replaceSelectionBy:something |
5413 | 4290 |
"undoably delete the selection (if any) and insert something, a character or string; |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4291 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4292 |
|
4666 | 4293 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4294 |
! |
4295 |
||
4296 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4297 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4298 |
leave cursor after insertion or leave it, depending on keep" |
4299 |
||
4666 | 4300 |
self replaceSelectionBy:something keepCursor:keep select:false |
4301 |
||
4302 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4303 |
! |
|
4304 |
||
4305 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4306 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4307 |
leave cursor after insertion or leave it, depending on keep. |
4308 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4309 |
||
4310 |
|sel l c selStartLine selStartCol| |
|
105 | 4311 |
|
4312 |
l := cursorLine. |
|
4313 |
c := cursorCol. |
|
4314 |
||
4818 | 4315 |
sel := self selectionAsString. |
4666 | 4316 |
sel isNil ifTrue:[ |
4317 |
selStartLine := l. |
|
4318 |
selStartCol := c. |
|
4319 |
] ifFalse:[ |
|
4320 |
selStartLine := selectionStartLine. |
|
4321 |
selStartCol := selectionStartCol. |
|
4322 |
||
4053 | 4323 |
self setLastStringToReplace: sel. |
4324 |
||
4010 | 4325 |
self deleteSelection. |
4326 |
replacing := true. |
|
4818 | 4327 |
lastReplacementInfo rememberReplacement. |
4048 | 4328 |
lastReplacementInfo lastReplacement: ''. |
4818 | 4329 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 4330 |
undoSupport actionInfo:'replace'. |
3161 | 4331 |
]. |
4332 |
||
4333 |
something isCharacter ifTrue:[ |
|
4051 | 4334 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 4335 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 4336 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 4337 |
]. |
4010 | 4338 |
]. |
4339 |
self isInInsertMode ifTrue:[ |
|
4340 |
self insertCharAtCursor:something |
|
4341 |
] ifFalse:[ |
|
4342 |
self replaceCharAtCursor:something |
|
4343 |
] |
|
105 | 4344 |
] ifFalse:[ |
4010 | 4345 |
something isString ifTrue:[ |
4048 | 4346 |
lastReplacementInfo lastReplacement: something. |
4010 | 4347 |
self isInInsertMode ifTrue:[ |
4348 |
self insertStringAtCursor:something |
|
4349 |
] ifFalse:[ |
|
4350 |
self replaceStringAtCursor:something |
|
4351 |
] |
|
4352 |
] ifFalse:[ |
|
4353 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4354 |
]. |
|
105 | 4355 |
]. |
4356 |
keep ifTrue:[ |
|
4010 | 4357 |
self cursorLine:l col:c |
4666 | 4358 |
]. |
4359 |
selectNewText ifTrue:[ |
|
4360 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 4361 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4362 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4363 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4364 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4365 |
|
4458 | 4366 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4367 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4368 |
This is not prepared to encounter special chars (except TAB) in the string." |
4369 |
||
4370 |
|originalString| |
|
4371 |
||
4372 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4373 |
||
4374 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4375 |
||
4376 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4377 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4378 |
! |
|
4379 |
||
4713 | 4380 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4381 |
|continue count| |
4382 |
||
4383 |
self cursorToTop. |
|
4384 |
self selectFromBeginning. |
|
4385 |
count := 0. |
|
4386 |
continue := true. |
|
4387 |
[ continue ] whileTrue:[ |
|
4713 | 4388 |
(self selectionAsString notNil |
4389 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4390 |
ifTrue:[ |
|
4742 | 4391 |
self replaceSelectionBy:aNewString. |
4713 | 4392 |
count := count + 1. |
4393 |
]. |
|
4394 |
self |
|
4395 |
searchFwd:aString |
|
4396 |
ignoreCase:ignoreCase |
|
4397 |
ifAbsent:[ |
|
4398 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4399 |
bindWith:aString with:aNewString with:count). |
|
4400 |
continue := false. |
|
4401 |
]. |
|
3549 | 4402 |
]. |
3430 | 4403 |
|
4404 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4405 |
! |
|
4406 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4407 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4408 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4409 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4410 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4411 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4412 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4413 |
(aString includes:Character tab) ifTrue:[ |
4823 | 4414 |
"/ need special care for TAB (to move cursor correctly) |
4415 |
i1 := 1. |
|
4416 |
[i1 ~~ 0] whileTrue:[ |
|
4417 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4418 |
i2 ~~ 0 ifTrue:[ |
|
4419 |
i1 ~~ i2 ifTrue:[ |
|
4420 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4421 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4422 |
]. |
|
4423 |
self replaceTABAtCursor. |
|
4424 |
i2 := i2 + 1. |
|
4425 |
] ifFalse:[ |
|
4426 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4427 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4428 |
]. |
|
4429 |
i1 := i2. |
|
4430 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4431 |
] ifFalse:[ |
4823 | 4432 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 4433 |
self setValidatedCursorCol:(cursorCol + aString size). |
4434 |
"/ self cursorCol:(cursorCol + aString size). |
|
4435 |
]. |
|
4436 |
wasOn ifTrue:[ |
|
4437 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
4438 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
4439 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4440 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4441 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4442 |
"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
|
4443 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4444 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4445 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4446 |
"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
|
4447 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4448 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4449 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4450 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4451 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4452 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4453 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4454 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4455 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4456 |
! |
4457 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4458 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4459 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4460 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4461 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4462 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4463 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4464 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4465 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4466 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4467 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4468 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4469 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4470 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4471 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4472 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4473 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4474 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4475 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4476 |
|
4458 | 4477 |
splitLine:lineNr before:colNr |
4478 |
"split the line linNr before colNr; the right part (from colNr) |
|
4479 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4480 |
||
4481 |
self basicSplitLine:lineNr before:colNr. |
|
4482 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4483 |
! |
|
4484 |
||
5761 | 4485 |
toggleTabSetting |
4486 |
"toggle between 4-col |
|
4487 |
and 8-col tabs" |
|
4488 |
||
4489 |
(tabPositions == self class tab4Positions) |
|
4490 |
ifTrue:[self setTab8] |
|
4491 |
ifFalse:[self setTab4] |
|
4492 |
||
4493 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4494 |
! |
|
4495 |
||
4496 |
undentSelectionBy1 |
|
4497 |
"undent selected line-range |
|
4498 |
by 1 space (i.e. to the left)" |
|
4499 |
||
4500 |
self undentBy:1 |
|
4501 |
||
4502 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4503 |
! |
|
4504 |
||
5146 | 4505 |
withAutoIndent:aBoolean do:aBlock |
4506 |
|sav| |
|
4507 |
||
4508 |
sav := autoIndent. |
|
4509 |
autoIndent := aBoolean. |
|
4510 |
aBlock ensure:[ autoIndent := sav ]. |
|
4511 |
! |
|
4512 |
||
4458 | 4513 |
withoutRedrawAt:lineNr put:aString |
4514 |
"replace a line at lineNr" |
|
4515 |
||
4516 |
|originalLine| |
|
4517 |
||
4518 |
originalLine := self listAt:lineNr. |
|
4519 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4520 |
super withoutRedrawAt:lineNr put:aString. |
|
4521 |
! |
|
4522 |
||
4523 |
withoutRedrawInsertLine:aString before:lineNr |
|
4524 |
"insert the argument, aString before line lineNr; the string |
|
4525 |
becomes line lineNr; everything else is moved down; the view |
|
4526 |
is not redrawn" |
|
4527 |
||
4771 | 4528 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4529 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4530 |
! |
|
4531 |
||
4532 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4533 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4534 |
||
4535 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4536 |
self isReadOnly ifFalse:[ |
|
4823 | 4537 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4538 |
]. |
4539 |
! |
|
4540 |
||
4541 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4542 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4543 |
||
4544 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4545 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4546 |
! |
|
4547 |
||
3890 | 4548 |
wrapLines |
4549 |
"wrap lines (insert line-break)" |
|
4550 |
||
4551 |
|lineLength answerString string| |
|
4552 |
||
4553 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4554 |
||
4555 |
self hasSelection ifFalse:[ |
|
4556 |
self selectLine:cursorLine. |
|
4557 |
]. |
|
4558 |
string := self selectionAsString. |
|
4559 |
string isEmptyOrNil ifTrue:[ |
|
4560 |
Dialog information:(resources string:'Nothing selected.'). |
|
4561 |
^ self. |
|
4562 |
]. |
|
4563 |
||
4564 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4565 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4566 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4567 |
lineLength < 1 ifTrue:[ |
4568 |
lineLength := 1. |
|
4569 |
]. |
|
4570 |
||
4571 |
self |
|
4572 |
undoableDo:[ |
|
4573 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4574 |
||
4575 |
line := selectionStartLine. |
|
4576 |
col := selectionStartCol. |
|
4577 |
||
4578 |
self cutSelection. |
|
4579 |
self cursorLine:line col:col. |
|
4580 |
||
4581 |
lastGoodCol := col. |
|
4582 |
||
4583 |
inStream := string readStream. |
|
4584 |
[ inStream atEnd ] whileFalse:[ |
|
4585 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4586 |
word := WriteStream on:(String new:10). |
|
4587 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4588 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4589 |
self insertCharAtCursor:(Character cr). |
|
4590 |
col := 1. |
|
4591 |
] ifFalse:[ |
|
4592 |
col ~~ 1 ifTrue:[ |
|
4593 |
self insertStringAtCursor:' '. |
|
4594 |
col := col + 1. |
|
4595 |
] |
|
4596 |
]. |
|
4597 |
self insertStringAtCursor:word contents. |
|
4598 |
col := col + word size. |
|
4599 |
]. |
|
4600 |
] |
|
4601 |
info:'Wrap' |
|
4388 | 4602 |
|
4603 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4604 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4605 |
|
2752 | 4606 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4607 |
|
2952 | 4608 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4609 |
"delete characters from startCol to endCol in line lineNr" |
4610 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4611 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4612 |
|
4673 | 4613 |
self unselect. |
4614 |
||
4615 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4616 |
cursorCol >= startCol ifTrue:[ |
4617 |
cursorCol >= endCol ifTrue:[ |
|
4618 |
cursorCol := startCol. |
|
4619 |
] ifFalse:[ |
|
4620 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4621 |
"/ self assert:(cursorCol >= 0). |
|
4622 |
cursorCol := cursorCol max:1. |
|
4623 |
] |
|
4624 |
]. |
|
4673 | 4625 |
]. |
4626 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4627 |
line := self listAt:lineNr. |
827 | 4628 |
|
4673 | 4629 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4630 |
||
4631 |
lineSize := line size. |
|
4632 |
||
4633 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4634 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4635 |
||
4636 |
stop >= start ifTrue:[ |
|
5909 | 4637 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4638 |
ifFalse:[ newLine := '' ]. |
|
4639 |
||
4640 |
stop == lineSize ifFalse:[ |
|
4641 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4642 |
newLine := line string species fromString:newLine. |
|
4643 |
]. |
|
4644 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4645 |
]. |
|
4646 |
||
4647 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4648 |
newLine := nil |
|
4649 |
]. |
|
4650 |
||
4651 |
prevWidth := self widthOfLine:lineNr. |
|
4652 |
||
4653 |
self basicListAt:lineNr put:newLine. |
|
4654 |
||
4655 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4656 |
"/ remember old width of this line, |
|
4657 |
"/ only clear widthOfWidestLine, if this lines |
|
4658 |
"/ length was (one of) the longest. |
|
4659 |
"/ avoids slow delete with huge texts. |
|
4660 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4661 |
||
4662 |
"/ scroll left if reqiured |
|
4663 |
viewOrigin x > 0 ifTrue:[ |
|
4664 |
newWidth := self widthOfLine:lineNr. |
|
4665 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4666 |
self scrollHorizontalTo:(newWidth |
|
4667 |
- width |
|
4668 |
+ margin + margin |
|
4669 |
+ (gc font widthOf:' ')) |
|
4670 |
] |
|
4671 |
]. |
|
4672 |
self textChanged. |
|
4673 |
] ifFalse:[ |
|
4674 |
self textChanged "/ textChangedButNoSizeChange |
|
4675 |
]. |
|
4676 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4677 |
self invalidateLine:lineNr. |
|
4678 |
] ifFalse:[ |
|
4679 |
self redrawLine:lineNr from:start. |
|
4680 |
]. |
|
4673 | 4681 |
]. |
827 | 4682 |
|
4191 | 4683 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4684 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4685 |
|
2952 | 4686 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4687 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4688 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4689 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4690 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4691 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4692 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4693 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4694 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4695 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4696 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4697 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4698 |
startLineNr <= list size ifTrue:[ |
4771 | 4699 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4700 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4701 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4702 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4703 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4704 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4705 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4706 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4707 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4708 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4709 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4710 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4711 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4712 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4713 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4714 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4715 |
|
4226 | 4716 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4717 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4718 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4719 |
|
2952 | 4720 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4721 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4722 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4723 |
|
2952 | 4724 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4725 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4726 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4727 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4728 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4729 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4730 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4731 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4732 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4733 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4734 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4735 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4736 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4737 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4738 |
|
2952 | 4739 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4740 |
"insert a single character at lineNr/colNr; |
827 | 4741 |
set emphasis to character at current position" |
4742 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4743 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4744 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4745 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4746 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4747 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4748 |
self splitLine:lineNr before:colNr. |
4749 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4750 |
]. |
827 | 4751 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4752 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4753 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4754 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4755 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4756 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4757 |
self st80EditMode ifFalse:[ |
5909 | 4758 |
(self trimBlankLines |
4759 |
and:[colNr > lineSize |
|
4760 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
4761 |
^ self |
|
4762 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4763 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4764 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4765 |
(lineSize == 0) ifTrue:[ |
5909 | 4766 |
newLine := aCharacter asString species new:colNr. |
4767 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4768 |
] ifFalse: [ |
5909 | 4769 |
(colNr > lineSize) ifTrue: [ |
4770 |
colNr == (lineSize +1) ifTrue:[ |
|
4771 |
attribute := line emphasisAt:lineSize |
|
4772 |
]. |
|
4773 |
newLine := line species new:colNr. |
|
4774 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4775 |
drawCharacterOnly := true |
|
4776 |
] ifFalse: [ |
|
4777 |
attribute := line emphasisAt:colNr. |
|
4778 |
newLine := line species new:(lineSize + 1). |
|
4779 |
||
4780 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4781 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4782 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4783 |
]. |
827 | 4784 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4785 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4786 |
newLine := aCharacter asString species fromString:newLine. |
4787 |
line isText ifTrue:[ |
|
4788 |
newLine := newLine asText |
|
4789 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4790 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4791 |
newLine at:colNr put:aCharacter. |
827 | 4792 |
|
4793 |
attribute notNil ifTrue:[ |
|
5909 | 4794 |
newLine emphasisAt:colNr put:attribute. |
827 | 4795 |
]. |
4796 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4797 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4798 |
newLine := self withTabsExpanded:newLine. |
4799 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4800 |
]. |
827 | 4801 |
|
4771 | 4802 |
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
|
4803 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4804 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4805 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4806 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4807 |
shown ifTrue:[ |
5909 | 4808 |
"/ care for italic text - in this case, we must also |
4809 |
"/ redraw the character before the insertion in order |
|
4810 |
"/ to fix the slanted piece of the character. |
|
4811 |
"/ (but we must clip, to avoid destoying the character before) |
|
4812 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4813 |
colNr > 1 ifTrue:[ |
|
4814 |
cursorVisibleLine notNil ifTrue:[ |
|
6031 | 4815 |
oldClip := self clippingBoundsOrNil. |
5909 | 4816 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
4817 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4818 |
||
4819 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4820 |
self invalidateLine:lineNr. |
|
4821 |
] ifFalse:[ |
|
4822 |
drawCharacterOnly ifTrue:[ |
|
6031 | 4823 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
5909 | 4824 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4825 |
] ifFalse:[ |
|
6031 | 4826 |
self clippingBounds:(x@y extent:((width - x) @ fontHeight)). |
5909 | 4827 |
self redrawLine:lineNr from:colNr-1 |
4828 |
]. |
|
6031 | 4829 |
self clippingBounds:oldClip. |
5909 | 4830 |
]. |
4831 |
]. |
|
4832 |
^ self. |
|
4833 |
]. |
|
4834 |
]. |
|
4835 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4836 |
self invalidateLine:lineNr. |
|
4837 |
] ifFalse:[ |
|
4838 |
drawCharacterOnly ifTrue:[ |
|
4839 |
self redrawLine:lineNr col:colNr |
|
4840 |
] ifFalse:[ |
|
4841 |
self redrawLine:lineNr from:colNr |
|
4842 |
] |
|
4843 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4844 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4845 |
|
4191 | 4846 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4847 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4848 |
|
4771 | 4849 |
basicListAt:lineNr put:newLine |
4850 |
"redefinable for special subclasses (with virtual list)" |
|
4851 |
||
4852 |
list at:lineNr put:newLine. |
|
4853 |
! |
|
4854 |
||
4855 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4856 |
"redefinable for special subclasses (with virtual list)" |
|
4857 |
||
4858 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4859 |
! |
|
4860 |
||
2952 | 4861 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4862 |
"merge line lineNr with line lineNr+1" |
4863 |
||
827 | 4864 |
|leftPart rightPart bothParts nextLineNr i| |
4865 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4866 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4867 |
"/ empty list or beyond end of text |
4868 |
^ self |
|
827 | 4869 |
]. |
4870 |
leftPart := self listAt:lineNr. |
|
4871 |
||
4872 |
leftPart isNil ifTrue:[ |
|
5909 | 4873 |
leftPart := ''. |
4874 |
autoIndent ifTrue:[ |
|
4875 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4876 |
leftPart := String new:i |
|
4877 |
] |
|
4878 |
] |
|
827 | 4879 |
]. |
4880 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4881 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4882 |
||
4883 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4884 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4885 |
rightPart := '' |
|
4886 |
] ifFalse:[ |
|
4887 |
removeBlanks ifTrue:[ |
|
4888 |
rightPart := rightPart withoutLeadingSeparators. |
|
4889 |
] |
|
4890 |
]. |
|
4891 |
||
4892 |
bothParts := leftPart , rightPart. |
|
4893 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4894 |
self basicListAt:lineNr put:bothParts. |
|
4895 |
self redrawLine:lineNr. |
|
4896 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4897 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4898 |
|
1319 | 4899 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4900 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4901 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4902 |
|
2952 | 4903 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4904 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4905 |
|
5045 | 4906 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4907 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4908 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4909 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4910 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4911 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4912 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4913 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4914 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4915 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4916 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4917 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4918 |
|
5909 | 4919 |
(self trimBlankLines |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4920 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4921 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4922 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4923 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4924 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4925 |
(lineSize == 0) ifTrue:[ |
5909 | 4926 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4927 |
] ifFalse: [ |
5045 | 4928 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5909 | 4929 |
newLineSpecies := aCharacter stringSpecies |
4930 |
] ifFalse:[ |
|
4931 |
newLineSpecies := line species |
|
4932 |
]. |
|
4933 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4934 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4935 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4936 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4937 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4938 |
newLine := self withTabsExpanded:newLine. |
4939 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4940 |
]. |
4771 | 4941 |
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
|
4942 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4943 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4944 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4945 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4946 |
shown ifTrue:[ |
5909 | 4947 |
gc font hasOverlappingCharacters ifTrue:[ |
4948 |
self invalidateLine:lineNr. |
|
4949 |
] ifFalse:[ |
|
4950 |
drawCharacterOnly ifTrue:[ |
|
4951 |
self redrawLine:lineNr col:colNr |
|
4952 |
] ifFalse:[ |
|
4953 |
self redrawLine:lineNr from:colNr |
|
4954 |
] |
|
4955 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4956 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4957 |
|
4190 | 4958 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4959 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4960 |
! |
4961 |
||
3235 | 4962 |
basicReplaceString:aString atLine:lineNr col:colNr |
4963 |
"replace multiple characters starting at lineNr/colNr. |
|
4964 |
This is not prepared to encounter special chars (except TAB) |
|
4965 |
in the string." |
|
4966 |
||
5045 | 4967 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4968 |
|
4969 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4970 |
||
4971 |
self checkForExistingLine:lineNr. |
|
4972 |
line := list at:lineNr. |
|
4973 |
lineSize := line size. |
|
4974 |
||
4975 |
endCol := colNr + aString size - 1. |
|
4976 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4977 |
newLine := aString species new:endCol. |
3235 | 4978 |
] ifFalse: [ |
5571 | 4979 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4980 |
newLineSpecies := aString stringSpecies |
4981 |
] ifFalse:[ |
|
4982 |
newLineSpecies := line species |
|
4983 |
]. |
|
4984 |
||
4985 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4986 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4987 |
]. |
4988 |
newLine replaceFrom:colNr with:aString. |
|
4989 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4990 |
newLine := self withTabsExpanded:newLine. |
3235 | 4991 |
]. |
4771 | 4992 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4993 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4994 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4995 |
]. |
4996 |
self textChanged. |
|
4997 |
shown ifTrue:[ |
|
4889 | 4998 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4999 |
self invalidateLine:lineNr. |
5000 |
] ifFalse:[ |
|
5001 |
self redrawLine:lineNr from:colNr |
|
5002 |
] |
|
3235 | 5003 |
] |
5004 |
||
4190 | 5005 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 5006 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 5007 |
! |
5008 |
||
2952 | 5009 |
basicSplitLine:lineNr before:colNr |
5010 |
"split the line linNr before colNr; the right part (from colNr) |
|
5011 |
is cut off and inserted after lineNr; the view is redrawn" |
|
5012 |
||
3160 | 5013 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 5014 |
srcY "{ Class: SmallInteger }" | |
5015 |
||
3027 | 5016 |
list isNil ifTrue:[ ^ self ]. |
5017 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
5018 |
||
5019 |
(colNr == 1) ifTrue:[ |
|
5909 | 5020 |
self nonUndoableDo:[ |
5021 |
self insertLine:nil before:lineNr. |
|
5022 |
]. |
|
5023 |
^ self |
|
3027 | 5024 |
]. |
5025 |
||
5026 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5027 |
line notNil ifTrue:[ |
5909 | 5028 |
lineSize := line size. |
5029 |
(colNr <= lineSize) ifTrue:[ |
|
5030 |
rightRest := line copyFrom:colNr to:lineSize. |
|
5031 |
(colNr > 1) ifTrue:[ |
|
5032 |
leftRest := line copyTo:(colNr - 1) |
|
5033 |
] |
|
5034 |
] ifFalse:[ |
|
5035 |
leftRest := line |
|
5036 |
] |
|
3027 | 5037 |
]. |
5038 |
leftRest notNil ifTrue:[ |
|
5909 | 5039 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 5040 |
]. |
4771 | 5041 |
self basicListAt:lineNr put:leftRest. |
3027 | 5042 |
self nonUndoableDo:[ |
5909 | 5043 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 5044 |
]. |
5045 |
visLine := self listLineToVisibleLine:(lineNr). |
|
5046 |
visLine notNil ifTrue:[ |
|
5909 | 5047 |
w := self widthForScrollBetween:lineNr |
5048 |
and:(firstLineShown + nLinesShown). |
|
5049 |
srcY := topMargin + (visLine * fontHeight). |
|
5050 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
5051 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
5052 |
self catchExpose. |
|
5053 |
self |
|
5054 |
copyFrom:self |
|
5055 |
x:textStartLeft y:srcY |
|
5056 |
toX:textStartLeft y:(srcY + fontHeight) |
|
5057 |
width:w |
|
5058 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
5059 |
async:true. |
|
5060 |
]. |
|
5061 |
self redrawLine:lineNr. |
|
5062 |
self redrawLine:(lineNr + 1). |
|
5063 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 5064 |
]. |
5065 |
widthOfWidestLine := nil. "/ unknown |
|
5066 |
self textChanged. |
|
2952 | 5067 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5068 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 5069 |
! |
5070 |
||
2954 | 5071 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5072 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5073 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5074 |
because the text might have been pasted from an alien view." |
|
2954 | 5075 |
|
5076 |
|newLine newLines nLines| |
|
5077 |
||
5078 |
nLines := end - start + 1. |
|
5079 |
newLines := Array new:(lines size). |
|
5080 |
start to:end do:[:index | |
|
4328 | 5081 |
newLine := lines at:index. |
5082 |
newLine notNil ifTrue:[ |
|
5083 |
newLine isString ifTrue:[ |
|
5084 |
newLine isBlank ifTrue:[ |
|
5085 |
newLine := nil |
|
5086 |
] ifFalse:[ |
|
5087 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5088 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5089 |
] |
|
5090 |
] |
|
5091 |
] |
|
5092 |
]. |
|
5093 |
newLines at:index put:newLine |
|
2954 | 5094 |
]. |
5095 |
list isNil ifTrue: [ |
|
4328 | 5096 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5097 |
] ifFalse: [ |
4328 | 5098 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5099 |
]. |
5100 |
||
5101 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5102 |
overlapping copy - if it didn't, we had to use:" |
5103 |
" |
|
5104 |
index := list size. |
|
5105 |
[index > lineNr] whileTrue: [ |
|
4328 | 5106 |
pIndex := index - 1. |
5107 |
list at:index put:(list at:pIndex). |
|
5108 |
index := pIndex |
|
2954 | 5109 |
]. |
5110 |
" |
|
5111 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5112 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5113 |
self contentsChanged |
|
5114 |
||
4328 | 5115 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5116 |
! |
5117 |
||
5118 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5119 |
"insert aString (which has no crs) at lineNr/colNr. |
5120 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5121 |
because the text might have been pasted from an alien view." |
|
2954 | 5122 |
|
4360 | 5123 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5124 |
|
4623 | 5125 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5126 |
|
5127 |
strLen := aString size. |
|
5128 |
self checkForExistingLine:lineNr. |
|
5129 |
||
5130 |
stringType := aString string species. |
|
5131 |
isText := aString isText. |
|
5132 |
line := list at:lineNr. |
|
5133 |
||
5134 |
line notNil ifTrue:[ |
|
4328 | 5135 |
lineSize := line size. |
5136 |
line isString ifFalse:[ |
|
5137 |
stringType := line species |
|
5138 |
] ifTrue:[ |
|
4360 | 5139 |
lineCharWidth := line bitsPerCharacter. |
5140 |
stringCharWidth := aString bitsPerCharacter. |
|
5141 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 5142 |
stringType := line string species |
4360 | 5143 |
] ifFalse:[ |
5144 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5145 |
stringType := aString string species |
|
5146 |
] |
|
4328 | 5147 |
]. |
5148 |
line isText ifTrue:[ isText := true ] |
|
5149 |
]. |
|
2954 | 5150 |
] ifFalse:[ |
4328 | 5151 |
lineSize := 0 |
2954 | 5152 |
]. |
5153 |
||
5154 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 5155 |
newLine := aString |
2954 | 5156 |
] ifFalse:[ |
4328 | 5157 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5158 |
sz := colNr + strLen - 1 |
|
5159 |
] ifFalse:[ |
|
5160 |
sz := lineSize + strLen |
|
5161 |
]. |
|
5162 |
||
4360 | 5163 |
newLine := stringType new:sz. |
5164 |
isText ifTrue:[ |
|
5165 |
newLine := Text string:newLine |
|
4328 | 5166 |
]. |
5167 |
||
5168 |
(lineSize ~~ 0) ifTrue: [ |
|
5169 |
(colNr > lineSize) ifTrue: [ |
|
5170 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5171 |
] ifFalse: [ |
|
5172 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5173 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5174 |
] |
|
5175 |
]. |
|
5176 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5177 |
]. |
5178 |
||
5179 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 5180 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5181 |
]. |
5182 |
||
4771 | 5183 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5184 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 5185 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5186 |
]. |
5187 |
self textChanged. |
|
5188 |
||
4360 | 5189 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5190 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5191 |
|
2752 | 5192 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5194 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5195 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5196 |
|
5216 | 5197 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5198 |
dragIsActive := false. |
5199 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5200 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5201 |
"/ 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
|
5202 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5203 |
]. |
4609 | 5204 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5205 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5206 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5207 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5208 |
|
4420 | 5209 |
"On X11, be nice and paste PRIMARY when middle click. |
5210 |
Note, that middle button on X11 is translated to button |
|
5211 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 5212 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 5213 |
self undoableDo:[ |
5214 |
self paste: (self getClipboardText:#selection). |
|
5215 |
]. |
|
5216 |
^self. |
|
5217 |
]. |
|
5218 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5219 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5220 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5221 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5222 |
"/ 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
|
5223 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5224 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5225 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5226 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5227 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5228 |
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
|
5229 |
|
4420 | 5230 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5231 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 5232 |
! |
5233 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5234 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5235 |
"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
|
5236 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5237 |
|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
|
5238 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5239 |
(button == 1) ifTrue:[ |
5882 | 5240 |
typeOfSelection := nil. |
5241 |
||
5242 |
dragIsActive ifTrue:[ |
|
5243 |
self unselect |
|
5244 |
]. |
|
5245 |
selectionStartLine isNil ifTrue:[ |
|
5246 |
clickCol notNil ifTrue:[ |
|
5247 |
self cursorMovementAllowed ifTrue:[ |
|
5248 |
newCursorCol := clickCol. |
|
5249 |
||
5250 |
cursorType ~~ #block ifTrue:[ |
|
5251 |
clickPos notNil ifTrue:[ |
|
5252 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
5253 |
"/ (i.e. if its an ibeam). |
|
5254 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
3790 | 5255 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
5882 | 5256 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
5257 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5258 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5259 |
]. |
|
5260 |
]. |
|
5261 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5262 |
"/ a partially visible last line (where the first click used to |
|
5263 |
"/ scroll the text so that the second click was handled on another |
|
5264 |
"/ line. An alternative (possibly better) solution would be to |
|
5265 |
"/ remember the last click position and adjust in the double click |
|
5266 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5267 |
"/ Time will show, if this hack works. |
|
5268 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5269 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5057 | 5270 |
Processor |
5882 | 5271 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
5272 |
after:0.3 seconds. |
|
5273 |
] ifFalse:[ |
|
5274 |
self cursorLine:clickLine col:newCursorCol. |
|
5275 |
]. |
|
5276 |
]. |
|
5277 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5278 |
list notEmptyOrNil ifTrue:[ |
|
5279 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5280 |
(clickLine >= list size) ifTrue:[ |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5281 |
(clickLine > (self list size + 2) |
5882 | 5282 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
5283 |
self selectAll |
|
5284 |
]. |
|
5285 |
]. |
|
5286 |
] |
|
5287 |
] |
|
5288 |
] |
|
5289 |
] |
|
5290 |
] ifFalse:[ |
|
5291 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5292 |
]. |
|
5293 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5294 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5295 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5296 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5297 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5298 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5299 |
|
2580 | 5300 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5301 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5302 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5303 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5304 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5305 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5306 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5307 |
self changeTypeOfSelectionTo:nil. |
2580 | 5308 |
|
5309 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5310 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5311 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5312 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5313 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5314 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5315 |
self validateNewSelection. |
4420 | 5316 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5317 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5318 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5319 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5320 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5321 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5322 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5323 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5324 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5325 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5326 |
"/ Compensate for Claus paste-cursordown-paste feature. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5327 |
"/ Right after paste the cursor is at the beginning of the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5328 |
"/ selection. But if immediately after paste user moves cursor right |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5329 |
"/ (but without shift!!!!!!), she probably wants to move past the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5330 |
"/ pasted text, not into it. This is how every other editor behaves. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5331 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5332 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5333 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5334 |
]. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5335 |
|
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5336 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5337 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5338 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5339 |
self setCursorLine: selectionEndLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5340 |
self setCursorCol: selectionEndCol + 1. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5341 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5342 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5343 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5344 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5345 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5346 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5347 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5348 |
^ self |
2580 | 5349 |
]. |
5350 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5351 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5352 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5353 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5354 |
selectionEndCol := cursorCol - 1. |
4970 | 5355 |
"/ selectionEndCol == 1 ifTrue:[ |
5356 |
"/ selectionEndCol := 0. |
|
5357 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5358 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5359 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5360 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5361 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5362 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5363 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5364 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5365 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5366 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5367 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5368 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5369 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5370 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5371 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5372 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5373 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5374 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5375 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5376 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5377 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5378 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5379 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5380 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5381 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5382 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5383 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5384 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5385 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5386 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5387 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5388 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5389 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5390 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5391 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5392 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5393 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5394 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5395 |
"/ If there's selection, unselect and move cursor |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5396 |
"/ one line below last selection line but at the |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5397 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5398 |
"/ useful when pasting... |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5399 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5400 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5401 |
self setCursorCol: selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5402 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5403 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5404 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5405 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5406 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5407 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5408 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5409 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5410 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5411 |
^ self |
2580 | 5412 |
]. |
5413 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5414 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5415 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5416 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5417 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5418 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5419 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5420 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5421 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5422 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5423 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5424 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5425 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5426 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5427 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5428 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5429 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5430 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5431 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5432 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5433 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5434 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5435 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5436 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5437 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5438 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5439 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5440 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5441 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5442 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5443 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5444 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5445 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5446 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5447 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5448 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5449 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5450 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5451 |
"/ self setCursorCol:selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5452 |
"/ self makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5453 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5454 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5455 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5456 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5457 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5458 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5459 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5460 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5461 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5462 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5463 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5464 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5465 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5466 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5467 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5468 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5469 |
^ self. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5470 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5471 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5472 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5473 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5474 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5475 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5476 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5477 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5478 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5479 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5480 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5481 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5482 |
"/ to the beggining of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5483 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5484 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5485 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5486 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5487 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5488 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5489 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5490 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5491 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5492 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5493 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5494 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5495 |
]. |
2580 | 5496 |
]. |
4420 | 5497 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5498 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 5499 |
! |
5500 |
||
2952 | 5501 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5502 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5503 |
|
4521 | 5504 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 5505 |
#Replace #Undo #Redo #Accept |
3780 | 5506 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 5507 |
#DeleteSpaces #Join |
3780 | 5508 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 5509 |
#SelectWord #ExpandSelectionByWord |
3780 | 5510 |
#SelectToEnd #SelectFromBeginning |
4707 | 5511 |
#SelectLine #ExpandSelectionByLine |
3780 | 5512 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5513 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5514 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5515 |
#GotoLine #BeginOfText #EndOfText |
|
5516 |
#InsertLine #DeleteLine |
|
5517 |
#SelectLineFromBeginning |
|
5518 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5519 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5520 |
#'F*' #'f*')> |
2017 | 5521 |
|
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5522 |
|fKeyMacros shiftPressed ctrlPressed i event immediateCompletion currentUserPrefs rawKey| |
4818 | 5523 |
|
5524 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5525 |
|
4701 | 5526 |
"/ experimental |
4818 | 5527 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5528 |
(immediateCompletion |
4818 | 5529 |
or:[currentUserPrefs codeCompletionOnControlKey |
5530 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5531 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5532 |
self initializeCompletionSupport. |
4609 | 5533 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5534 |
]. |
5394 | 5535 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5536 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5537 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5538 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5539 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5540 |
completionSupport notNil ifTrue:[ |
5394 | 5541 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5542 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5543 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5544 |
|
4818 | 5545 |
key isSymbol ifTrue:[ |
5643 | 5546 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 5547 |
lastReplacementInfo stillCollectingInput:false. |
5548 |
] |
|
5549 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5550 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5551 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5552 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5553 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5554 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5555 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5556 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5557 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5558 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5559 |
]. |
3799 | 5560 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5561 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5562 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5563 |
self learnMode ifTrue:[ |
4482 | 5564 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5565 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5566 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5567 |
|
4238 | 5568 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5569 |
"the macro named key exists" |
|
3780 | 5570 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5571 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5572 |
|
4482 | 5573 |
key isSymbol ifFalse:[ |
5574 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5575 |
self handleNonCommandKey:key. |
|
5576 |
^ self |
|
5577 |
]. |
|
5578 |
||
5579 |
event isNil ifTrue:[ |
|
5580 |
event := WindowGroup lastEventQuerySignal query. |
|
5581 |
]. |
|
5582 |
shiftPressed := event hasShift. |
|
5583 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5584 |
rawKey := event rawKey. |
4482 | 5585 |
|
5133 | 5586 |
key == #InsertUUID ifTrue:[ |
5587 |
self insertUUID. |
|
5588 |
^ self. |
|
5589 |
]. |
|
5590 |
||
4253 | 5591 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5592 |
self deleteWordBeforeCursor. |
|
5593 |
^ self. |
|
5594 |
]. |
|
5595 |
||
5119 | 5596 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5597 |
selectionStartLine notNil ifTrue:[ |
5598 |
((key == #BasicBackspace) |
|
4818 | 5599 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5600 |
ifTrue:[ |
5601 |
self deleteSelection. |
|
5602 |
] ifFalse: [ |
|
5603 |
self copyAndDeleteSelection. |
|
5604 |
]. |
|
4609 | 5605 |
] ifFalse:[ |
5606 |
self makeCursorVisible. |
|
5607 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5608 |
"/ self deleteWordBeforeCursor. |
|
5609 |
"/ ] ifFalse:[ |
|
5610 |
self deleteCharBeforeCursor. |
|
5611 |
"/ ]. |
|
3780 | 5612 |
]. |
4738 | 5613 |
true "immediateCompletion" ifTrue:[ |
5394 | 5614 |
completionSupport notNil ifTrue:[ |
5615 |
completionSupport postKeyPress:key |
|
5616 |
]. |
|
4731 | 5617 |
]. |
3780 | 5618 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5619 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5620 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5621 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5622 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5623 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5624 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5625 |
|
3235 | 5626 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5627 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5628 |
^ self. |
3160 | 5629 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
|
4162 | 5631 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5632 |
CharacterSetView notNil ifTrue:[ |
|
5633 |
self specialCharacters. |
|
5634 |
^ self. |
|
5635 |
] |
|
5636 |
]. |
|
5637 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5638 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5639 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5640 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5641 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5642 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5643 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5644 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5645 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5646 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5647 |
(('[fF][0-9]' match:key) |
5648 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5649 |
shiftPressed ifFalse:[ |
|
4818 | 5650 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5651 |
fKeyMacros notNil ifTrue:[ |
5652 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5653 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5654 |
^ self |
|
5655 |
] |
|
5656 |
] |
|
5657 |
] |
|
5658 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5659 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5660 |
|
2506 | 5661 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5662 |
self parenthizeSelectionWith:$( and:$). |
5663 |
^ self. |
|
2506 | 5664 |
]. |
5665 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5666 |
self parenthizeSelectionWith:$" and:$". |
5667 |
^ self. |
|
2506 | 5668 |
]. |
5669 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5670 |
self parenthizeSelectionWith:$' and:$'. |
5671 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5672 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5673 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5674 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5675 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5676 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5677 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5678 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5679 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5680 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5681 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5682 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5683 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5684 |
|
3542 | 5685 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5686 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5687 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5688 |
self makeCursorVisible. |
|
5689 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5690 |
^ self |
|
5691 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5692 |
(key == #SelectWord) ifTrue:[ |
3780 | 5693 |
self makeCursorVisible. |
5694 |
self selectWordUnderCursor. |
|
5695 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5696 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5697 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5698 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5699 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5700 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5701 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5702 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5703 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5704 |
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
|
5705 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5706 |
(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
|
5707 |
(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
|
5708 |
(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
|
5709 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
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 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5712 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5713 |
shiftPressed ifTrue: [ |
5714 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5715 |
"/ self unselect. |
|
5716 |
"/ self cursorHome. |
|
5717 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5718 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5719 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5720 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5721 |
"/ self selectFromBeginOfLine. |
3780 | 5722 |
] ifFalse: [ |
5723 |
self unselect. |
|
5724 |
ctrlPressed ifTrue:[ |
|
5725 |
self cursorHome. |
|
5726 |
] ifFalse:[ |
|
5727 |
self cursorToBeginOfLine. |
|
5728 |
] |
|
5729 |
]. |
|
5730 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5731 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5732 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5733 |
shiftPressed ifTrue:[ |
5734 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5735 |
"/ self unselect. |
|
5736 |
"/ self cursorToBottom |
|
4257 | 5737 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5738 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5739 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5740 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5741 |
"/ self selectToEndOfLine. |
3780 | 5742 |
] ifFalse:[ |
5743 |
self unselect. |
|
5744 |
ctrlPressed ifTrue:[ |
|
5745 |
self cursorToBottom |
|
5746 |
] ifFalse:[ |
|
5747 |
self cursorToEndOfLine. |
|
5748 |
] |
|
5749 |
]. |
|
5750 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5751 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5752 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5753 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5754 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5755 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5756 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5757 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5758 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5759 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5760 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5761 |
]. |
3310 | 5762 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5763 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5764 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5765 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5766 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5767 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5768 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5769 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5770 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5771 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5772 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5773 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5774 |
|
5119 | 5775 |
(rawKey == #CursorRight |
5776 |
or:[rawKey == #CursorDown |
|
5777 |
or:[rawKey == #CursorLeft |
|
5778 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5779 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5780 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5781 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5782 |
|
5119 | 5783 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5784 |
self unselect. self cursorReturn. |
5785 |
^ self |
|
3257 | 5786 |
]. |
5787 |
||
5788 |
(key == #Return) ifTrue:[ |
|
3780 | 5789 |
shiftPressed ifTrue:[ |
5790 |
self unselect. self cursorReturn. |
|
5791 |
^ self |
|
5792 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5793 |
|
3780 | 5794 |
self isReadOnly ifTrue:[ |
5795 |
self unselect; makeCursorVisible. |
|
5796 |
self cursorReturn |
|
5797 |
] ifFalse:[ |
|
5798 |
self isInInsertMode ifFalse:[ |
|
5529 | 5799 |
self cursorReturn:true. |
3780 | 5800 |
autoIndent == true ifTrue:[ |
5801 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5802 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5803 |
self cursorCol:(i+1 max:1) |
5804 |
] |
|
3780 | 5805 |
] |
5806 |
] ifTrue:[ |
|
4826 | 5807 |
|left right oldIndent| |
4812 | 5808 |
|
3780 | 5809 |
"/ old version just unselected ... |
5810 |
"/ self unselect; makeCursorVisible. |
|
5811 |
||
5812 |
"/ new version deletes ... |
|
5813 |
typeOfSelection == #paste ifTrue:[ |
|
5814 |
self unselect; makeCursorVisible. |
|
5815 |
] ifFalse:[ |
|
5816 |
self copyAndDeleteSelection. |
|
5817 |
]. |
|
4816 | 5818 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5819 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5820 |
self insertCharAtCursor:(Character cr). |
5112 | 5821 |
|
3780 | 5822 |
autoIndent == true ifTrue:[ |
4816 | 5823 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5824 |
"/ nothing to do. |
|
4812 | 5825 |
] ifFalse:[ |
5826 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5827 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5828 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5829 |
left := left withoutSeparators. |
5830 |
right := right withoutSeparators. |
|
5831 |
(left endsWith:'[') ifTrue:[ |
|
5832 |
"/ i := i + 4. |
|
4816 | 5833 |
] ifFalse:[ |
4823 | 5834 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5835 |
i := i - 4. |
5836 |
]. |
|
4812 | 5837 |
]. |
4826 | 5838 |
oldIndent := self leftIndentOfLine:cursorLine. |
5839 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5840 |
self st80EditMode ifTrue:[ |
|
5841 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5842 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5843 |
]. |
|
5844 |
]. |
|
4812 | 5845 |
self cursorCol:(i+1 max:1) |
5846 |
]. |
|
5847 |
] |
|
3780 | 5848 |
]. |
5849 |
]. |
|
5850 |
]. |
|
5851 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5852 |
]. |
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
|
5853 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5854 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5855 |
self unselect. self cursorTab. |
5856 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5857 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5858 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5859 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5860 |
(self hasSelection and:[selectionStartLine ~~ selectionEndLine]) ifTrue:[ |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5861 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5862 |
self indentByTab. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5863 |
] ifFalse:[ |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5864 |
self undentByTab. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5865 |
]. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5866 |
^ self. |
3780 | 5867 |
]. |
5868 |
||
5869 |
self unselect. |
|
5870 |
(key == #Tab) ifTrue:[ |
|
5871 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5872 |
self cursorTab. |
|
5873 |
^ self |
|
5874 |
]. |
|
5875 |
self insertTabAtCursor. |
|
5876 |
^ self |
|
5877 |
]. |
|
5878 |
self cursorBacktab. |
|
5879 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5880 |
]. |
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
|
5881 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5882 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5883 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5884 |
shiftPressed ifTrue:[ |
5885 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5886 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5887 |
self makeCursorVisible. |
|
5888 |
self deleteCharAtCursor. |
|
5889 |
]. |
|
5890 |
^ self |
|
5891 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5892 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5893 |
|
5119 | 5894 |
(rawKey == #Delete |
870 | 5895 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5896 |
selectionStartLine notNil ifTrue:[ |
4130 | 5897 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5898 |
"/ To remove text repetetively, use Cut instead. |
|
5899 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5900 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5901 |
((key == #BasicDelete) |
4818 | 5902 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5903 |
self deleteSelection. |
5904 |
] ifFalse:[ |
|
5905 |
self copyAndDeleteSelection. |
|
5906 |
]. |
|
5907 |
^ self |
|
5908 |
]. |
|
5909 |
self makeCursorVisible. |
|
5910 |
self deleteCharAtCursor. |
|
5911 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5912 |
]. |
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
|
5913 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5914 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5915 |
self unselect. |
5916 |
cursorVisibleLine == 1 ifTrue:[ |
|
5917 |
self cursorHome. |
|
5918 |
] ifFalse:[ |
|
5919 |
self cursorToFirstVisibleLine |
|
5920 |
]. |
|
5921 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5922 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5923 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5924 |
self unselect. |
5925 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5926 |
self cursorToBottom. |
|
5927 |
] ifFalse:[ |
|
5928 |
self cursorToLastVisibleLine |
|
5929 |
]. |
|
5930 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5931 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5932 |
((key == #Escape) |
3257 | 5933 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5934 |
self makeCursorVisible. |
5935 |
self unselect. self selectCursorLineFromBeginning. |
|
5936 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5937 |
]. |
3257 | 5938 |
(key == #SelectLine) ifTrue:[ |
3780 | 5939 |
self makeCursorVisible. |
5940 |
self unselect. self selectCursorLine. |
|
5941 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5942 |
]. |
3257 | 5943 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5944 |
"/ self makeCursorVisible. |
3780 | 5945 |
self selectExpandCursorLine. |
5946 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5947 |
]. |
3257 | 5948 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5949 |
self makeCursorVisible. |
5950 |
self unselect. self deleteCursorLine. |
|
5951 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5952 |
]. |
3257 | 5953 |
(key == #InsertLine) ifTrue:[ |
3780 | 5954 |
self makeCursorVisible. |
5955 |
self unselect. self insertLine:nil before:cursorLine. |
|
5956 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5957 |
]. |
3781 | 5958 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5959 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5960 |
|
3310 | 5961 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5962 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
5963 |
"Modified: / 11-10-2017 / 23:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5964 |
! |
5965 |
||
2952 | 5966 |
executeKeyboardMacro:cmdMacro |
5967 |
Error handle:[:ex | |
|
4823 | 5968 |
self warn:'Error in keyboard macro: ' , ex description. |
5969 |
ex return. |
|
2952 | 5970 |
] do:[ |
4823 | 5971 |
AbortOperationRequest handle:[:ex | |
5972 |
self warn:'Keyboard macro aborted'. |
|
5973 |
ex return. |
|
5974 |
] do:[ |
|
5975 |
Parser |
|
5976 |
evaluate:cmdMacro asString |
|
5977 |
receiver:self |
|
5978 |
notifying:nil |
|
5979 |
compile:false. |
|
5980 |
]. |
|
2952 | 5981 |
]. |
5982 |
! |
|
5983 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5984 |
extendSelectionToX:x y:y setPrimarySelection:aBoolean |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5985 |
| movedVisibleLine movedLine movedCol movedUp | |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5986 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5987 |
movedVisibleLine := self visibleLineOfY:y. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5988 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5989 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5990 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5991 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5992 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5993 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5994 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5995 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5996 |
"find out if we are before or after initial click" |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5997 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5998 |
(movedLine < (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5999 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6000 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6001 |
(movedLine == (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6002 |
(movedCol < (clickStartCol ? movedCol)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6003 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6004 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6005 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6006 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6007 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6008 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6009 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6010 |
"/ Set cursor to selection start |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6011 |
self setCursorLine: selectionStartLine col: selectionStartCol |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6012 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6013 |
"/ Set cursor to selection end |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6014 |
self setCursorLine: selectionEndLine col: selectionEndCol + 1 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6015 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6016 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6017 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6018 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6019 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6020 |
super extendSelectionToX:x y:y setPrimarySelection:aBoolean. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6021 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6022 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 6023 |
! |
6024 |
||
6025 |
handleNonCommandKey:keyArg |
|
4700 | 6026 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 6027 |
|
6028 |
self isReadOnly ifTrue:[ |
|
4988 | 6029 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6030 |
^ self. |
2952 | 6031 |
]. |
6032 |
||
6033 |
key := keyArg. |
|
6034 |
||
6035 |
typeOfSelection == #paste ifTrue:[ |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6036 |
"Pasted selection will NOT be replaced by keystroke (non-standard, St/X feature)" |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6037 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6038 |
"/ After paste, the cursor is at the beginning to support |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6039 |
"/ paste-cursordown-paste. Compensate for this here - we want |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6040 |
"/ to continue editing after the end of the selection. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6041 |
"/ This is |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6042 |
cursorLine := selectionEndLine. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6043 |
cursorCol := selectionEndCol + 1. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6044 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6045 |
"/ Cursor position set, we can unselect. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6046 |
self unselect. |
2952 | 6047 |
]. |
6048 |
||
4700 | 6049 |
selStartLineBefore := selectionStartLine. |
6050 |
selStartColBefore := self selectionStartCol. |
|
6051 |
selEndLineBefore := selectionEndLine. |
|
6052 |
selEndColBefore := self selectionEndCol. |
|
2952 | 6053 |
|
4940 | 6054 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 6055 |
key isCharacter ifTrue:[ |
4940 | 6056 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 6057 |
] ifFalse:[ |
4940 | 6058 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 6059 |
]. |
2952 | 6060 |
]. |
6061 |
||
6062 |
"replace selection by what is typed in - |
|
3235 | 6063 |
if word was selected with a space, keep it. |
4700 | 6064 |
if there was no selection, the key's character is inserted" |
3235 | 6065 |
|
6066 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6067 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 6068 |
]. |
2952 | 6069 |
|
6070 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6071 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 6072 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6073 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6074 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6075 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6076 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6077 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6078 |
] |
3160 | 6079 |
]. |
2952 | 6080 |
selectStyle := nil. |
6081 |
||
3235 | 6082 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 6083 |
selectionStartLine := selStartLineBefore. |
6084 |
selectionStartCol := selStartColBefore. |
|
6085 |
selectionEndLine := selEndLineBefore. |
|
6086 |
selectionEndCol := selEndColBefore. |
|
3235 | 6087 |
]. |
6088 |
||
2952 | 6089 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6090 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6091 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6092 |
"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
|
6093 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6094 |
" |
2952 | 6095 |
" |
4481 | 6096 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 6097 |
" |
4481 | 6098 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6099 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6100 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6101 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6102 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6103 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6104 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6105 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6106 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6107 |
self cursorLine:line col:col. |
4940 | 6108 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6109 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6110 |
"/ 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
|
6111 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6112 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6113 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6114 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6115 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6116 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6117 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6118 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6119 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6120 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6121 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6122 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6123 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6124 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6125 |
] |
2952 | 6126 |
]. |
6127 |
||
6128 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
6129 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
6130 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
6131 |
"/ |
|
6132 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
6133 |
"/ self selection. |
|
6134 |
"/ typeOfSelection := #paste. |
|
3160 | 6135 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6136 |
"/ ]. |
3235 | 6137 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6138 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6139 |
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
|
6140 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6141 |
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
|
6142 |
]. |
3235 | 6143 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6144 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 6145 |
|
6146 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
6147 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 6148 |
! |
6149 |
||
6150 |
keyPress:key x:x y:y |
|
6151 |
"handle keyboard input" |
|
6152 |
||
4771 | 6153 |
|wasOn| |
6154 |
||
6155 |
wasOn := cursorShown. |
|
6156 |
||
5689 | 6157 |
NoModificationError |
6158 |
handle:[:ex | |
|
6159 |
self flashReadOnly. |
|
6160 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6161 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6162 |
]. |
|
6163 |
] |
|
6164 |
do:[ |
|
6165 |
self undoableDo:[ |
|
6166 |
self doKeyPress:key x:x y:y |
|
6167 |
]. |
|
6168 |
]. |
|
6169 |
||
4242 | 6170 |
self repairDamage |
6171 |
||
6172 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6173 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 6174 |
! |
6175 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6176 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6177 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6178 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6179 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6180 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6181 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6182 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6183 |
requestAutoAccept |
5068 | 6184 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6185 |
This forces my value to be accepted into my model. |
|
6186 |
Any widget may suppress the ok/cancel, by returning false." |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6187 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6188 |
acceptEnabled == false ifTrue:[ |
4823 | 6189 |
"/ nope - |
6190 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6191 |
]. |
5404 | 6192 |
"/ cg: only do this if modified. |
6193 |
"/ otherwise, users would have to make sure that the contents is |
|
6194 |
"/ always correct (which they don't). If you change this back, |
|
6195 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6196 |
"/ which has a problem with that behavior. |
|
6197 |
self modified ifTrue:[ |
|
6198 |
self accept. |
|
6199 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6200 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6201 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6202 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6203 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6204 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6205 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6206 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6207 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6208 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6209 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6210 |
cv notNil ifTrue:[ |
4823 | 6211 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6212 |
] |
4967 | 6213 |
! |
6214 |
||
6215 |
unmapped |
|
6216 |
super unmapped. |
|
6217 |
||
6218 |
completionSupport notNil ifTrue:[ |
|
6219 |
completionSupport release. |
|
6220 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6221 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6222 |
|
1807 | 6223 |
!EditTextView methodsFor:'focus handling'! |
6224 |
||
4818 | 6225 |
focusOut |
6226 |
super focusOut. |
|
6227 |
||
6228 |
completionSupport notNil ifTrue:[ |
|
6229 |
completionSupport release. |
|
6230 |
]. |
|
6231 |
! |
|
6232 |
||
1807 | 6233 |
hasKeyboardFocus:aBoolean |
6234 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6235 |
(otherwise, I would not know about this)" |
|
6236 |
||
6237 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6238 |
|
3160 | 6239 |
(cursorShown |
6240 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6241 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6242 |
self drawCursor |
4609 | 6243 |
]. |
6244 |
||
6245 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6246 |
completionSupport notNil ifTrue:[ |
6247 |
"/ this is a hack for Windows: |
|
6248 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6249 |
"/ then an activate is sent to the completion popup. |
|
6250 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6251 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6252 |
"/ before forcing it to be closed... |
|
6253 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6254 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6255 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6256 |
|
4821 | 6257 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6258 |
! |
6259 |
||
6260 |
showFocus:explicit |
|
6261 |
"in addition to however my superclass thinks how a focusView is to be |
|
6262 |
displayed, show the cursor when I got the focus" |
|
6263 |
||
5239 | 6264 |
self hasKeyboardFocus:true. |
1807 | 6265 |
self showCursor. |
6266 |
super showFocus:explicit |
|
6267 |
||
6268 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6269 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6270 |
|
4967 | 6271 |
showNoFocus:explicit |
6272 |
"the view lost the keyboard focus |
|
6273 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
6274 |
- change any display attributes as req'd." |
|
6275 |
||
6276 |
super showNoFocus:explicit. |
|
5149 | 6277 |
|
6278 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6279 |
"/ not when the focus is lost normally (because this also happens when |
|
6280 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6281 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6282 |
explicit ifTrue:[ |
|
6283 |
completionSupport notNil ifTrue:[ |
|
6284 |
completionSupport release. |
|
6285 |
]. |
|
4818 | 6286 |
]. |
6287 |
! |
|
6288 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6289 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6290 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6291 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6292 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6293 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6294 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6295 |
and:[self enabled |
4781 | 6296 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6297 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6298 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6299 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6300 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6301 |
^ false |
1807 | 6302 |
! ! |
6303 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6304 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6305 |
|
4237 | 6306 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6307 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6308 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6309 |
|
4482 | 6310 |
|cmdMacro| |
6311 |
||
6312 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6313 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6314 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6315 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6316 |
^ true |
4238 | 6317 |
|
6318 |
" |
|
4483 | 6319 |
EditTextView open |
4238 | 6320 |
contents:'bla'; |
6321 |
selectAll; |
|
6322 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6323 |
EditTextView open |
4238 | 6324 |
contents:'bla'; |
6325 |
selectAll; |
|
6326 |
executekeyboardMacroNamed:#blabla. |
|
6327 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6328 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6329 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6330 |
! |
6331 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6332 |
indent |
3221 | 6333 |
"indent a line-range - this is done by searching for the |
6334 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6335 |
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
|
6336 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6337 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6339 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6340 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6341 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6342 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6343 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 6344 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6345 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6346 |
self unselect. |
3160 | 6347 |
self |
3786 | 6348 |
undoableDo:[self indentFromLine:start toLine:end] |
6349 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6350 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6351 |
|
4237 | 6352 |
indentBy4 |
5050 | 6353 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6354 |
||
6355 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6356 |
! |
|
6357 |
||
6358 |
indentBy8 |
|
6359 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6360 |
|
6361 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6362 |
! |
|
6363 |
||
5050 | 6364 |
indentBy:n |
6365 |
|line1 line2| |
|
6366 |
||
6367 |
line1 := self selectionStartLine. |
|
6368 |
line2 := self selectionEndLine. |
|
6369 |
line1 isNil ifTrue:[ |
|
5833 | 6370 |
line1 := self cursorLine. |
6371 |
line1 notNil ifTrue:[ |
|
6372 |
line2 := line1 |
|
6373 |
] |
|
5769 | 6374 |
] ifFalse:[ |
5833 | 6375 |
line2 notNil ifTrue:[ |
6376 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
5769 | 6377 |
]. |
6378 |
]. |
|
5050 | 6379 |
line1 notNil ifTrue:[ |
5833 | 6380 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6381 |
] |
6382 |
! |
|
6383 |
||
6384 |
indentByTab |
|
6385 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6386 |
! |
|
6387 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6388 |
indentFromLine:start toLine:end |
3221 | 6389 |
"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
|
6390 |
last non-empty line before start, and change the indent |
4742 | 6391 |
of the selected line-range based on that line's indent." |
6392 |
||
4811 | 6393 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6394 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6395 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6396 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6398 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6399 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6400 |
self indentFromLine:start toLine:end by:delta |
6401 |
! |
|
6402 |
||
6403 |
indentFromLine:start toLine:end by:delta |
|
6404 |
"indent a line-range - this is done by searching for the |
|
6405 |
last non-empty line before start, and change the indent |
|
6406 |
of the selected line-range based on that line's indent." |
|
6407 |
||
6408 |
|d line spaces anyChange| |
|
6409 |
||
6410 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6411 |
(delta > 0) ifTrue:[ |
4742 | 6412 |
spaces := String new:delta |
6413 |
]. |
|
6414 |
||
6415 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6416 |
start to:end do:[:lineNr | |
4742 | 6417 |
line := self listAt:lineNr. |
6418 |
line notNil ifTrue:[ |
|
6419 |
line isBlank ifTrue:[ |
|
4771 | 6420 |
self basicListAt:lineNr put:nil |
4742 | 6421 |
] ifFalse:[ |
6422 |
(delta > 0) ifTrue:[ |
|
6423 |
line := spaces , line. |
|
6424 |
widthOfWidestLine notNil ifTrue:[ |
|
6425 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6426 |
] |
|
6427 |
] ifFalse:[ |
|
6428 |
"check if deletion is ok" |
|
6429 |
d := delta negated + 1. |
|
6430 |
||
6431 |
line size > d ifTrue:[ |
|
6432 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6433 |
line := line copyFrom:d |
|
6434 |
] |
|
6435 |
]. |
|
6436 |
widthOfWidestLine := nil |
|
6437 |
]. |
|
6438 |
self replaceLine:lineNr with:line. |
|
6439 |
anyChange := true. |
|
6440 |
] |
|
6441 |
] |
|
6442 |
]. |
|
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6443 |
"/ Update the selection, if not whole-lines... |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6444 |
(selectionStartLine == start and:[ selectionStartCol ~~ 1]) ifTrue:[ |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6445 |
selectionStartCol := (selectionStartCol + delta) max: 1. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6446 |
]. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6447 |
(selectionEndLine == end and:[ selectionEndCol ~~ 0]) ifTrue:[ |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6448 |
selectionEndCol := (selectionEndCol + delta) max: 1. |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6449 |
]. |
4742 | 6450 |
|
6451 |
anyChange ifTrue:[ self textChanged ]. |
|
6452 |
||
3221 | 6453 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6454 |
|
6215
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6455 |
"Modified: / 05-03-1996 / 14:59:18 / cg" |
c6976b98f3c3
Issue #130: Fixed support for indenting by tab
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6153
diff
changeset
|
6456 |
"Modified: / 11-10-2017 / 23:22:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6457 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6458 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6459 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6460 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6461 |
this is done by searching for the last non-empty line before it |
4823 | 6462 |
and returning its indent. |
6463 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6464 |
|
827 | 6465 |
"SHOULD GO TO ListView" |
6466 |
||
6467 |
|line lnr indent| |
|
6468 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6469 |
lnr := lineNr. |
827 | 6470 |
|
4823 | 6471 |
"/ [lnr ~~ 1] whileTrue:[ |
6472 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 6473 |
lnr := lnr - 1. |
6474 |
line := self listAt:lnr. |
|
6475 |
||
6476 |
line notNil ifTrue:[ |
|
6477 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
6478 |
indent ~~ 0 ifTrue:[ |
|
6479 |
(line endsWith:$[) ifTrue:[ |
|
6480 |
^ indent + 4 - 1 |
|
6481 |
]. |
|
6482 |
^ indent - 1 |
|
6483 |
] |
|
6484 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6485 |
]. |
827 | 6486 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6487 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6488 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 6489 |
! |
6490 |
||
6491 |
undentBy4 |
|
5050 | 6492 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6493 |
||
6494 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6495 |
! |
|
6496 |
||
6497 |
undentBy8 |
|
6498 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6499 |
|
6500 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6501 |
! |
6502 |
||
6503 |
undentBy:n |
|
6504 |
self indentBy:(n negated) |
|
6505 |
! |
|
6506 |
||
6507 |
undentByTab |
|
6508 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6509 |
! ! |
6510 |
||
0 | 6511 |
!EditTextView methodsFor:'initialization'! |
6512 |
||
941 | 6513 |
fetchDeviceResources |
6514 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6515 |
||
6516 |
super fetchDeviceResources. |
|
6517 |
||
5643 | 6518 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6519 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6520 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6521 |
|
6522 |
"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
|
6523 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6524 |
! |
6525 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6526 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6527 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6528 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6529 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6530 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6531 |
! |
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 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6534 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6535 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6536 |
super initStyle. |
4576 | 6537 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6538 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6539 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6540 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6541 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6542 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6543 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6544 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6545 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6546 |
cursorTypeNoFocus := cursorType. |
|
6547 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6548 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6549 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6550 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6551 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6552 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6553 |
cursorType ~~ #block ifTrue:[ |
6554 |
cursorNoFocusFgColor := cursorBgColor |
|
6555 |
] ifFalse:[ |
|
6556 |
cursorNoFocusFgColor := cursorFgColor |
|
6557 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6558 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6559 |
|
2088 | 6560 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6561 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6562 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6563 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6564 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6565 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6567 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6568 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6569 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6570 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6571 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6572 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6573 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6574 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6575 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6576 |
cursorCol := 1. |
5251 | 6577 |
cursorLineHolder := ValueHolder with:1. |
6578 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6579 |
modifiedChannel := ValueHolder with:false. |
6580 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6581 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6582 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6583 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6584 |
tabMeansNextField := false. |
5106 | 6585 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6586 |
autoIndent := false. |
|
5251 | 6587 |
editMode := ValueHolder with:EditMode insertMode. |
6588 |
learnMode := ValueHolder with:false. |
|
2131 | 6589 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6590 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6591 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6592 |
"/ enable drop by default |
2589 | 6593 |
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
|
6594 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6595 |
undoSupport := UndoSupport for:self. |
5251 | 6596 |
codeAspectHolder := ValueHolder with:nil. |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6597 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6598 |
"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
|
6599 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6600 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6601 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6602 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6603 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6604 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6605 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6606 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6607 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6608 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6609 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6610 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6611 |
! |
6612 |
||
6613 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6614 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6615 |
completionSupport release |
4771 | 6616 |
]. |
6617 |
super release |
|
0 | 6618 |
! ! |
6619 |
||
2580 | 6620 |
!EditTextView methodsFor:'macros'! |
6621 |
||
6622 |
executeLearnedKeyboardMacro |
|
4673 | 6623 |
"replay the characters as learned previously" |
6624 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6625 |
(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
|
6626 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6627 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6628 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6629 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6630 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6631 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6632 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6633 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6634 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6635 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6636 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6637 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6638 |
]. |
2580 | 6639 |
] ifFalse:[ |
5153 | 6640 |
self flash:'no macro'. |
2580 | 6641 |
]. |
6642 |
! |
|
6643 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6644 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6645 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6646 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6647 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6648 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6649 |
|
2580 | 6650 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6651 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6652 |
|
2580 | 6653 |
|fg bg| |
6654 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6655 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6656 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6657 |
aBoolean ifTrue:[ |
5795 | 6658 |
learnedMacro := OrderedCollection new. |
6659 |
fg := self whiteColor. |
|
6660 |
bg := self blackColor. |
|
2580 | 6661 |
] ifFalse:[ |
5795 | 6662 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6663 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6664 |
]. |
6665 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6666 |
! |
|
6667 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6668 |
learnModeHolder |
4673 | 6669 |
"a holder returning true, if in learn mode" |
6670 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6671 |
learnMode isNil ifTrue:[ |
5251 | 6672 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6673 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6674 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6675 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6676 |
|
4673 | 6677 |
rememberLearnedMacroAs: nameString |
6678 |
Macros isNil ifTrue:[ |
|
6679 |
Macros := Dictionary new. |
|
6680 |
]. |
|
6681 |
Macros at:nameString put:learnedMacro |
|
6682 |
! |
|
6683 |
||
2580 | 6684 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6685 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6686 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6687 |
self learnMode:(self learnMode not). |
2580 | 6688 |
! ! |
6689 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6690 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6691 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6692 |
babelFishTranslate:fromToModeString |
5962 | 6693 |
"translate the selected text and paste it after the selection. |
6694 |
This is now obsolete, as that web service no longer exists (sigh)" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6695 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6696 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6697 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6698 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6699 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6700 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6701 |
self withWaitCursorDo:[ |
5962 | 6702 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6703 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6704 |
] do:[ |
|
6705 |
translated := SOAP::BabelFishClient new |
|
6706 |
translate:original mode:fromToModeString. |
|
6707 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6708 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6709 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6710 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6711 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6712 |
self unselect. |
3799 | 6713 |
self |
6714 |
undoablePaste:translated |
|
5962 | 6715 |
info:'Translate' |
3495 | 6716 |
|
6717 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6718 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6719 |
|
3517 | 6720 |
compareWithClipboard |
6721 |
"compare the selection against the clipboard contents" |
|
6722 |
||
6723 |
|t1 t2| |
|
6724 |
||
6725 |
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
|
6726 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6727 |
Dialog information:'Clipboard is empty.'. |
6728 |
^ self. |
|
3517 | 6729 |
]. |
6730 |
||
6731 |
self hasSelection ifTrue:[ |
|
4823 | 6732 |
t1 := self selectionAsString. |
3517 | 6733 |
] ifFalse:[ |
4823 | 6734 |
t1 := self contents asString |
3517 | 6735 |
]. |
6736 |
t1 := t1 string. |
|
6737 |
||
6738 |
t1 = t2 ifTrue:[ |
|
4823 | 6739 |
Dialog information:'Strings are equal.'. |
6740 |
^ self. |
|
3517 | 6741 |
]. |
6742 |
DiffTextView |
|
4823 | 6743 |
openOn:t1 label:'Editor' |
6744 |
and:t2 label:'Clipboard' |
|
3517 | 6745 |
! |
6746 |
||
5826 | 6747 |
compareWithFile |
6748 |
"compare the selection or the whole text against the contents of a file" |
|
6749 |
||
6750 |
|fn t1 t2| |
|
6751 |
||
6752 |
fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog. |
|
6753 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
6754 |
||
6755 |
t2 := fn asFilename contentsOfEntireFile. |
|
6756 |
t2 isEmptyOrNil ifTrue:[ |
|
6757 |
Dialog information:'File is empty.'. |
|
6758 |
^ self. |
|
6759 |
]. |
|
6760 |
||
6761 |
self hasSelection ifTrue:[ |
|
6762 |
t1 := self selectionAsString. |
|
6763 |
] ifFalse:[ |
|
6764 |
t1 := self contents asString |
|
6765 |
]. |
|
6766 |
t1 := t1 string. |
|
6767 |
||
6768 |
t1 = t2 ifTrue:[ |
|
6769 |
Dialog information:'Same contents.'. |
|
6770 |
^ self. |
|
6771 |
]. |
|
6772 |
DiffTextView |
|
6773 |
openOn:t1 label:'Editor' |
|
6774 |
and:t2 label:'File' |
|
6775 |
! |
|
6776 |
||
5689 | 6777 |
copySelection |
6778 |
"copy contents into smalltalk copybuffer. |
|
6779 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6780 |
||
6781 |
self hasSelection ifTrue:[ |
|
6782 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6783 |
]. |
|
6784 |
super copySelection. |
|
6785 |
||
6786 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6787 |
! |
|
6788 |
||
121 | 6789 |
cut |
6790 |
"cut selection into copybuffer" |
|
6791 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6792 |
self deleteCopyToClipboard:true |
121 | 6793 |
! |
6794 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6795 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6796 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6797 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6798 |
cursorLine notNil ifTrue:[ |
4823 | 6799 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6800 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6801 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6802 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6803 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6804 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6805 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6806 |
|
4129 | 6807 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6808 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6809 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6810 |
self flashReadOnly. |
3786 | 6811 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6812 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6813 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6814 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6815 |
sel notNil ifTrue:[ |
4129 | 6816 |
self setLastStringToReplace: sel. |
4053 | 6817 |
|
3786 | 6818 |
line := selectionStartLine. |
6819 |
col := selectionStartCol. |
|
6820 |
||
6821 |
toClipboard ifTrue:[ |
|
6822 |
" |
|
6823 |
remember in CopyBuffer |
|
6824 |
" |
|
6825 |
self setClipboardText:sel. "/ lastString. |
|
6826 |
]. |
|
6827 |
||
6828 |
" |
|
6829 |
append to DeleteHistory (if there is one) |
|
6830 |
" |
|
6831 |
history := Smalltalk at:#DeleteHistory. |
|
6832 |
history notNil ifTrue:[ |
|
6833 |
history addAll:(sel asStringCollection). |
|
6834 |
history size > 1000 ifTrue:[ |
|
6835 |
history := history copyFrom:(history size - 1000) |
|
6836 |
]. |
|
6837 |
]. |
|
6838 |
||
6839 |
" |
|
6840 |
now, delete it |
|
6841 |
" |
|
6842 |
self |
|
6843 |
undoableDo:[self deleteSelection] |
|
6844 |
info:'Delete'. |
|
4048 | 6845 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6846 |
] ifFalse:[ |
3786 | 6847 |
" |
6848 |
a cut without selection will search&cut again |
|
6849 |
" |
|
6850 |
self undoableDo:[ |
|
6851 |
self again |
|
6852 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6853 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6854 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6855 |
"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
|
6856 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6857 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6858 |
editMenu |
5977 | 6859 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6860 |
|
3781 | 6861 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6862 |
#Find #GotoLine #SaveAs #Print |
3890 | 6863 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6864 |
#ToggleAutoIndent #ToggleInsertMode |
5826 | 6865 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6866 |
<resource: #programMenu> |
1054 | 6867 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6868 |
|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
|
6869 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6870 |
|
2460 | 6871 |
items := #( |
5826 | 6872 |
('Redo' redo Redo ) |
6873 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6874 |
('-' ) |
|
6875 |
('Search...' search Find ) |
|
6876 |
('Goto Line...' gotoLine GotoLine ) |
|
6877 |
('-' ) |
|
6878 |
('Tools' tools ) |
|
6879 |
('Font...' changeFont ) |
|
6880 |
('Insert Unicode...' insertUnicode ) |
|
6881 |
). |
|
4213 | 6882 |
CharacterSetView notNil ifTrue:[ |
5826 | 6883 |
items := items , |
6884 |
#( |
|
6885 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6886 |
). |
|
4213 | 6887 |
]. |
6888 |
items := items , #( |
|
5826 | 6889 |
('-' ) |
6890 |
('Save As...' save SaveAs ) |
|
6891 |
('Print' doPrint Print ) |
|
6892 |
('=' ) |
|
6893 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6894 |
|
2866 | 6895 |
miscItems := #( |
5826 | 6896 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6897 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6898 |
('-' ) |
|
6899 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
6900 |
('Join Lines' joinLines Join ) |
|
6901 |
('Wrap Lines...' wrapLines Wrap ) |
|
6902 |
('-' ) |
|
6903 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6904 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6905 |
('-' ) |
|
6906 |
('Insert File...' insertFile ) |
|
6907 |
('Insert URL Contents...' insertURL ) |
|
6908 |
('Insert new UUID' insertUUID ) |
|
6909 |
('Insert Date && Time' insertDateAndTime ) |
|
6910 |
('-' ) |
|
6911 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6912 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6913 |
). |
|
4213 | 6914 |
"/ CharacterSetView notNil ifTrue:[ |
6915 |
"/ miscItems := miscItems , |
|
6916 |
"/ #( |
|
5529 | 6917 |
"/ ('-' ) |
4213 | 6918 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6919 |
"/ ('Font...' changeFont ) |
4213 | 6920 |
"/ ). |
5529 | 6921 |
"/ ] ifFalse:[ |
6922 |
"/ miscItems := miscItems , |
|
6923 |
"/ #( |
|
6924 |
"/ ('Font...' changeFont ) |
|
6925 |
"/"/ ('Encoding...' changeEncoding ) |
|
6926 |
"/ ). |
|
6927 |
"/ ]. |
|
2866 | 6928 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6929 |
translateItems := #( |
5826 | 6930 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6931 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6932 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6933 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6934 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6935 |
('-' ) |
|
6936 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6937 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6938 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6939 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6940 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6941 |
). |
|
3221 | 6942 |
|
6943 |
sortItems := #( |
|
5826 | 6944 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6945 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6946 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6947 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6948 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6949 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6950 |
('-' ) |
|
6951 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6952 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6953 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6954 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6955 |
('-' ) |
|
6956 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6957 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6958 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6959 |
|
2762 | 6960 |
toolItems := #( |
5826 | 6961 |
('Indent' indent ) |
6962 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6963 |
('Sort' sort ) |
|
6964 |
('Split...' splitLinesAtCharacterOrString ) |
|
6965 |
('-' ) |
|
6966 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6967 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
6968 |
('Translate' babelFishTranslate ) |
|
6969 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6970 |
('Compare with File...' compareWithFile ) |
|
6971 |
). |
|
2762 | 6972 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6973 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6974 |
toolItems := toolItems , #( |
6975 |
('-' ) |
|
6976 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6977 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6978 |
('Inspect Selected String' inspectSelectedString ) |
|
6979 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6980 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6981 |
|
2460 | 6982 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6983 |
sub receiver:self. |
2460 | 6984 |
|
2919 | 6985 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6986 |
toolSub receiver:self. |
|
6987 |
sub subMenuAt:#tools put:toolSub. |
|
6988 |
||
3495 | 6989 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6990 |
transSub receiver:self. |
|
6991 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6992 |
||
6993 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6994 |
sortSub receiver:self. |
|
6995 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6996 |
|
2866 | 6997 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6998 |
subSub receiver:self. |
|
2952 | 6999 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 7000 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 7001 |
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
|
7002 |
|
2866 | 7003 |
sub subMenuAt:#misc put:subSub. |
7004 |
||
3495 | 7005 |
mainItems := #( |
5826 | 7006 |
('Undo' undo Undo ) |
7007 |
('Again' again Again ) |
|
7008 |
('-' ) |
|
7009 |
('Cut' cut Cut ) |
|
7010 |
('Copy' copySelection Copy ) |
|
7011 |
('Paste' pasteOrReplace Paste ) |
|
7012 |
('-' ) |
|
7013 |
('Accept' accept Accept ) |
|
7014 |
('=' ) |
|
7015 |
('More' others Ctrl ) |
|
7016 |
). |
|
3495 | 7017 |
main := PopUpMenu itemList:mainItems resources:resources. |
7018 |
main subMenuAt:#others put:sub. |
|
7019 |
||
7020 |
sensor := self sensor. |
|
7021 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
7022 |
sensor shiftDown ifTrue:[ |
|
5826 | 7023 |
m := subSub |
7024 |
] ifFalse:[ |
|
7025 |
m := sub |
|
7026 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7027 |
] ifFalse:[ |
5826 | 7028 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7029 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7030 |
|
4742 | 7031 |
"/ the 'Smalltalk at:' code is here to |
7032 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 7033 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 7034 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
7035 |
m disable:#googleSpellingSuggestion |
|
2676 | 7036 |
]. |
4742 | 7037 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 7038 |
m disable:#internalSpellingSuggestion |
4742 | 7039 |
]. |
2676 | 7040 |
|
3811 | 7041 |
HTTPInterface isNil ifTrue:[ |
5826 | 7042 |
m disableAll:#(insertURL) |
3811 | 7043 |
]. |
7044 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7045 |
self isReadOnly ifTrue:[ |
5826 | 7046 |
m disableAll:#(accept undo again multipleAgain redo |
7047 |
paste pasteOrReplace pasteOrReplaceFromHistory |
|
7048 |
cut indent autoIndent: insertMode: |
|
7049 |
insertFile insertFileAsStringLiteral insertURL |
|
7050 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 7051 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
5826 | 7052 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
7053 |
insertUnicode specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7054 |
]. |
2817 | 7055 |
self hasSelectionForCopy ifFalse:[ |
5826 | 7056 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7057 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
7058 |
self hasSelection ifFalse:[ |
5371 | 7059 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5826 | 7060 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 7061 |
] ifTrue:[ |
5826 | 7062 |
(Error handle:[:ex | |
7063 |
ex return:false |
|
7064 |
] do:[ |
|
7065 |
|fn| |
|
7066 |
fn := self selectionAsString. |
|
7067 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
7068 |
]) ifFalse:[ |
|
7069 |
m disableAll:#(openFileBrowserOnIt). |
|
7070 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7071 |
]. |
2569 | 7072 |
self hasUndoAction ifFalse:[ |
5826 | 7073 |
m disable:#undo. |
3115 | 7074 |
] ifTrue:[ |
5826 | 7075 |
what := undoSupport undoActionInfo. |
7076 |
what notNil ifTrue:[ |
|
7077 |
undoIdx := m indexOf:#undo. |
|
7078 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
7079 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
7080 |
]. |
2952 | 7081 |
self hasRedoAction ifFalse:[ |
5826 | 7082 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
7083 |
] ifTrue:[ |
5826 | 7084 |
what := undoSupport redoActionInfo. |
7085 |
what notNil ifTrue:[ |
|
7086 |
redoIdx := sub indexOf:#redo. |
|
7087 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
7088 |
] |
|
2952 | 7089 |
]. |
5216 | 7090 |
self canAccept ifFalse:[ |
5826 | 7091 |
m disable:#accept |
1108 | 7092 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7093 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7094 |
|
4388 | 7095 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7096 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7097 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7098 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7099 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7100 |
|
5643 | 7101 |
history := device getCopyBufferHistory copy. |
3160 | 7102 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7103 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7104 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7105 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7106 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7107 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7108 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7109 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7110 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7111 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7112 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7113 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7114 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7115 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7116 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7117 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7118 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7119 |
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
|
7120 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7121 |
box show. |
3160 | 7122 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7123 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7124 |
"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
|
7125 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7126 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7127 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7128 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7129 |
self sensor shiftDown ifTrue:[ |
3855 | 7130 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7131 |
]. |
2724 | 7132 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7133 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7134 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7135 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7136 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7137 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7138 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7139 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7140 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7141 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7142 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7143 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7144 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7145 |
"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
|
7146 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7147 |
|
2676 | 7148 |
googleSpellingSuggestion |
7149 |
"insert the google-spelling suggestion for the selected text. |
|
7150 |
Requires that the SOAP stuff is loaded and working." |
|
7151 |
||
2677 | 7152 |
|text suggestion| |
2676 | 7153 |
|
7154 |
self withWaitCursorDo:[ |
|
3799 | 7155 |
text := self selection asString string withoutSeparators. |
7156 |
text size == 0 ifTrue:[^ self]. |
|
7157 |
||
4742 | 7158 |
"/ the 'Smalltalk at:' code is here to |
7159 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
7160 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 7161 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
7162 |
^ self. |
|
7163 |
] do:[ |
|
4742 | 7164 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 7165 |
]. |
7166 |
suggestion size == 0 ifTrue:[ |
|
4742 | 7167 |
self information:('No spelling suggestion from Google for: ' , text). |
7168 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 7169 |
^ self. |
7170 |
]. |
|
7171 |
]. |
|
7172 |
self |
|
7173 |
undoablePaste:suggestion |
|
7174 |
info:'Spelling Suggestion'. |
|
3495 | 7175 |
|
7176 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 7177 |
! |
7178 |
||
3595 | 7179 |
insertDateAndTime |
7180 |
"insert the curent date and time string" |
|
7181 |
||
7182 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7183 |
self |
3786 | 7184 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 7185 |
info:'Paste Date and Time' |
3595 | 7186 |
! |
7187 |
||
2676 | 7188 |
insertFile |
3160 | 7189 |
"insert contents of a file |
2676 | 7190 |
- ask user for filename using a fileSelectionBox." |
7191 |
||
3731 | 7192 |
self insertFileAsStringLiteral:false |
7193 |
! |
|
7194 |
||
7195 |
insertFileAsStringLiteral |
|
7196 |
"insert a file's contents as a string literal. |
|
7197 |
Almost the same as the insert file, but single-quotes are doubled, |
|
7198 |
to make it a legal string literal" |
|
7199 |
||
7200 |
self insertFileAsStringLiteral:true |
|
7201 |
! |
|
7202 |
||
7203 |
insertFileAsStringLiteral:asStringLiteral |
|
7204 |
"insert contents of a file; either as-is or as a string literal. |
|
7205 |
- ask user for filename using a fileSelectionBox." |
|
7206 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7207 |
|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
|
7208 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7209 |
((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
|
7210 |
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
|
7211 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7212 |
ifTrue:[ |
3731 | 7213 |
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
|
7214 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7215 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7216 |
[ |
3731 | 7217 |
|why| |
7218 |
||
7219 |
file := Dialog |
|
7220 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7221 |
default:initial |
|
7222 |
ok:(resources string:'Insert') |
|
7223 |
abort:(resources string:'Cancel') |
|
7224 |
pattern:nil |
|
7225 |
fromDirectory:directoryForFileDialog. |
|
7226 |
file isNil ifTrue:[ |
|
7227 |
"cancel" |
|
7228 |
^ self. |
|
7229 |
]. |
|
7230 |
file := file asFilename. |
|
7231 |
directoryForFileDialog := file. |
|
7232 |
||
7233 |
ok := file isReadable and:[file isDirectory not]. |
|
7234 |
ok ifFalse:[ |
|
7235 |
file isReadable ifFalse:[ |
|
7236 |
why := '%1 is unreadable.\\Please try again.' |
|
7237 |
] ifTrue:[ |
|
7238 |
why := '%1 is a directory.\\Please try again.' |
|
7239 |
]. |
|
7240 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7241 |
]. |
|
2909 | 7242 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7243 |
|
5063 | 7244 |
text := file contentsAsString. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7245 |
self |
3786 | 7246 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 7247 |
info:'Paste File' |
3495 | 7248 |
|
7249 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
7250 |
! |
|
7251 |
||
3811 | 7252 |
insertURL |
7253 |
"insert contents of a URL |
|
7254 |
- ask user for URL using a dialog." |
|
7255 |
||
7256 |
self insertURLAsStringLiteral:false |
|
7257 |
! |
|
7258 |
||
7259 |
insertURLAsStringLiteral:asStringLiteral |
|
7260 |
"insert contents of a file; either as-is or as a string literal. |
|
7261 |
- ask user for filename using a fileSelectionBox." |
|
7262 |
||
7263 |
|sel url text response initial| |
|
7264 |
||
7265 |
(sel := self selectionAsString) notEmptyOrNil |
|
7266 |
ifTrue:[ |
|
7267 |
initial := sel. |
|
7268 |
]. |
|
7269 |
||
7270 |
url := Dialog |
|
7271 |
request:(resources string:'Insert Contents of URL:') |
|
7272 |
initialAnswer:initial |
|
7273 |
okLabel:(resources string:'Insert') |
|
7274 |
title:(resources string:'URL'). |
|
7275 |
url isNil ifTrue:[ |
|
7276 |
"cancel" |
|
7277 |
^ self. |
|
7278 |
]. |
|
7279 |
response := HTTPInterface get:url. |
|
7280 |
response isErrorResponse ifTrue:[ |
|
7281 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
7282 |
^ self. |
|
7283 |
]. |
|
7284 |
text := response data asString. |
|
7285 |
||
7286 |
self |
|
7287 |
undoableDo:[ |
|
7288 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7289 |
] |
|
7290 |
info:'Insert Contents of URL' |
|
7291 |
! |
|
7292 |
||
3495 | 7293 |
insertUUID |
7294 |
"insert a new UUID's string" |
|
7295 |
||
7296 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7297 |
self |
3786 | 7298 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 7299 |
info:'Paste New UUID' |
3495 | 7300 |
|
7301 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7302 |
! |
7303 |
||
4940 | 7304 |
insertUnicode |
7305 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7306 |
||
7307 |
|unicodePoint unicodeChar unicodeString| |
|
7308 |
||
5904 | 7309 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7310 |
unicodeString size < 2 ifTrue:[ |
5904 | 7311 |
^ self. |
4940 | 7312 |
]. |
7313 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7314 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7315 |
] ifFalse:[ |
5904 | 7316 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7317 |
]. |
4940 | 7318 |
|
7319 |
unicodeChar := Character value:unicodePoint. |
|
7320 |
self keyPress:unicodeChar x:0 y:0. |
|
7321 |
self keyRelease:unicodeChar x:0 y:0. |
|
7322 |
! |
|
7323 |
||
5331 | 7324 |
inspectSelectedString |
7325 |
"inspect the selected text" |
|
7326 |
||
7327 |
self selectionAsString inspect. |
|
7328 |
! |
|
7329 |
||
4742 | 7330 |
internalSpellingSuggestion |
7331 |
"insert the internal-spelling suggestion for the selected text. |
|
7332 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7333 |
||
7334 |
|text suggestions best| |
|
7335 |
||
7336 |
self withWaitCursorDo:[ |
|
7337 |
text := self selection asString string withoutSeparators. |
|
7338 |
text size == 0 ifTrue:[^ self]. |
|
7339 |
||
7340 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7341 |
suggestions size == 0 ifTrue:[ |
|
7342 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7343 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7344 |
^ self. |
|
7345 |
]. |
|
7346 |
Transcript showCR:suggestions. |
|
7347 |
best := suggestions first. |
|
7348 |
]. |
|
7349 |
self |
|
7350 |
undoablePaste:best |
|
7351 |
info:'Spelling Suggestion'. |
|
7352 |
! |
|
7353 |
||
4884 | 7354 |
openFileBrowserOnFileNamed:fileNameString |
7355 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 7356 |
|
4630 | 7357 |
|fn| |
2762 | 7358 |
|
4884 | 7359 |
fn := fileNameString asFilename. |
2762 | 7360 |
fn exists ifFalse:[ |
4884 | 7361 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 7362 |
fn exists ifFalse:[ |
5082 | 7363 |
^ self warn:(resources |
7364 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
7365 |
with:fn baseName allBold |
|
7366 |
with:fn directory baseName allBold). |
|
4042 | 7367 |
]. |
2762 | 7368 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7369 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7370 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7371 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 7372 |
! |
7373 |
||
4884 | 7374 |
openFileBrowserOnIt |
7375 |
"open a fileBrowser on the selected fileName" |
|
7376 |
||
7377 |
|fileNameString| |
|
7378 |
||
7379 |
fileNameString := self selectionAsString. |
|
7380 |
self openFileBrowserOnFileNamed:fileNameString |
|
7381 |
||
7382 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
7383 |
! |
|
7384 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7385 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7386 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7387 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7388 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7389 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7390 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7391 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7392 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7393 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7394 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7395 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7396 |
paste |
6133
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7397 |
"paste the copybuffer; if there is a selection, unselect first. |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7398 |
Then paste at cursor position." |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7399 |
|
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7400 |
self checkModificationsAllowed ifTrue:[ |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7401 |
self withSelfAndTextForPasteDo:[:me :text | |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7402 |
me unselect. |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7403 |
me undoablePaste:text |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7404 |
] |
da4954e52fd3
Backed out changeset f0f9120765af
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6132
diff
changeset
|
7405 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7406 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7407 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7408 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7409 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7410 |
|
3825 | 7411 |
self paste:someText withCR:false |
7412 |
! |
|
7413 |
||
7414 |
paste:someText withCR:withCR |
|
7415 |
"paste someText at cursor" |
|
7416 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7417 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7418 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7419 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7420 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7421 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7422 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7423 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7424 |
CharacterEncoderError handle:[:ex | |
3825 | 7425 |
|code msg| |
7426 |
||
7427 |
code := ex parameter. |
|
7428 |
codingErrorReported ifFalse:[ |
|
4940 | 7429 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 7430 |
code notNil ifTrue:[ |
7431 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7432 |
]. |
|
7433 |
Dialog warn:(resources stringWithCRs:msg). |
|
7434 |
codingErrorReported := true. |
|
7435 |
]. |
|
7436 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7437 |
] do:[ |
3825 | 7438 |
s isString ifTrue:[ |
4940 | 7439 |
s encoding ~~ gc characterEncoding ifTrue:[ |
7440 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 7441 |
]. |
7442 |
||
7443 |
s := s asStringCollection. |
|
7444 |
(someText endsWith:Character cr) ifTrue:[ |
|
7445 |
"/ s := s copyWith:nil. |
|
7446 |
s := s copyWith:'' "/ an empty line at the end |
|
7447 |
||
7448 |
] |
|
7449 |
] ifFalse:[ |
|
7450 |
s isStringCollection ifTrue:[ |
|
4940 | 7451 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 7452 |
] ifFalse:[ |
7453 |
(self |
|
7454 |
confirm:(resources |
|
7455 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7456 |
with:s class name)) ifFalse:[^ self]. |
|
7457 |
s := StringCollection with:s storeString . |
|
7458 |
"/ ^ self |
|
7459 |
]. |
|
7460 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7461 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7462 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7463 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7464 |
(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
|
7465 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7466 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7467 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7468 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7469 |
startCol := c1 := cursorCol. |
3180 | 7470 |
|
5194 | 7471 |
"do not autoindent here. |
7472 |
It does make things very ugly, in the inspector |
|
7473 |
(try inspecting a multiline string)..." |
|
7474 |
self withAutoIndent:false do:[ |
|
7475 |
"do not expand tabs into spaces here - |
|
7476 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7477 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7478 |
||
7479 |
self insertLines:s withCR:withCR. |
|
7480 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7481 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7482 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7483 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7484 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7485 |
"/ For Claus to support paste-cursordown-paste :-) |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7486 |
"/ Move cursor the the beggining of the selection so subsequent |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7487 |
"/ cursor move will start there. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7488 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7489 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7490 |
|
4328 | 7491 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7492 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7493 |
"Modified: / 30-08-2013 / 00:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7494 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7495 |
|
3731 | 7496 |
pasteAsStringLiteral |
7497 |
"insert clipboard string as a string literal. |
|
7498 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7499 |
to make it a legal string literal" |
|
7500 |
||
7501 |
typeOfSelection := nil. |
|
7502 |
self |
|
5107 | 7503 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 7504 |
info:'Paste as String Literal' |
3731 | 7505 |
! |
7506 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7507 |
pasteOrReplace |
1289 | 7508 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7509 |
otherwise paste at cursor position. |
7510 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7511 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7512 |
|
2724 | 7513 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7514 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7515 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7516 |
pasteOrReplace:someText |
1289 | 7517 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7518 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7519 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7520 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7521 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7522 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7523 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7524 |
self undoableDo:[ |
4823 | 7525 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7526 |
self replace:someText |
|
7527 |
] ifFalse:[ |
|
7528 |
self paste:someText. |
|
7529 |
] |
|
3542 | 7530 |
] info:'Paste/Replace'. |
1289 | 7531 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7532 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7533 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7534 |
|
5387 | 7535 |
pasteOrReplaceByKeyPress |
7536 |
"paste a previous item from the copybuffer history. |
|
7537 |
(i.e. repaste some previously deleted or copied text)" |
|
7538 |
||
7539 |
|text| |
|
7540 |
||
7541 |
self checkModificationsAllowed ifFalse:[ |
|
7542 |
self flashReadOnly. |
|
7543 |
^ self |
|
7544 |
]. |
|
7545 |
text := self getClipboardText:#clipboard. |
|
7546 |
text notNil ifTrue:[ |
|
7547 |
self pasteOrReplace:text |
|
7548 |
] |
|
7549 |
! |
|
7550 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7551 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7552 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7553 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7554 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7555 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7556 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7557 |
self checkModificationsAllowed ifFalse:[ |
4988 | 7558 |
self flashReadOnly. |
4823 | 7559 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7560 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7561 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7562 |
text notNil ifTrue:[ |
4823 | 7563 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7564 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7565 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7566 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7567 |
replace |
1289 | 7568 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7569 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7570 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7571 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7572 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7573 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7574 |
me undoableDo:[ me replace:text ] |
7575 |
info:'Replace' |
|
2952 | 7576 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7577 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7578 |
|
121 | 7579 |
replace:someText |
1289 | 7580 |
"replace the selection by someText" |
121 | 7581 |
|
3160 | 7582 |
|selected selectedString |
7583 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7584 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7585 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7586 |
|
3130 | 7587 |
self undoableDo:[ |
4010 | 7588 |
selected := self selection. |
7589 |
selected isNil ifTrue:[ |
|
7590 |
^ self paste:someText |
|
7591 |
]. |
|
7592 |
||
7593 |
self deleteSelection. |
|
7594 |
||
7595 |
"take care, if we replace a selection without space by a word selected |
|
7596 |
with one - in this case we usually do not want the space. |
|
7597 |
But, if we replace a word-selected selection by something without a |
|
7598 |
space, we DO want the space added." |
|
7599 |
||
7600 |
selected size == 1 ifTrue:[ |
|
7601 |
selectedString := selected at:1. |
|
7602 |
]. |
|
7603 |
||
7604 |
someText size == 1 ifTrue:[ |
|
7605 |
|cutOffSpace addSpace replacement replacementString| |
|
7606 |
||
7607 |
cutOffSpace := false. |
|
7608 |
addSpace := false. |
|
7609 |
replacement := someText copyFrom:1. |
|
7610 |
||
7611 |
selectedString notNil ifTrue:[ |
|
7612 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7613 |
"selection has no space" |
|
7614 |
||
7615 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7616 |
cutOffSpace := true |
|
7617 |
] |
|
7618 |
] ifTrue:[ |
|
7619 |
addSpace := true |
|
7620 |
] |
|
7621 |
]. |
|
7622 |
replacementString := replacement at:1. |
|
7623 |
cutOffSpace ifTrue:[ |
|
7624 |
(replacementString startsWith:' ') ifTrue:[ |
|
7625 |
replacementString := replacementString withoutSpaces |
|
7626 |
]. |
|
7627 |
] ifFalse:[ |
|
7628 |
selectStyle == #wordLeft ifTrue:[ |
|
7629 |
"want a space at left" |
|
7630 |
(replacementString startsWith:' ') ifFalse:[ |
|
7631 |
replacementString := replacementString withoutSpaces. |
|
7632 |
replacementString := ' ' , replacementString |
|
7633 |
] |
|
7634 |
]. |
|
7635 |
selectStyle == #wordRight ifTrue:[ |
|
7636 |
"want a space at right" |
|
7637 |
||
7638 |
(replacementString endsWith:' ') ifFalse:[ |
|
7639 |
replacementString := replacementString withoutSpaces. |
|
7640 |
replacementString := replacementString , ' ' |
|
7641 |
] |
|
7642 |
]. |
|
7643 |
]. |
|
7644 |
replacement at:1 put: replacementString. |
|
7645 |
self paste:replacement. |
|
7646 |
] ifFalse:[ |
|
7647 |
self paste:someText |
|
7648 |
]. |
|
4053 | 7649 |
self setLastStringToReplace: selectedString. |
7650 |
||
4048 | 7651 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7652 |
|
7653 |
selStartLine := selectionStartLine. |
|
7654 |
selStartCol := self selectionStartCol. |
|
7655 |
selEndLine := selectionEndLine. |
|
7656 |
selEndCol := self selectionEndCol. |
|
3130 | 7657 |
] |
3542 | 7658 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7659 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7660 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7661 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7662 |
! |
7663 |
||
3430 | 7664 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7665 |
"search for a string - show a box to enter searchpattern |
3430 | 7666 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7667 |
- 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
|
7668 |
|
3430 | 7669 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7670 |
||
7671 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7672 |
lastSearchDirection := #forward. |
|
7673 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7674 |
caseHolder := ValueHolder with:ign. |
7675 |
patternHolder := ValueHolder with:''. |
|
7676 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7677 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7678 |
initialString := lastSearchPattern |
3430 | 7679 |
]. |
7680 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7681 |
initialString := self selectionAsString |
3430 | 7682 |
]. |
7683 |
initialString isNil ifTrue:[ |
|
4823 | 7684 |
LastSearchPatterns size > 0 ifTrue:[ |
7685 |
initialString := LastSearchPatterns first |
|
7686 |
] |
|
3430 | 7687 |
]. |
7688 |
initialString notNil ifTrue:[ |
|
4823 | 7689 |
patternHolder value:initialString. |
7690 |
replacePatternHolder value:initialString. |
|
3430 | 7691 |
]. |
7692 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7693 |
search := [:fwd | |
4823 | 7694 |
self |
7695 |
search:patternHolder value |
|
7696 |
ignoreCase:caseHolder value |
|
7697 |
forward:fwd. |
|
7698 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7699 |
replace := [:all | |
4823 | 7700 |
self |
7701 |
replace:patternHolder value |
|
7702 |
by:replacePatternHolder value |
|
7703 |
all:all |
|
7704 |
ignoreCase:caseHolder value |
|
7705 |
]. |
|
3430 | 7706 |
bindings := IdentityDictionary new. |
7707 |
bindings at:#searchPattern put:patternHolder. |
|
7708 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7709 |
modal ifTrue:[ |
|
4823 | 7710 |
bindings at:#nextAction |
7711 |
put:[ |
|
7712 |
flag := true. |
|
7713 |
action := search. |
|
7714 |
searchBox doAccept. |
|
7715 |
]. |
|
7716 |
bindings at:#prevAction |
|
7717 |
put:[ |
|
7718 |
flag := false. |
|
7719 |
action := search. |
|
7720 |
searchBox doAccept. |
|
7721 |
]. |
|
7722 |
bindings at:#replaceAction |
|
7723 |
put:[ |
|
7724 |
flag := false. |
|
7725 |
action := replace. |
|
7726 |
searchBox doAccept. |
|
7727 |
]. |
|
7728 |
bindings at:#replaceAllAction |
|
7729 |
put:[ |
|
7730 |
flag := true. |
|
7731 |
action := replace. |
|
7732 |
searchBox doAccept. |
|
7733 |
]. |
|
3430 | 7734 |
] ifFalse:[ |
4823 | 7735 |
bindings at:#nextAction put:[ search value:true. ]. |
7736 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7737 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7738 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7739 |
]. |
7740 |
bindings at:#ignoreCase put:caseHolder. |
|
7741 |
bindings at:#patternList put:LastSearchPatterns. |
|
7742 |
modal ifTrue:[ |
|
4823 | 7743 |
searchBox := SimpleDialog new. |
3430 | 7744 |
] ifFalse:[ |
4823 | 7745 |
searchBox := ApplicationModel new. |
7746 |
searchBox createBuilder. |
|
3430 | 7747 |
]. |
7748 |
searchBox resources:(self resources). |
|
7749 |
bldr := searchBox builder. |
|
7750 |
bldr addBindings:bindings. |
|
7751 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7752 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7753 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7754 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7755 |
modal ifTrue:[ |
|
4823 | 7756 |
searchBox openDialog. |
7757 |
searchBox accepted ifTrue:[ |
|
7758 |
action value:flag |
|
7759 |
]. |
|
3430 | 7760 |
] ifFalse:[ |
4823 | 7761 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7762 |
(bldr componentAt:#cancelButton) |
|
7763 |
label:(resources string:'Close'); |
|
7764 |
action:[ searchBox closeRequest ]. |
|
7765 |
||
7766 |
"/ searchBox masterApplication:self application. |
|
7767 |
||
7768 |
self topView beMaster. |
|
7769 |
(searchBox window) |
|
7770 |
beSlave; |
|
7771 |
openInGroup:(self windowGroup). |
|
7772 |
||
7773 |
"/ searchBox window open. |
|
7774 |
||
5283 | 7775 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7776 |
] |
7777 |
||
7778 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7779 |
! |
|
7780 |
||
121 | 7781 |
showDeleted |
7782 |
"open a readonly editor on all deleted text" |
|
7783 |
||
7784 |
|v| |
|
7785 |
||
7786 |
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
|
7787 |
v readOnly:true. |
121 | 7788 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7789 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7790 |
|
3221 | 7791 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7792 |
"sort/reorder the selected lines. |
7793 |
how: |
|
7794 |
#lines |
|
7795 |
#linesByFirstWord |
|
7796 |
#linesByNthWord |
|
7797 |
#linesByNthNumber |
|
7798 |
#linesByNthHexNumber |
|
7799 |
#words |
|
7800 |
#linesByLength |
|
7801 |
#reverse |
|
7802 |
" |
|
7803 |
||
7804 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7805 |
|
7806 |
lineWise := true. |
|
7807 |
||
4763 | 7808 |
how == #reverse ifTrue:[ |
7809 |
operation := [:lines | lines reverse]. |
|
7810 |
] ifFalse:[ |
|
7811 |
operation := [:linesOrWords | |
|
7812 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7813 |
]. |
|
7814 |
||
7815 |
how == #linesByLength ifTrue:[ |
|
7816 |
fetcher := [:l | l size]. |
|
7817 |
] ifFalse:[ |
|
7818 |
how == #lines ifTrue:[ |
|
7819 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7820 |
] ifFalse:[ |
|
7821 |
how == #linesByFirstWord ifTrue:[ |
|
7822 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7823 |
] ifFalse:[ |
|
7824 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7825 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7826 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7827 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7828 |
LastColumnNumberForSort := n. |
|
7829 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7830 |
how == #linesByNthNumber ifTrue:[ |
|
7831 |
innerExtractor := extractor. |
|
7832 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7833 |
] ifFalse:[ |
|
7834 |
how == #linesByNthHexNumber ifTrue:[ |
|
7835 |
innerExtractor := extractor. |
|
7836 |
extractor := [:l | |
|
7837 |
|s| |
|
7838 |
s := innerExtractor value:l. |
|
7839 |
(s startsWith:'16r') ifTrue:[ |
|
7840 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7841 |
] ifFalse:[ |
|
7842 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7843 |
] |
|
7844 |
] |
|
4753 | 7845 |
] |
4763 | 7846 |
]. |
7847 |
] ifFalse:[ |
|
7848 |
how == #words ifTrue:[ |
|
7849 |
lineWise := false. |
|
7850 |
extractor := [:w | w]. |
|
7851 |
] ifFalse:[ |
|
7852 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7853 |
] |
4373 | 7854 |
] |
7855 |
] |
|
4763 | 7856 |
]. |
7857 |
ignoreCase ifTrue:[ |
|
7858 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7859 |
] ifFalse:[ |
|
7860 |
fetcher := extractor. |
|
7861 |
]. |
|
7862 |
]. |
|
3221 | 7863 |
]. |
7864 |
||
7865 |
lineWise ifTrue:[ |
|
4763 | 7866 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7867 |
start == end ifTrue:[^ self ]. |
7868 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7869 |
lines := operation value:lines. |
4373 | 7870 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7871 |
] ifFalse:[ |
7872 |
"process the whole selection as a string" |
|
7873 |
s := self selectionAsString. |
|
7874 |
words := s asCollectionOfWords. |
|
7875 |
words := operation value:words. |
|
7876 |
s := words asStringCollection asStringWith:Character space. |
|
7877 |
self replace:s. |
|
7878 |
]. |
|
3221 | 7879 |
self textChanged. |
4373 | 7880 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7881 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7882 |
! |
7883 |
||
7884 |
sortSelection:how ignoreCase:ignoreCase |
|
7885 |
"sort the selected lines" |
|
7886 |
||
7887 |
|start end| |
|
7888 |
||
7889 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7890 |
||
7891 |
start := selectionStartLine. |
|
7892 |
end := selectionEndLine. |
|
7893 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7894 |
end := end - 1 |
3221 | 7895 |
]. |
7896 |
||
7897 |
self |
|
4373 | 7898 |
undoableDo:[ |
7899 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7900 |
] |
|
3786 | 7901 |
info:'Sort' |
4373 | 7902 |
|
7903 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7904 |
! |
7905 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7906 |
specialCharacters |
2915 | 7907 |
CharacterSetView |
4823 | 7908 |
openAsInputFor:self |
7909 |
label:'Special Character Input' |
|
7910 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7911 |
! |
7912 |
||
5370 | 7913 |
splitLinesAtCharacterOrString |
7914 |
"ask user for the character and split after it" |
|
7915 |
||
7916 |
|sel in out separator record| |
|
7917 |
||
7918 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7919 |
||
7920 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7921 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7922 |
||
7923 |
sel := self selectionAsString. |
|
7924 |
in := sel readStream. |
|
5887 | 7925 |
out := CharacterWriteStream on:''. |
5370 | 7926 |
[in atEnd] whileFalse:[ |
5887 | 7927 |
record := in throughAll:separator. |
7928 |
out nextPutLine:record. |
|
5370 | 7929 |
]. |
7930 |
self |
|
7931 |
undoableDo:[ |
|
5887 | 7932 |
self replaceSelectionBy:(out contents). |
7933 |
] |
|
7934 |
info:'Split Selection' |
|
5370 | 7935 |
! |
7936 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7937 |
undoablePaste:someText |
3495 | 7938 |
self undoablePaste:someText info:nil. |
7939 |
||
7940 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7941 |
! |
|
7942 |
||
7943 |
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
|
7944 |
self |
4823 | 7945 |
undoableDo:[ |
7946 |
self paste:someText. |
|
7947 |
] |
|
7948 |
info:infoOrNil |
|
3495 | 7949 |
|
7950 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7951 |
! |
|
7952 |
||
7953 |
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
|
7954 |
self |
4823 | 7955 |
undoableDo:[ |
7956 |
self pasteOrReplace:someText. |
|
7957 |
] |
|
7958 |
info:infoOrNil |
|
3495 | 7959 |
|
7960 |
"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
|
7961 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7962 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7963 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7964 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7965 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7966 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7967 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7968 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7969 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7970 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7971 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7972 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7973 |
|
2724 | 7974 |
withSelfAndTextForPasteDo:aBlock |
7975 |
"common code for paste/replace of the copybuffer" |
|
7976 |
||
7977 |
|sel| |
|
7978 |
||
7979 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7980 |
self flashReadOnly. |
4823 | 7981 |
^ self |
2724 | 7982 |
]. |
7983 |
||
7984 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7985 |
sel notNil ifTrue:[ |
|
4823 | 7986 |
aBlock value:self value:sel. |
2724 | 7987 |
] |
105 | 7988 |
! ! |
7989 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7990 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7991 |
|
3880 | 7992 |
beep |
5244 | 7993 |
"output an audible beep or bell on my screen device" |
7994 |
||
3880 | 7995 |
UserPreferences current beepInEditor ifTrue:[ |
7996 |
super beep |
|
7997 |
] |
|
7998 |
! |
|
7999 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8000 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8001 |
"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
|
8002 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8003 |
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
|
8004 |
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
|
8005 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8006 |
self isReadOnly ifTrue: [ |
4823 | 8007 |
exceptionBlock isNil ifTrue:[ |
8008 |
^ false |
|
8009 |
]. |
|
8010 |
||
8011 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
8012 |
^ false |
|
8013 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8014 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8015 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8016 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8017 |
"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
|
8018 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8019 |
|
2596 | 8020 |
currentSelectionBgColor |
8021 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 8022 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 8023 |
]. |
5216 | 8024 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 8025 |
^ super currentSelectionBgColor |
8026 |
||
8027 |
" |
|
8028 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
8029 |
" |
|
8030 |
! |
|
8031 |
||
8032 |
currentSelectionFgColor |
|
8033 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 8034 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 8035 |
]. |
8036 |
^ super currentSelectionFgColor |
|
8037 |
! |
|
8038 |
||
3996 | 8039 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8040 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 8041 |
|
8042 |
super resetVariablesBeforeNewSearch. |
|
8043 |
||
8044 |
"/ new search invalidates remembered string |
|
4048 | 8045 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8046 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8047 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 8048 |
! |
8049 |
||
4053 | 8050 |
setLastStringToReplace: aString |
8051 |
||
8052 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
8053 |
||
8054 |
|lastReplaceIgnoredCase| |
|
8055 |
||
4064 | 8056 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
8057 |
self clearSearchAction. |
|
8058 |
||
4053 | 8059 |
lastReplacementInfo lastStringToReplace: aString. |
8060 |
lastStringFromReplaceForNextSearch := aString. |
|
8061 |
||
8062 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 8063 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
8064 |
ifTrue: [lastSearchIgnoredCase] |
|
8065 |
ifFalse: [nil]. |
|
4053 | 8066 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
8067 |
! |
|
8068 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8069 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8070 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8071 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8072 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8073 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8074 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8075 |
textChanged |
522 | 8076 |
"my text was modified (internally). |
8077 |
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
|
8078 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 8079 |
is used to notify scrollers, other views etc.). |
8080 |
||
5979 | 8081 |
As some authors of this code have been very sloppy in the past |
4635 | 8082 |
(not sending contentsChanged, but textChanged), |
8083 |
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
|
8084 |
|
641 | 8085 |
self contentsChanged. |
1015 | 8086 |
self modified:true. |
5774 | 8087 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8088 |
contentsWasSaved := false |
641 | 8089 |
|
1015 | 8090 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 8091 |
! |
8092 |
||
2617 | 8093 |
textChangedButNoSizeChange |
2207 | 8094 |
"my text was modified (internally). |
8095 |
Sent whenever text has been edited (not to confuse with |
|
8096 |
contentsChanged, which is triggered when the size has changed, and |
|
8097 |
is used to notify scrollers, other views etc.)" |
|
8098 |
||
8099 |
self modified:true. |
|
8100 |
contentsWasSaved := false |
|
8101 |
||
8102 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8103 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8104 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8105 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8106 |
|
5216 | 8107 |
canAccept |
8108 |
"true if text can be accepts. |
|
8109 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8110 |
||
8111 |
^ acceptEnabled ~~ false |
|
8112 |
! |
|
8113 |
||
8114 |
canCut |
|
8115 |
"true if there is a selection possibly to be cut. |
|
8116 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8117 |
||
8118 |
self isReadOnly ifTrue:[ ^ false ]. |
|
8119 |
^ self hasSelection |
|
8120 |
! |
|
8121 |
||
8122 |
canDoAgain |
|
8123 |
"true if there is a possible repeat last edit operation. |
|
8124 |
Used to disable the menu if there is nothing" |
|
8125 |
||
8126 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 8127 |
^ lastReplacementInfo lastStringToReplace notNil |
8128 |
||
8129 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 8130 |
! |
8131 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8132 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8133 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8134 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8135 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8136 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8137 |
"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
|
8138 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8139 |
|
4064 | 8140 |
hasSearchActionSelection |
8141 |
||
8142 |
^ typeOfSelection == #searchAction |
|
8143 |
! |
|
8144 |
||
1878 | 8145 |
isKeyboardConsumer |
8146 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 8147 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 8148 |
|
3476 | 8149 |
^ self isReadOnly not |
1878 | 8150 |
! |
8151 |
||
997 | 8152 |
specClass |
1390 | 8153 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
8154 |
||
997 | 8155 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 8156 |
^ super specClass |
8157 |
||
1390 | 8158 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 8159 |
! |
8160 |
||
324 | 8161 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
8162 |
"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
|
8163 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8164 |
"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
|
8165 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8166 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8167 |
|
8168 |
"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
|
8169 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8170 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8171 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8172 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8173 |
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
|
8174 |
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
|
8175 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8176 |
|
697 | 8177 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8178 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8179 |
w := super widthOfContents. |
5643 | 8180 |
(dev := device ) isNil ifTrue:[ |
4889 | 8181 |
"/ really don't know ... |
4823 | 8182 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8183 |
]. |
4889 | 8184 |
^ w + (gc font widthOn:dev) |
697 | 8185 |
|
8186 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8187 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8188 |
|
1588 | 8189 |
!EditTextView methodsFor:'realization'! |
8190 |
||
8191 |
realize |
|
8192 |
"make the view visible - scroll to make the cursor visible." |
|
8193 |
||
8194 |
super realize. |
|
8195 |
||
8196 |
self makeCursorVisible. |
|
5643 | 8197 |
cursorFgColor := cursorFgColor onDevice:device. |
8198 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8199 |
|
8200 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8201 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8202 |
! ! |
|
8203 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8204 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8205 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8206 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8207 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8208 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8209 |
cursorShown ifTrue:[ |
4823 | 8210 |
cursorVisibleLine notNil ifTrue:[ |
8211 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8212 |
self drawCursorCharacter |
|
8213 |
] |
|
8214 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8215 |
] |
105 | 8216 |
! |
8217 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8218 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8219 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8220 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8221 |
cursorShown ifTrue:[ |
4823 | 8222 |
(visLine == cursorVisibleLine) ifTrue:[ |
8223 |
self drawCursorCharacter |
|
8224 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8225 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8226 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8227 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8228 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8229 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8230 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8231 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8232 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8233 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8234 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8235 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8236 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8237 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8238 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8239 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8240 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8241 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8242 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8243 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8244 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8245 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8246 |
cursorShown ifTrue:[ |
4823 | 8247 |
(visLine == cursorVisibleLine) ifTrue:[ |
8248 |
(colNr == cursorCol) ifTrue:[ |
|
8249 |
self drawCursorCharacter. |
|
8250 |
^ self |
|
8251 |
] |
|
8252 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8253 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8254 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8255 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8256 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8257 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8258 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8259 |
"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
|
8260 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8261 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8262 |
cursorShown ifTrue:[ |
8263 |
self redrawCursorIfInVisibleLine:visLine |
|
8264 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8265 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8266 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8267 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8268 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8269 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8270 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8271 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8272 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8273 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8274 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8275 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8276 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8277 |
"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
|
8278 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8279 |
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
|
8280 |
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
|
8281 |
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
|
8282 |
|
4889 | 8283 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8284 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8285 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8286 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8287 |
"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
|
8288 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8289 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8290 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8291 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8292 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8293 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8294 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8295 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8296 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8297 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8298 |
"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
|
8299 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8300 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8301 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8302 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8303 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8304 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8305 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8306 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8307 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8308 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8309 |
"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
|
8310 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8312 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8313 |
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
|
8314 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8315 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8316 |
prevCursorState ifTrue:[ |
4823 | 8317 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8318 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8319 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8320 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8321 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8322 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8323 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8324 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8325 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8326 |
prevCursorState := cursorShown. |
1601 | 8327 |
"/ cursorShown := false. |
1591 | 8328 |
cursorShown ifTrue:[ |
4823 | 8329 |
self hideCursor |
1591 | 8330 |
] |
8331 |
||
1601 | 8332 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8333 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8334 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8335 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8336 |
"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
|
8337 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8339 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8340 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8341 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8342 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8343 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8344 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8345 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8346 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8347 |
"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
|
8348 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8349 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8350 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8351 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8352 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8353 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8354 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8355 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8356 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8357 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8358 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8359 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8360 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8361 |
|
2822 | 8362 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8363 |
! |
8364 |
||
8365 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8366 |
"do a backward search" |
|
8367 |
||
8368 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8369 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8370 |
! |
8371 |
||
8372 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8373 |
"do a backward search" |
|
8374 |
||
8375 |
cursorLine isNil ifTrue:[^ self]. |
|
8376 |
||
3160 | 8377 |
self |
4119 | 8378 |
searchBackwardFor:pattern |
8379 |
ignoreCase:ign |
|
8380 |
startingAtLine:startLine col:startCol |
|
5717 | 8381 |
ifFound:[:line :col :endColOrNil | |
4119 | 8382 |
self cursorMovementAllowed ifTrue:[ |
8383 |
self cursorLine:line col:col. |
|
8384 |
]. |
|
5717 | 8385 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
1339 | 8386 |
"/ self makeLineVisible:cursorLine |
4119 | 8387 |
typeOfSelection := #search] |
8388 |
ifAbsent:aBlock |
|
1339 | 8389 |
|
8390 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8391 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8392 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8393 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8394 |
"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
|
8395 |
|
2554 | 8396 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8397 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8398 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8399 |
searchForMatchingParenthesis |
3160 | 8400 |
"search for a matching parenthesis starting at cursor position. |
8401 |
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
|
8402 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8403 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8404 |
|
2822 | 8405 |
self cursorMovementAllowed ifFalse:[^ self]. |
8406 |
||
3160 | 8407 |
self |
4823 | 8408 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8409 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8410 |
ifNotFound:[self showNotFound] |
|
8411 |
onError:[self beep] |
|
1339 | 8412 |
|
8413 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8414 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8415 |
|
3967 | 8416 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8417 |
"do a forward search" |
8418 |
||
8419 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 8420 |
self |
8421 |
searchForwardFor:pattern |
|
8422 |
ignoreCase:ign |
|
8423 |
match: match |
|
8424 |
startingAtLine:startLine col:startCol |
|
5717 | 8425 |
ifFound:[:line :col :endColOrNil| |
3967 | 8426 |
self cursorMovementAllowed ifTrue:[ |
8427 |
self cursorLine:line col:col. |
|
8428 |
]. |
|
5717 | 8429 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
1339 | 8430 |
"/ self makeLineVisible:cursorLine |
3967 | 8431 |
typeOfSelection := #search |
8432 |
] |
|
8433 |
ifAbsent:aBlock |
|
1339 | 8434 |
|
8435 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8436 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8437 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8438 |
|
3967 | 8439 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8440 |
"do a forward search" |
|
8441 |
||
8442 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8443 |
! |
|
8444 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8445 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8446 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8447 |
|
2822 | 8448 |
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
|
8449 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8450 |
|
3982 | 8451 |
searchPatternForSearchBar |
8452 |
||
8453 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8454 |
||
8455 |
|searchPattern| |
|
8456 |
||
4138 | 8457 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 8458 |
searchPattern isNil |
8459 |
ifTrue: [searchPattern := lastSearchPattern] |
|
8460 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
8461 |
^ searchPattern |
|
8462 |
! |
|
8463 |
||
3578 | 8464 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8465 |
"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
|
8466 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8467 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8468 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8469 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8470 |
"/ |
3967 | 8471 |
"/ 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
|
8472 |
"/ original string (for search after again) |
4121 | 8473 |
"/ 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
|
8474 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8475 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8476 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8477 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8478 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8479 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8480 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8481 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8482 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8483 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8484 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8485 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8486 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8487 |
"/ 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
|
8488 |
"/ if there was a previous search, only take the selection if |
3967 | 8489 |
"/ 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
|
8490 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8491 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8492 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8493 |
sel notNil ifTrue:[ |
3967 | 8494 |
(lastSearchPattern isNil |
4484 | 8495 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
8496 |
) ifTrue:[ |
|
3967 | 8497 |
self cursorLine:selectionStartLine col:selectionStartCol. |
8498 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8499 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8500 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8501 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8502 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8503 |
"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
|
8504 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8505 |
|
5717 | 8506 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8507 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8508 |
typeOfSelection := #search. |
8509 |
! |
|
8510 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8511 |
startPositionForSearchBackward |
2822 | 8512 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8513 |
! |
|
8514 |
||
8515 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8516 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8517 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8518 |
selectionStartLine notNil ifTrue:[ |
4823 | 8519 |
startLine := selectionStartLine. |
8520 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8521 |
] ifFalse:[ |
4823 | 8522 |
cursorLine isNil ifTrue:[ |
8523 |
startLine := list size. |
|
8524 |
startCol := self listAt:startLine size. |
|
8525 |
] ifFalse:[ |
|
8526 |
startLine := cursorLine min:list size. |
|
8527 |
startCol := cursorCol |
|
8528 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8529 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8530 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8531 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8532 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8533 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8534 |
startPositionForSearchForward |
2822 | 8535 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8536 |
! |
|
8537 |
||
8538 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8539 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8540 |
|
3160 | 8541 |
"/ 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
|
8542 |
"/ 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
|
8543 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8544 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8545 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8546 |
] ifFalse:[ |
4064 | 8547 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8548 |
startCol := 0 |
|
8549 |
]. |
|
8550 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8551 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8552 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8553 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8554 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8555 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8556 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8557 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8558 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8559 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8560 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8561 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8562 |
after evaluation of `aBlock`. Used to implement |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8563 |
Shift-Up/Down/Left/Right, Shift-Home & Shift-End." |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8564 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8565 |
"/ Following comment is in czech and thus now very useful. |
4970 | 8566 |
"/ However I (JV) kept it here as this is one of the very |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8567 |
"/ first fix/hack we made to Smalltalk/X ages ago, if not |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8568 |
"/ the very first one. Actually, this method and comment was |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8569 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8570 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8571 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8572 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8573 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8574 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8575 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8576 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8577 |
| startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown flip extModeStandard | |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8578 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8579 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8580 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8581 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8582 |
self hasSelection ifTrue: [ |
4970 | 8583 |
startLine := selectionStartLine. |
8584 |
startCol := selectionStartCol. |
|
8585 |
endLine := selectionEndLine. |
|
8586 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8587 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8588 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8589 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8590 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8591 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8592 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8593 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8594 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8595 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8596 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8597 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8598 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8599 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8600 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8601 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8602 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8603 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8604 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8605 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8606 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8607 |
flip := cursorLine == endLine and:[cursorCol > endCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8608 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8609 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8610 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8611 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8612 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8613 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8614 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8615 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8616 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8617 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8618 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8619 |
startLine := cursorLine. |
4823 | 8620 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8621 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8622 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8623 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8624 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8625 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8626 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8627 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8628 |
flip := cursorLine == startLine and:[cursorCol < startCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8629 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8630 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8631 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8632 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8633 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8634 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8635 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8636 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8637 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8638 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8639 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8640 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8641 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8642 |
] |
4823 | 8643 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8644 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8645 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8646 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8647 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8648 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8649 |
"Modified (comment): / 25-03-2014 / 17:18:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8650 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8651 |
|
1850 | 8652 |
autoMoveCursorToEndOfSelection |
8653 |
"return true, if the cursor should be automatically moved to the |
|
8654 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8655 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8656 |
not be affected by selecting" |
8657 |
||
8658 |
^ true |
|
8659 |
! |
|
8660 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8661 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8662 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8663 |
typeOfSelection := newType. |
8664 |
selectionStartLine notNil ifTrue:[ |
|
8665 |
self |
|
8666 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8667 |
toLine:selectionEndLine col:selectionEndCol |
|
8668 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8669 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8670 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8671 |
|
4707 | 8672 |
findNextWordAfterSelectionAndAddToSelection |
8673 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8674 |
||
8675 |
selectionStartCol isNil ifTrue:[ |
|
8676 |
self selectWordUnderCursor. |
|
8677 |
^ self |
|
8678 |
]. |
|
8679 |
||
8680 |
selStartCol := selectionStartCol. |
|
8681 |
selEndCol := selectionEndCol. |
|
8682 |
selStartLine := selectionStartLine. |
|
8683 |
selEndLine := selectionEndLine. |
|
8684 |
||
8685 |
self cursorToNextWord. |
|
8686 |
self selectWordUnderCursor. |
|
8687 |
||
8688 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8689 |
! |
|
8690 |
||
4138 | 8691 |
searchPatternFromUserSelectionOrReplace |
8692 |
||
8693 |
|sel searchPattern| |
|
8694 |
||
8695 |
"/ |
|
8696 |
"/ if the last operation was a replace, set pattern to last |
|
8697 |
"/ original string (for search after again) |
|
8698 |
"/ |
|
8699 |
(lastStringFromReplaceForNextSearch notNil |
|
8700 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8701 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8702 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8703 |
] ifFalse:[ |
|
8704 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8705 |
]. |
|
8706 |
^ searchPattern |
|
8707 |
]. |
|
8708 |
||
8709 |
"/ |
|
8710 |
"/ if there is a selection: |
|
8711 |
"/ if there was no previous search, take it as search pattern. |
|
8712 |
"/ if there was a previous search, only take the selection if |
|
8713 |
"/ it did not result from a paste. |
|
8714 |
"/ (to allow search-paste to be repeated) |
|
8715 |
"/ |
|
8716 |
sel := self selection. |
|
8717 |
sel notNil ifTrue:[ |
|
8718 |
typeOfSelection ~~ #search ifTrue:[ |
|
8719 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8720 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8721 |
searchPattern := sel asStringWithoutFinalCR. |
|
8722 |
] |
|
8723 |
]. |
|
8724 |
]. |
|
8725 |
||
8726 |
^ searchPattern |
|
8727 |
! |
|
8728 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8729 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8730 |
"select the whole text. |
5593 | 8731 |
redefined to send super selectFrom... since we don't want the |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8732 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8733 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8734 |
list isNil ifTrue:[ |
4823 | 8735 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8736 |
] ifFalse:[ |
4823 | 8737 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8738 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8739 |
] |
1082 | 8740 |
|
8741 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8742 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8743 |
|
4117 | 8744 |
selectAllInitially |
8745 |
"select the whole text. This is called only once during the initialization |
|
8746 |
for editFields which are shown in a table or tree. |
|
8747 |
The selectAll is called via this method to allow for easier redefinition and |
|
8748 |
to distinguish auto-select from user-initiated selects." |
|
8749 |
||
8750 |
self selectAll |
|
8751 |
! |
|
8752 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8753 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8754 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8755 |
|
3160 | 8756 |
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
|
8757 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8759 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8760 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8761 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8762 |
cursorCol > 1 ifTrue:[ |
4823 | 8763 |
self selectFromLine:cursorLine col:1 |
8764 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8765 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8766 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8767 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8768 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8769 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8770 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8771 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8772 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8773 |
selectionStartLine isNil ifTrue:[ |
4823 | 8774 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8775 |
] ifFalse:[ |
4823 | 8776 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8777 |
toLine:cursorLine+1 col:0. |
|
8778 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8779 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8780 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8781 |
|
4257 | 8782 |
selectFromBeginOfLine |
8783 |
"select the text from the beginning of the current line to the current cursor position." |
|
8784 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8785 |
| newCursorCol ln | |
4271 | 8786 |
|
4257 | 8787 |
list isNil ifTrue:[ |
8788 |
self unselect |
|
8789 |
] ifFalse:[ |
|
8790 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8791 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8792 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8793 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8794 |
cursorCol := newCursorCol. |
|
4257 | 8795 |
typeOfSelection := nil |
8796 |
] |
|
8797 |
] |
|
8798 |
||
8799 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8800 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8801 |
! |
8802 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8803 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8804 |
"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
|
8805 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8806 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8807 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8808 |
list isNil ifTrue:[ |
4823 | 8809 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8810 |
] ifFalse:[ |
4823 | 8811 |
cursorCol == 0 ifTrue:[ |
8812 |
col := 0 |
|
8813 |
] ifFalse:[ |
|
8814 |
col := cursorCol - 1 |
|
8815 |
]. |
|
8816 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8817 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8818 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8819 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8820 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8821 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8822 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8823 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
5293
bb7a5aa59ddb
Merged 5251ecf0c9bb and 9d85f8e1e20c (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
8824 |
"JV: That's actually rubbish as then you loose the original positon |
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8825 |
and if user wants to extend/shring the selection further, you don't know |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8826 |
from which end to do it!!" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8827 |
"/ (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8828 |
"/ self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8829 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8830 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8831 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8832 |
"Modified: / 27-08-2013 / 13:28:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8833 |
"Modified (comment): / 27-08-2013 / 15:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8834 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8835 |
|
4257 | 8836 |
selectToEndOfLine |
8837 |
"select the text from the current cursor position to the end of the current line" |
|
8838 |
||
4271 | 8839 |
| newCursorCol line | |
8840 |
||
4257 | 8841 |
list isNil ifTrue:[ |
8842 |
self unselect |
|
8843 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8844 |
cursorCol >= 1 ifTrue:[ |
4271 | 8845 |
line := list at: cursorLine. |
8846 |
newCursorCol := line size. |
|
8847 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8848 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8849 |
||
8850 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8851 |
cursorCol := newCursorCol. |
|
4257 | 8852 |
typeOfSelection := nil |
8853 |
] |
|
8854 |
] |
|
8855 |
||
8856 |
"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
|
8857 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8858 |
! |
8859 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8860 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8861 |
"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
|
8862 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8863 |
list isNil ifTrue:[ |
4823 | 8864 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8865 |
] ifFalse:[ |
4823 | 8866 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8867 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8868 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8869 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8870 |
|
6153
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8871 |
selectWordAtLine:line col:col |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8872 |
"select the word at given line/col" |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8873 |
super selectWordAtLine:line col:col. |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8874 |
cursorLine := selectionEndLine. |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8875 |
cursorCol := selectionEndCol + 1. |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8876 |
|
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8877 |
"Created: / 16-03-2017 / 23:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8878 |
! |
ef289d40b266
Issue #124, case 0: Fixed long standing bug with inconsistent cursor position after select-word
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6133
diff
changeset
|
8879 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8880 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8881 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8882 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8883 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8884 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8886 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8887 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8888 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8889 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8890 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8891 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8892 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8893 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8894 |
wasOn ifTrue:[self showCursor] |
105 | 8895 |
! ! |
8896 |
||
8897 |
!EditTextView methodsFor:'undo & again'! |
|
8898 |
||
2952 | 8899 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8900 |
^ undoSupport addUndo:action. |
2952 | 8901 |
! |
8902 |
||
105 | 8903 |
again |
8904 |
"repeat the last action (which was a cut or replace). |
|
8905 |
If current selection is not last string, search forward to |
|
3160 | 8906 |
next occurrence of it before repeating the last operation." |
105 | 8907 |
|
4048 | 8908 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8909 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8910 |
|
8911 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8912 |
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
|
8913 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8914 |
]. |
4048 | 8915 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8916 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8917 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8918 |
self undoableDo:[ |
4010 | 8919 |
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
|
8920 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8921 |
(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
|
8922 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8923 |
|
4053 | 8924 |
"set lastStringToReplace as the next search string |
8925 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8926 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8927 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8928 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8929 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8930 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8931 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8932 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8933 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8934 |
"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
|
8935 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8936 |
(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
|
8937 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8938 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8939 |
self deleteSelection. |
4051 | 8940 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8941 |
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
|
8942 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8943 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8944 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8945 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8946 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8947 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8948 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8949 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8950 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8951 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8952 |
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
|
8953 |
]. |
4048 | 8954 |
self |
8955 |
searchForwardFor:s |
|
8956 |
ignoreCase: lastReplaceIgnoredCase |
|
8957 |
match: lastReplaceWasMatch |
|
8958 |
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
|
8959 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8960 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8961 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8962 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8963 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8964 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8965 |
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
|
8966 |
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
|
8967 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8968 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8969 |
self deleteSelection. |
4051 | 8970 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8971 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8972 |
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
|
8973 |
] ifTrue:[ |
4051 | 8974 |
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
|
8975 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8976 |
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
|
8977 |
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
|
8978 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8979 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8980 |
selectStyle := savedSelectStyle. |
4484 | 8981 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8982 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8983 |
] |
4048 | 8984 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8985 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8986 |
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
|
8987 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8988 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8989 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8990 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8991 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8992 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8993 |
^ true. |
501 | 8994 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8995 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8996 |
! |
8997 |
||
2952 | 8998 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8999 |
^ undoSupport hasRedoAction. |
2952 | 9000 |
! |
9001 |
||
9002 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9003 |
^ undoSupport hasUndoAction. |
2952 | 9004 |
! |
9005 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9006 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9007 |
"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
|
9008 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9009 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9010 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9011 |
|
2952 | 9012 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9013 |
undoSupport nonUndoableDo:aBlock. |
2952 | 9014 |
! |
9015 |
||
9016 |
redo |
|
3780 | 9017 |
"undo the last undo" |
9018 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9019 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 9020 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9021 |
] ifTrue:[ |
3780 | 9022 |
undoSupport redo. |
2952 | 9023 |
] |
9024 |
! |
|
9025 |
||
121 | 9026 |
undo |
3780 | 9027 |
"undo the last edit operation" |
9028 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9029 |
undoSupport hasUndoAction ifFalse:[ |
5834 | 9030 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9031 |
] ifTrue:[ |
5834 | 9032 |
undoSupport undo. |
9033 |
self makeSelectionVisible. |
|
9034 |
self makeCursorVisible. |
|
121 | 9035 |
] |
2952 | 9036 |
! |
9037 |
||
9038 |
undoableDo:aBlock |
|
3495 | 9039 |
self undoableDo:aBlock info:nil. |
9040 |
||
9041 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 9042 |
! |
9043 |
||
9044 |
undoableDo:aBlock info:aString |
|
5689 | 9045 |
|selectionRestore| |
9046 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9047 |
self checkModificationsAllowed ifFalse:[ |
4823 | 9048 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
9049 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9050 |
] ifTrue:[ |
5689 | 9051 |
undoSupport isInTransaction ifFalse:[ |
9052 |
selectionRestore := RestoreSelectionAndCursor new |
|
9053 |
cursorLine:cursorLine cursorCol:cursorCol |
|
9054 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
9055 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
9056 |
info:nil. |
|
9057 |
]. |
|
9058 |
undoSupport |
|
9059 |
undoableDo:[ |
|
9060 |
aBlock value. |
|
9061 |
selectionRestore notNil ifTrue:[ |
|
9062 |
undoSupport transactionNotEmpty ifTrue:[ |
|
9063 |
undoSupport addUndoFirst:selectionRestore |
|
9064 |
]. |
|
9065 |
]. |
|
9066 |
] |
|
9067 |
info:aString. |
|
9068 |
]. |
|
9069 |
||
9070 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 9071 |
! ! |
9072 |
||
9073 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
9074 |
||
9075 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9076 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9077 |
! |
|
9078 |
||
3115 | 9079 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 9080 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 9081 |
! |
9082 |
||
2952 | 9083 |
line:arg1 col:arg2 character:arg3 |
9084 |
^ self new line:arg1 col:arg2 character:arg3 |
|
9085 |
! |
|
9086 |
||
3115 | 9087 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 9088 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 9089 |
! |
9090 |
||
3235 | 9091 |
line:arg1 col:arg2 characters:arg3 info:info |
9092 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
9093 |
! |
|
9094 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9095 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9096 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9097 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9098 |
|
2952 | 9099 |
line:arg1 col:arg2 string:arg3 |
9100 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 9101 |
! |
9102 |
||
9103 |
line:arg1 col:arg2 string:arg3 info:info |
|
9104 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 9105 |
! |
9106 |
||
9107 |
line:arg1 string:arg3 info:info |
|
9108 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 9109 |
! |
9110 |
||
9111 |
text:arg info:info |
|
9112 |
^ (self new text:arg) info:info |
|
3115 | 9113 |
! ! |
9114 |
||
9115 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
9116 |
||
9117 |
info |
|
9118 |
^ userFriendlyInfo |
|
9119 |
! |
|
9120 |
||
9121 |
info:aString |
|
9122 |
userFriendlyInfo := aString |
|
2952 | 9123 |
! ! |
9124 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9125 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9126 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9127 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9128 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9129 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9130 |
"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
|
9131 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9132 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9133 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9134 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9135 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9136 |
^ false |
5710 | 9137 |
! |
9138 |
||
9139 |
isRestoreSelectionAndCursor |
|
9140 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9141 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9142 |
|
2952 | 9143 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
9144 |
||
3160 | 9145 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 9146 |
"set instance variables (automatically generated)" |
9147 |
||
9148 |
self assert:(line1Arg notNil). |
|
9149 |
self assert:(col1Arg notNil). |
|
9150 |
self assert:(line2Arg notNil). |
|
9151 |
self assert:(col2Arg notNil). |
|
9152 |
||
9153 |
line1 := line1Arg. |
|
9154 |
col1 := col1Arg. |
|
9155 |
line2 := line2Arg. |
|
9156 |
col2 := col2Arg. |
|
9157 |
! ! |
|
9158 |
||
9159 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
9160 |
||
3160 | 9161 |
executeIn:editor |
2952 | 9162 |
editor unselect. |
3160 | 9163 |
editor |
4823 | 9164 |
deleteFromLine:line1 |
9165 |
col:col1 |
|
9166 |
toLine:line2 |
|
9167 |
col:col2. |
|
2952 | 9168 |
editor cursorLine:line1 col:col1. |
9169 |
! ! |
|
9170 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9171 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9172 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9173 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9174 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9175 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9176 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9177 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9178 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9179 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9180 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9181 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9182 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9183 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9184 |
|
3160 | 9185 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9186 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9187 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9188 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9189 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9190 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9191 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9192 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9193 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9194 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9195 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9196 |
|
3160 | 9197 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9198 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9199 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9200 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9201 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9202 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9203 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9204 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9205 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9206 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9207 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9208 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9209 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9210 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9211 |
|
3160 | 9212 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9213 |
"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
|
9214 |
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
|
9215 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9216 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9217 |
previousDeleteAction line == line ifTrue:[ |
4823 | 9218 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
9219 |
^ true |
|
9220 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9221 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9222 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9223 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9224 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9225 |
|
3160 | 9226 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9227 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9228 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9229 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9230 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9231 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9232 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9233 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9234 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9235 |
|
3160 | 9236 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9237 |
editor unselect. |
3160 | 9238 |
editor |
4823 | 9239 |
deleteFromLine:line |
9240 |
col:col1 |
|
9241 |
toLine:line |
|
9242 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9243 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9244 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9245 |
|
3235 | 9246 |
!EditTextView::EditMode class methodsFor:'constants'! |
9247 |
||
9248 |
insertAndSelectMode |
|
9249 |
^ InsertAndSelectMode |
|
9250 |
! |
|
9251 |
||
9252 |
insertMode |
|
9253 |
^ InsertMode |
|
9254 |
! |
|
9255 |
||
9256 |
overwriteMode |
|
9257 |
^ OverwriteMode |
|
9258 |
! ! |
|
9259 |
||
9260 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9261 |
||
9262 |
isInsertAndSelectMode |
|
9263 |
^ false |
|
9264 |
! |
|
9265 |
||
9266 |
isInsertMode |
|
9267 |
^ false |
|
9268 |
! |
|
9269 |
||
9270 |
symbolicName |
|
9271 |
self subclassResponsibility |
|
9272 |
! ! |
|
9273 |
||
9274 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9275 |
||
9276 |
infoPrintString |
|
9277 |
^ 'IS' |
|
9278 |
! ! |
|
9279 |
||
9280 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9281 |
||
9282 |
isInsertAndSelectMode |
|
9283 |
^ true |
|
9284 |
! |
|
9285 |
||
9286 |
isInsertMode |
|
9287 |
^ true |
|
9288 |
! ! |
|
9289 |
||
9290 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9291 |
||
9292 |
infoPrintString |
|
9293 |
^ 'I' |
|
9294 |
! ! |
|
9295 |
||
9296 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9297 |
||
9298 |
isInsertMode |
|
9299 |
^ true |
|
9300 |
! ! |
|
9301 |
||
9302 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9303 |
||
9304 |
infoPrintString |
|
9305 |
^ 'O' |
|
9306 |
! ! |
|
9307 |
||
4048 | 9308 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9309 |
||
9310 |
lastReplaceIgnoredCase |
|
9311 |
^ lastReplaceIgnoredCase ? false |
|
9312 |
! |
|
9313 |
||
9314 |
lastReplaceIgnoredCase:something |
|
9315 |
lastReplaceIgnoredCase := something. |
|
9316 |
! |
|
9317 |
||
9318 |
lastReplaceWasMatch |
|
9319 |
^ lastReplaceWasMatch ? false |
|
9320 |
! |
|
9321 |
||
9322 |
lastReplaceWasMatch:something |
|
9323 |
lastReplaceWasMatch := something. |
|
9324 |
! |
|
9325 |
||
9326 |
lastReplacement |
|
9327 |
^ lastReplacement |
|
9328 |
! |
|
9329 |
||
9330 |
lastReplacement:something |
|
4053 | 9331 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9332 |
lastReplacement := something. |
9333 |
! |
|
9334 |
||
9335 |
lastStringToReplace |
|
9336 |
^ lastStringToReplace |
|
9337 |
! |
|
9338 |
||
9339 |
lastStringToReplace:something |
|
9340 |
lastStringToReplace := something. |
|
4818 | 9341 |
! |
9342 |
||
9343 |
previousReplacements |
|
9344 |
^ previousReplacements ? #() |
|
9345 |
! |
|
9346 |
||
9347 |
stillCollectingInput |
|
9348 |
^ stillCollectingInput |
|
9349 |
! |
|
9350 |
||
9351 |
stillCollectingInput:aBoolean |
|
9352 |
stillCollectingInput := aBoolean. |
|
9353 |
! ! |
|
9354 |
||
9355 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9356 |
||
9357 |
rememberReplacement |
|
9358 |
"remember the previous replacement (called when a new one appears). |
|
9359 |
Mostly for the benefit of the code completion..." |
|
9360 |
||
9361 |
|oldString newString| |
|
9362 |
||
9363 |
oldString := lastStringToReplace. |
|
9364 |
newString := lastReplacement. |
|
9365 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
9366 |
previousReplacements isNil ifTrue:[ |
|
9367 |
previousReplacements := OrderedCollection new. |
|
9368 |
]. |
|
9369 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9370 |
previousReplacements addFirst:(oldString -> newString). |
|
9371 |
previousReplacements size > 20 ifTrue:[ |
|
9372 |
previousReplacements removeLast. |
|
9373 |
] |
|
9374 |
]. |
|
4048 | 9375 |
! ! |
9376 |
||
2952 | 9377 |
!EditTextView::PasteString methodsFor:'accessing'! |
9378 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9379 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9380 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9381 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9382 |
"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
|
9383 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9384 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9385 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9386 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9387 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9388 |
"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
|
9389 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9390 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9391 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9392 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9393 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9394 |
"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
|
9395 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9396 |
|
3160 | 9397 |
line:lineArg col:colArg string:stringArg |
2952 | 9398 |
self assert:(lineArg notNil). |
9399 |
self assert:(colArg notNil). |
|
9400 |
self assert:(stringArg notNil). |
|
9401 |
||
9402 |
line := lineArg. |
|
9403 |
col := colArg. |
|
9404 |
string := stringArg. |
|
9405 |
! |
|
9406 |
||
9407 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9408 |
self assert:(lineArg notNil). |
|
9409 |
self assert:(colArg notNil). |
|
9410 |
self assert:(stringArg notNil). |
|
9411 |
||
9412 |
line := lineArg. |
|
9413 |
col := colArg. |
|
9414 |
string := stringArg. |
|
9415 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9416 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9417 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9418 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9419 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9420 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9421 |
"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
|
9422 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9423 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9424 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9425 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9426 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9427 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9428 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9429 |
"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
|
9430 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9431 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9432 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9433 |
"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
|
9434 |
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
|
9435 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9436 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9437 |
previousPasteAction line == line ifTrue:[ |
4823 | 9438 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9439 |
^ true |
|
9440 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9441 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9442 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9443 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9444 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9445 |
"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
|
9446 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9447 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9448 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9449 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9450 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9451 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9452 |
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
|
9453 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9454 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9455 |
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
|
9456 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9457 |
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
|
9458 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9459 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9460 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9461 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9462 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9463 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9464 |
! ! |
9465 |
||
9466 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9467 |
||
3160 | 9468 |
executeIn:editor |
2952 | 9469 |
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
|
9470 |
editor paste:string. |
2952 | 9471 |
selected ~~ true ifTrue:[ |
4823 | 9472 |
editor unselect |
2952 | 9473 |
]. |
9474 |
! ! |
|
9475 |
||
9476 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9477 |
||
3235 | 9478 |
col |
9479 |
^ col |
|
9480 |
! |
|
9481 |
||
9482 |
col1 |
|
9483 |
^ col |
|
9484 |
! |
|
9485 |
||
9486 |
col2 |
|
9487 |
^ col |
|
9488 |
! |
|
9489 |
||
9490 |
line |
|
9491 |
^ line |
|
9492 |
! |
|
9493 |
||
3160 | 9494 |
line:lineArg col:colArg character:characterArg |
2952 | 9495 |
line := lineArg. |
9496 |
col := colArg. |
|
9497 |
character := characterArg. |
|
9498 |
! ! |
|
9499 |
||
9500 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9501 |
||
3160 | 9502 |
executeIn:editor |
9503 |
editor |
|
4823 | 9504 |
replace:character |
9505 |
atLine:line |
|
9506 |
col:col. |
|
2952 | 9507 |
editor cursorLine:line col:col. |
105 | 9508 |
! ! |
9509 |
||
3235 | 9510 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9511 |
||
9512 |
characters |
|
9513 |
^ characters |
|
9514 |
! |
|
9515 |
||
9516 |
col1 |
|
9517 |
^ col1 |
|
9518 |
! |
|
9519 |
||
9520 |
col2 |
|
9521 |
^ col2 |
|
9522 |
! |
|
9523 |
||
9524 |
line |
|
9525 |
^ line |
|
9526 |
! |
|
9527 |
||
9528 |
line:lineArg col:colArg character:characterArg |
|
9529 |
line := lineArg. |
|
9530 |
col1 := col2 := colArg. |
|
9531 |
characters := characterArg asString. |
|
9532 |
! |
|
9533 |
||
9534 |
line:lineArg col:colArg characters:charactersArg |
|
9535 |
line := lineArg. |
|
9536 |
col1 := colArg. |
|
9537 |
characters := charactersArg asString. |
|
9538 |
col2 := col1 + charactersArg size - 1 |
|
9539 |
! ! |
|
9540 |
||
9541 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9542 |
||
9543 |
canCombineWithNext:anotherAction |
|
9544 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9545 |
! |
|
9546 |
||
9547 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9548 |
"I will combine only if we both are single character deletes, |
|
9549 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9550 |
(i.e. single-character typing)" |
|
9551 |
||
9552 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 9553 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9554 |
^ true |
|
9555 |
]. |
|
3235 | 9556 |
]. |
9557 |
||
9558 |
^ false |
|
9559 |
! |
|
9560 |
||
9561 |
combineWithNext:nextReplaceAction |
|
9562 |
self assert:(line == nextReplaceAction line). |
|
9563 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9564 |
||
9565 |
col2 := nextReplaceAction col2. |
|
9566 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9567 |
characters := characters , nextReplaceAction characters. |
|
9568 |
! ! |
|
9569 |
||
9570 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9571 |
||
9572 |
executeIn:editor |
|
9573 |
editor |
|
4823 | 9574 |
replaceString:characters |
9575 |
atLine:line |
|
9576 |
col:col1. |
|
3235 | 9577 |
editor cursorLine:line col:col1. |
9578 |
! ! |
|
9579 |
||
3131 | 9580 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9581 |
||
9582 |
text:something |
|
9583 |
text := something. |
|
9584 |
! ! |
|
9585 |
||
9586 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9587 |
||
3160 | 9588 |
executeIn:editor |
3131 | 9589 |
editor contents:text |
9590 |
! ! |
|
9591 |
||
3130 | 9592 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9593 |
||
3160 | 9594 |
line:lineArg string:stringArg |
3130 | 9595 |
line := lineArg. |
9596 |
text := stringArg. |
|
9597 |
! ! |
|
9598 |
||
9599 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9600 |
||
3160 | 9601 |
executeIn:editor |
3130 | 9602 |
editor list at:line put:text. |
9603 |
editor invalidateLine:line |
|
9604 |
! ! |
|
9605 |
||
3402 | 9606 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9607 |
||
9608 |
line:lineArg lines:lineCollectionArg |
|
9609 |
line := lineArg. |
|
9610 |
text := lineCollectionArg. |
|
9611 |
||
9612 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9613 |
! ! |
|
9614 |
||
9615 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9616 |
||
9617 |
executeIn:editor |
|
9618 |
|lnr| |
|
9619 |
||
9620 |
lnr := line. |
|
9621 |
text do:[:eachLine | |
|
4823 | 9622 |
editor list at:lnr put:eachLine. |
9623 |
editor invalidateLine:lnr. |
|
9624 |
lnr := lnr + 1. |
|
3402 | 9625 |
]. |
9626 |
||
9627 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9628 |
! ! |
|
9629 |
||
5689 | 9630 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9631 |
||
9632 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9633 |
cursorLine := cursorLineArg. |
|
9634 |
cursorCol := cursorColArg. |
|
9635 |
selectionStartLine := selectionStartLineArg. |
|
9636 |
selectionStartCol := selectionStartColArg. |
|
9637 |
selectionEndLine := selectionEndLineArg. |
|
9638 |
selectionEndCol := selectionEndColArg. |
|
9639 |
! |
|
9640 |
||
9641 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
9642 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
9643 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9644 |
info:info |
|
9645 |
||
9646 |
cursorLine := cursorLineArg. |
|
9647 |
cursorCol := cursorColArg. |
|
9648 |
selectionStartLine := selectionStartLineArg. |
|
9649 |
selectionStartCol := selectionStartColArg. |
|
9650 |
selectionEndLine := selectionEndLineArg. |
|
9651 |
selectionEndCol := selectionEndColArg. |
|
9652 |
userFriendlyInfo := info. |
|
9653 |
||
9654 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9655 |
! ! |
|
9656 |
||
9657 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9658 |
||
9659 |
executeIn:editor |
|
9660 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9661 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
9662 |
editor setCursorLine:cursorLine col:cursorCol. |
|
9663 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
9664 |
] ifFalse:[ |
|
9665 |
editor cursorLine:cursorLine col:cursorCol. |
|
9666 |
]. |
|
9667 |
||
9668 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9669 |
! ! |
|
9670 |
||
5710 | 9671 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9672 |
||
9673 |
isRestoreSelectionAndCursor |
|
9674 |
^ true |
|
9675 |
! ! |
|
9676 |
||
865 | 9677 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9678 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9679 |
version |
5361 | 9680 |
^ '$Header$' |
3945 | 9681 |
! |
9682 |
||
9683 |
version_CVS |
|
5361 | 9684 |
^ '$Header$' |
4843
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9685 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9686 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9687 |
version_HG |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9688 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9689 |
^ '$Changeset: <not expanded> $' |
0 | 9690 |
! ! |
4481 | 9691 |