author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 29 Jul 2016 22:05:57 +0100 | |
branch | jv |
changeset 5810 | ff31884ac479 |
parent 5809 | a5cecde02b21 |
parent 5795 | ee8125645546 |
child 5828 | 990b7b5c4a94 |
permissions | -rw-r--r-- |
5795 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
14 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
15 |
|
5239 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
TextView subclass:#EditTextView |
4826 | 19 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
20 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
21 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
22 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
23 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
24 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
25 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
26 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
27 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
28 |
undoSupport lastStringFromReplaceForNextSearch |
|
29 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
30 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
31 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
32 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
33 |
poolDictionaries:'' |
|
34 |
category:'Views-Text' |
|
0 | 35 |
! |
36 |
||
2952 | 37 |
Object subclass:#EditAction |
4826 | 38 |
instanceVariableNames:'userFriendlyInfo' |
39 |
classVariableNames:'' |
|
40 |
poolDictionaries:'' |
|
41 |
privateIn:EditTextView |
|
2952 | 42 |
! |
43 |
||
44 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 45 |
instanceVariableNames:'line1 col1 line2 col2' |
46 |
classVariableNames:'' |
|
47 |
poolDictionaries:'' |
|
48 |
privateIn:EditTextView |
|
2952 | 49 |
! |
50 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
51 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 52 |
instanceVariableNames:'line col1 col2' |
53 |
classVariableNames:'' |
|
54 |
poolDictionaries:'' |
|
55 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
56 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
57 |
|
3235 | 58 |
Object subclass:#EditMode |
4826 | 59 |
instanceVariableNames:'' |
60 |
classVariableNames:'' |
|
61 |
poolDictionaries:'' |
|
62 |
privateIn:EditTextView |
|
3235 | 63 |
! |
64 |
||
65 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 66 |
instanceVariableNames:'' |
67 |
classVariableNames:'' |
|
68 |
poolDictionaries:'' |
|
69 |
privateIn:EditTextView::EditMode |
|
3235 | 70 |
! |
71 |
||
72 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 73 |
instanceVariableNames:'' |
74 |
classVariableNames:'' |
|
75 |
poolDictionaries:'' |
|
76 |
privateIn:EditTextView::EditMode |
|
3235 | 77 |
! |
78 |
||
79 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 80 |
instanceVariableNames:'' |
81 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
82 |
poolDictionaries:'' |
|
83 |
privateIn:EditTextView::EditMode |
|
3235 | 84 |
! |
85 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
86 |
Query subclass:#ExecutingMacroQuery |
4826 | 87 |
instanceVariableNames:'' |
88 |
classVariableNames:'' |
|
89 |
poolDictionaries:'' |
|
90 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
91 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
92 |
|
4048 | 93 |
Object subclass:#LastReplacementInfo |
4826 | 94 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
95 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
96 |
classVariableNames:'' |
|
97 |
poolDictionaries:'' |
|
98 |
privateIn:EditTextView |
|
4048 | 99 |
! |
100 |
||
2952 | 101 |
EditTextView::EditAction subclass:#PasteString |
4826 | 102 |
instanceVariableNames:'line col string selected' |
103 |
classVariableNames:'' |
|
104 |
poolDictionaries:'' |
|
105 |
privateIn:EditTextView |
|
2952 | 106 |
! |
107 |
||
108 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 109 |
instanceVariableNames:'line col character' |
110 |
classVariableNames:'' |
|
111 |
poolDictionaries:'' |
|
112 |
privateIn:EditTextView |
|
2952 | 113 |
! |
114 |
||
3235 | 115 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 116 |
instanceVariableNames:'line col1 col2 characters' |
117 |
classVariableNames:'' |
|
118 |
poolDictionaries:'' |
|
119 |
privateIn:EditTextView |
|
3235 | 120 |
! |
121 |
||
3131 | 122 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 123 |
instanceVariableNames:'text' |
124 |
classVariableNames:'' |
|
125 |
poolDictionaries:'' |
|
126 |
privateIn:EditTextView |
|
3131 | 127 |
! |
128 |
||
3130 | 129 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 130 |
instanceVariableNames:'line text' |
131 |
classVariableNames:'' |
|
132 |
poolDictionaries:'' |
|
133 |
privateIn:EditTextView |
|
3130 | 134 |
! |
135 |
||
3402 | 136 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 137 |
instanceVariableNames:'line text' |
138 |
classVariableNames:'' |
|
139 |
poolDictionaries:'' |
|
140 |
privateIn:EditTextView |
|
3402 | 141 |
! |
142 |
||
5689 | 143 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
144 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
|
145 |
selectionEndLine selectionEndCol' |
|
146 |
classVariableNames:'' |
|
147 |
poolDictionaries:'' |
|
148 |
privateIn:EditTextView |
|
149 |
! |
|
150 |
||
865 | 151 |
!EditTextView class methodsFor:'documentation'! |
0 | 152 |
|
33 | 153 |
copyright |
154 |
" |
|
155 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 156 |
All Rights Reserved |
33 | 157 |
|
158 |
This software is furnished under a license and may be used |
|
159 |
only in accordance with the terms of that license and with the |
|
160 |
inclusion of the above copyright notice. This software may not |
|
161 |
be provided or otherwise made available to, or used by, any |
|
162 |
other person. No title to or ownership of the software is |
|
163 |
hereby transferred. |
|
164 |
" |
|
165 |
! |
|
166 |
||
0 | 167 |
documentation |
168 |
" |
|
169 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 170 |
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
|
171 |
acceptAction to be performed for accept |
125 | 172 |
|
173 |
If used with a model, this is informed by sending it a changeMsg with |
|
174 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
175 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 176 |
|
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
|
177 |
Please read the historic notice in the ListView class. |
0 | 178 |
|
586 | 179 |
[Instance variables:] |
0 | 180 |
|
4010 | 181 |
cursorLine <Number> line where cursor sits (1..) |
182 |
||
183 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
184 |
||
185 |
cursorCol <Number> col where cursor sits (1..) |
|
186 |
||
187 |
cursorShown <Boolean> true, if cursor is currently shown |
|
188 |
||
189 |
readOnly <Boolean> true, if text may not be edited |
|
190 |
||
191 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
192 |
cleared on accept. |
|
193 |
||
194 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
195 |
||
196 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
197 |
||
198 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
199 |
if it returns true, the modification will be done anyway. |
|
200 |
if it returns anything else, the modification is not done. |
|
201 |
||
202 |
cursorFgColor <Color> color used for cursor drawing |
|
203 |
cursorBgColor <Color> color used for cursor drawing |
|
204 |
||
205 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 206 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 207 |
(vertical bar at insertion point) |
4721 | 208 |
and #caret (caret below insertion-point). |
209 |
see cursorType: for an up-to-date list. |
|
4010 | 210 |
|
211 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
212 |
nil means: hide the cursor. |
|
213 |
||
214 |
undoAction <Block> block which undoes last cut, paste or replace |
|
215 |
(not yet fully implemented) |
|
216 |
||
217 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
218 |
this affects the next keyPress: if #paste it does not |
|
219 |
replace; otherwise it replaces the selection. |
|
220 |
||
221 |
lastCut <String> last cut or replaced string |
|
222 |
||
4053 | 223 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
224 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
225 |
lastReplacement is the string to replace lastStringToReplace |
|
226 |
||
227 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
228 |
(cleared after a new selection) |
|
4010 | 229 |
|
230 |
replacing <Boolean> true if entered characters replace last selection |
|
231 |
||
232 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
233 |
when entering one; this is the default. |
|
234 |
||
235 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
236 |
||
237 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
238 |
argument |
|
239 |
||
240 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
241 |
focus to the next field. For editTextViews, this is false |
|
242 |
by default (i.e. tabs can be entered into the text). |
|
243 |
For some subclasses (inputFields), this may be true. |
|
244 |
||
245 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
246 |
removed when editing. |
|
247 |
Default is true. |
|
248 |
||
249 |
wordWrap <Boolean> Currently not used. |
|
250 |
||
251 |
lockUpdates <Boolean> internal, private |
|
252 |
||
253 |
prevCursorState <Boolean> temporary, private |
|
254 |
||
255 |
cursorMovementWhenUpdating |
|
256 |
<Symbol> defines where the cursor is to be positioned if the |
|
257 |
model changes its value by some outside activity |
|
258 |
(i.e. not by user input into the field). |
|
259 |
Can be one of: |
|
260 |
#keep / nil -> stay where it was |
|
261 |
#endOfText -> cursor to the end |
|
262 |
#endOfLine -> stay in the line, but move to end |
|
263 |
#beginOfText -> cursor to the beginning |
|
264 |
#beginOfLine -> stay in the line, but move to begin |
|
265 |
The default is #beginOfText |
|
266 |
||
267 |
||
268 |
||
269 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 270 |
|
271 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
272 |
userPreference values: |
4010 | 273 |
userPreferences.st80EditMode |
274 |
<Boolean> if true, cursor positioning is |
|
275 |
done as in vi or ST80; i.e. |
|
276 |
wysiwyg mode is somewhat relaxed, |
|
277 |
in that the cursor cannot be |
|
278 |
positioned behind a lines end. |
|
279 |
This is not yet completely implemented. |
|
33 | 280 |
used globals: |
281 |
||
4010 | 282 |
DeleteHistory <Text> last 1000 lines of deleted text |
283 |
(but only if this variable exists already) |
|
586 | 284 |
|
285 |
[styleSheet parameters:] |
|
121 | 286 |
|
4010 | 287 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
288 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
289 |
textCursorNoFocusForegroundColor |
|
290 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
291 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 292 |
|
293 |
[author:] |
|
4010 | 294 |
Claus Gittinger |
586 | 295 |
|
296 |
[see also:] |
|
4010 | 297 |
CodeView Workspace TextView ListView |
298 |
EditField |
|
0 | 299 |
" |
297
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 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
305 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
306 |
basic setup: |
4823 | 307 |
[exBegin] |
308 |
|top textView| |
|
309 |
||
310 |
top := StandardSystemView new. |
|
311 |
top extent:300@200. |
|
312 |
||
313 |
textView := EditTextView new. |
|
314 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
315 |
top addSubView:textView. |
|
316 |
||
317 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
318 |
||
319 |
top open. |
|
320 |
[exEnd] |
|
594 | 321 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
322 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
323 |
with vertical scrollbar: |
4823 | 324 |
[exBegin] |
325 |
|top scrollView textView| |
|
326 |
||
327 |
top := StandardSystemView new. |
|
328 |
top extent:300@200. |
|
329 |
||
330 |
scrollView := ScrollableView for:EditTextView. |
|
331 |
textView := scrollView scrolledView. |
|
332 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
333 |
top addSubView:scrollView. |
|
334 |
||
335 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
336 |
||
337 |
top open. |
|
338 |
[exEnd] |
|
594 | 339 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
340 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
341 |
with horizontal & vertical scrollbars: |
4823 | 342 |
[exBegin] |
343 |
|top scrollView textView| |
|
344 |
||
345 |
top := StandardSystemView new. |
|
346 |
top extent:300@200. |
|
347 |
||
348 |
scrollView := HVScrollableView for:EditTextView. |
|
349 |
textView := scrollView scrolledView. |
|
350 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
351 |
top addSubView:scrollView. |
|
352 |
||
353 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
354 |
||
355 |
top open. |
|
356 |
[exEnd] |
|
297
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 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
359 |
set the action for accept: |
4823 | 360 |
[exBegin] |
361 |
|top textView| |
|
362 |
||
363 |
top := StandardSystemView new. |
|
364 |
top extent:300@200. |
|
365 |
||
366 |
textView := EditTextView new. |
|
367 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
368 |
top addSubView:textView. |
|
369 |
||
370 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
371 |
textView acceptAction:[:contents | |
|
372 |
Transcript showCR:'will not overwrite the file with:'. |
|
373 |
Transcript showCR:contents asString |
|
374 |
]. |
|
375 |
top open. |
|
376 |
[exEnd] |
|
594 | 377 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
378 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
379 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
380 |
non-string (text) items: |
4823 | 381 |
[exBegin] |
382 |
|top textView list| |
|
383 |
||
384 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
385 |
1 to:list size by:2 do:[:nr | |
|
386 |
list at:nr put:(Text string:(list at:nr) |
|
387 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
388 |
]. |
|
389 |
||
390 |
top := StandardSystemView new. |
|
391 |
top extent:300@200. |
|
392 |
||
393 |
textView := EditTextView new. |
|
394 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
395 |
top addSubView:textView. |
|
396 |
||
397 |
textView contents:list. |
|
398 |
top open. |
|
399 |
[exEnd] |
|
629
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 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
402 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
403 |
MVC operation: |
594 | 404 |
(the examples model here is a plug simulating a real model; |
405 |
real world applications would not use a plug ..) |
|
4823 | 406 |
[exBegin] |
407 |
|top textView model| |
|
408 |
||
409 |
model := Plug new. |
|
410 |
model respondTo:#accepted: |
|
411 |
with:[:newContents | |
|
412 |
Transcript showCR:'will not overwrite the file with:'. |
|
413 |
Transcript showCR:newContents asString |
|
414 |
]. |
|
415 |
model respondTo:#getList |
|
416 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
417 |
||
418 |
||
419 |
top := StandardSystemView new. |
|
420 |
top extent:300@200. |
|
421 |
||
422 |
textView := EditTextView new. |
|
423 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
424 |
top addSubView:textView. |
|
425 |
||
426 |
textView listMessage:#getList; |
|
427 |
model:model; |
|
428 |
changeMessage:#accepted:; |
|
429 |
aspect:#list. |
|
430 |
top open. |
|
431 |
[exEnd] |
|
594 | 432 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
433 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
434 |
two textViews on the same model: |
4823 | 435 |
[exBegin] |
436 |
|top1 textView1 top2 textView2 model currentContents| |
|
437 |
||
438 |
model := Plug new. |
|
439 |
model respondTo:#accepted: |
|
440 |
with:[:newContents | |
|
441 |
Transcript showCR:'accepted:'. |
|
442 |
Transcript showCR:newContents asString. |
|
443 |
currentContents := newContents. |
|
444 |
model changed:#contents |
|
445 |
]. |
|
446 |
model respondTo:#getList |
|
447 |
with:[Transcript showCR:'query'. |
|
448 |
currentContents]. |
|
449 |
||
450 |
||
451 |
top1 := StandardSystemView new. |
|
452 |
top1 extent:300@200. |
|
453 |
||
454 |
textView1 := EditTextView new. |
|
455 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
456 |
top1 addSubView:textView1. |
|
457 |
||
458 |
textView1 listMessage:#getList; |
|
459 |
model:model; |
|
460 |
aspect:#contents; |
|
461 |
changeMessage:#accepted:. |
|
462 |
top1 open. |
|
463 |
||
464 |
top2 := StandardSystemView new. |
|
465 |
top2 extent:300@200. |
|
466 |
||
467 |
textView2 := EditTextView new. |
|
468 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
469 |
top2 addSubView:textView2. |
|
470 |
||
471 |
textView2 listMessage:#getList; |
|
472 |
model:model; |
|
473 |
aspect:#contents; |
|
474 |
changeMessage:#accepted:. |
|
475 |
top2 open. |
|
476 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
477 |
" |
4978
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 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
480 |
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
|
481 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
482 |
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
|
483 |
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
|
484 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
485 |
* 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
|
486 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
487 |
* 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
|
488 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
489 |
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
|
490 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
491 |
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
|
492 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
(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
|
496 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
497 |
* 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
|
498 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
499 |
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
|
500 |
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
|
501 |
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
|
502 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
(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
|
506 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
507 |
* 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
|
508 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
513 |
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
|
514 |
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
|
515 |
(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
|
516 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
517 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
518 |
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
|
519 |
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
|
520 |
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
|
521 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
522 |
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
|
523 |
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
|
524 |
(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
|
525 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
526 |
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
|
527 |
UserPreferences current selectionExtensionMode |
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 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
530 |
* 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
|
531 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
532 |
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
|
533 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
534 |
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
|
535 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
536 |
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
|
537 |
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
|
538 |
(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
|
539 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
540 |
" |
0 | 541 |
! ! |
542 |
||
865 | 543 |
!EditTextView class methodsFor:'defaults'! |
59 | 544 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
545 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
546 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
547 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
548 |
"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
|
549 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
550 |
|
1419 | 551 |
st80Mode |
552 |
"return true, if the st80 editing mode is turned on. |
|
553 |
This setting affects the behavior of the cursor, when positioned |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
554 |
beyond the end of a line or the end of the text." |
1419 | 555 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
556 |
^ UserPreferences current st80EditMode |
1419 | 557 |
|
558 |
" |
|
559 |
EditTextView st80Mode:true |
|
560 |
EditTextView st80Mode:false |
|
561 |
" |
|
562 |
||
563 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
564 |
! |
|
565 |
||
566 |
st80Mode:aBoolean |
|
567 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 568 |
beyond the end of a line or the last line" |
1419 | 569 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
570 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 571 |
|
572 |
" |
|
573 |
EditTextView st80Mode:true |
|
574 |
EditTextView st80Mode:false |
|
575 |
" |
|
576 |
||
577 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
578 |
! |
|
579 |
||
59 | 580 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
581 |
"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
|
582 |
|
1390 | 583 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 584 |
#'textCursor.noFocusForegroundColor' |
585 |
#'textCursor.type' |
|
586 |
#'textCursor.typeNoFocus' |
|
587 |
#'editText.st80Mode')> |
|
1355 | 588 |
|
589 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
590 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
591 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
592 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
593 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
594 |
|
1419 | 595 |
" |
596 |
self updateStyleCache |
|
597 |
" |
|
598 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
599 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 600 |
! ! |
601 |
||
3431 | 602 |
!EditTextView class methodsFor:'specs'! |
603 |
||
604 |
searchReplaceDialogSpec |
|
605 |
"This resource specification was automatically generated |
|
606 |
by the UIPainter of ST/X." |
|
607 |
||
608 |
"Do not manually edit this!! If it is corrupted, |
|
609 |
the UIPainter may not be able to read the specification." |
|
610 |
||
611 |
" |
|
612 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
613 |
" |
|
614 |
||
615 |
<resource: #canvas> |
|
616 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
617 |
^ |
3431 | 618 |
#(FullSpec |
4823 | 619 |
name: searchReplaceDialogSpec |
620 |
window: |
|
3431 | 621 |
(WindowSpec |
4823 | 622 |
label: 'String Search and Replace' |
623 |
name: 'String Search and Replace' |
|
624 |
min: (Point 283 196) |
|
625 |
max: (Point 283 196) |
|
626 |
bounds: (Rectangle 0 0 279 192) |
|
627 |
) |
|
628 |
component: |
|
3431 | 629 |
(SpecCollection |
4823 | 630 |
collection: ( |
631 |
(LabelSpec |
|
632 |
label: 'Search Pattern:' |
|
633 |
name: 'label' |
|
634 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
635 |
level: 0 |
|
636 |
translateLabel: true |
|
637 |
adjust: left |
|
638 |
) |
|
639 |
(ComboBoxSpec |
|
640 |
name: 'patternComboBox' |
|
641 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
642 |
tabable: true |
|
643 |
model: searchPattern |
|
644 |
immediateAccept: false |
|
645 |
acceptOnLeave: true |
|
646 |
acceptOnReturn: true |
|
647 |
acceptOnTab: true |
|
648 |
acceptOnLostFocus: true |
|
649 |
acceptOnPointerLeave: false |
|
650 |
autoSelectInitialText: true |
|
651 |
comboList: patternList |
|
652 |
) |
|
653 |
(ComboBoxSpec |
|
654 |
name: 'replaceComboBox' |
|
655 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
656 |
tabable: true |
|
657 |
model: replacePattern |
|
658 |
immediateAccept: false |
|
659 |
acceptOnLeave: true |
|
660 |
acceptOnReturn: true |
|
661 |
acceptOnTab: true |
|
662 |
acceptOnLostFocus: true |
|
663 |
acceptOnPointerLeave: false |
|
664 |
autoSelectInitialText: true |
|
665 |
comboList: patternList |
|
666 |
) |
|
667 |
(CheckBoxSpec |
|
668 |
label: 'Ignore Case' |
|
669 |
name: 'ignoreCaseCheckBox' |
|
670 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
671 |
level: 0 |
|
672 |
tabable: true |
|
673 |
model: ignoreCase |
|
674 |
translateLabel: true |
|
675 |
) |
|
676 |
(VariableVerticalPanelSpec |
|
677 |
name: 'VariableVerticalPanel1' |
|
678 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
679 |
component: |
|
680 |
(SpecCollection |
|
681 |
collection: ( |
|
682 |
(HorizontalPanelViewSpec |
|
683 |
name: 'HorizontalPanel1' |
|
684 |
level: 0 |
|
685 |
horizontalLayout: fitSpace |
|
686 |
verticalLayout: center |
|
687 |
horizontalSpace: 3 |
|
688 |
verticalSpace: 3 |
|
689 |
ignoreInvisibleComponents: true |
|
690 |
reverseOrderIfOKAtLeft: true |
|
691 |
component: |
|
692 |
(SpecCollection |
|
693 |
collection: ( |
|
694 |
(ActionButtonSpec |
|
695 |
label: 'Replace' |
|
696 |
name: 'replaceButton' |
|
697 |
level: 2 |
|
698 |
translateLabel: true |
|
699 |
tabable: true |
|
700 |
model: replaceAction |
|
701 |
extent: (Point 134 21) |
|
702 |
) |
|
703 |
(ActionButtonSpec |
|
704 |
label: 'Replace All' |
|
705 |
name: 'replaceAllButton' |
|
706 |
level: 2 |
|
707 |
borderWidth: 1 |
|
708 |
translateLabel: true |
|
709 |
tabable: true |
|
710 |
model: replaceAllAction |
|
711 |
extent: (Point 134 21) |
|
712 |
) |
|
713 |
) |
|
714 |
||
715 |
) |
|
716 |
) |
|
717 |
(HorizontalPanelViewSpec |
|
718 |
name: 'horizontalPanelView' |
|
719 |
level: 0 |
|
720 |
horizontalLayout: fitSpace |
|
721 |
verticalLayout: center |
|
722 |
horizontalSpace: 3 |
|
723 |
verticalSpace: 3 |
|
724 |
ignoreInvisibleComponents: true |
|
725 |
reverseOrderIfOKAtLeft: true |
|
726 |
component: |
|
727 |
(SpecCollection |
|
728 |
collection: ( |
|
729 |
(ActionButtonSpec |
|
730 |
label: 'Cancel' |
|
731 |
name: 'cancelButton' |
|
732 |
level: 2 |
|
733 |
translateLabel: true |
|
734 |
tabable: true |
|
735 |
model: cancel |
|
736 |
extent: (Point 88 21) |
|
737 |
) |
|
738 |
(ActionButtonSpec |
|
739 |
label: 'Prev' |
|
740 |
name: 'prevButton' |
|
741 |
level: 2 |
|
742 |
translateLabel: true |
|
743 |
tabable: true |
|
744 |
model: prevAction |
|
745 |
extent: (Point 89 21) |
|
746 |
) |
|
747 |
(ActionButtonSpec |
|
748 |
label: 'Next' |
|
749 |
name: 'nextButton' |
|
750 |
level: 2 |
|
751 |
borderWidth: 1 |
|
752 |
translateLabel: true |
|
753 |
tabable: true |
|
754 |
model: nextAction |
|
755 |
isDefault: true |
|
756 |
extent: (Point 88 21) |
|
757 |
) |
|
758 |
) |
|
759 |
||
760 |
) |
|
761 |
) |
|
762 |
) |
|
763 |
||
764 |
) |
|
765 |
handles: (Any 0.5 1.0) |
|
766 |
) |
|
767 |
(LabelSpec |
|
768 |
label: 'Replace By:' |
|
769 |
name: 'ReplaceLabel' |
|
770 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
771 |
level: 0 |
|
772 |
translateLabel: true |
|
773 |
adjust: left |
|
774 |
) |
|
775 |
) |
|
776 |
||
777 |
) |
|
3431 | 778 |
) |
779 |
||
780 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
781 |
! ! |
|
782 |
||
2744 | 783 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
784 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
785 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
786 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
787 |
|
2019 | 788 |
"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
|
789 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
790 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
791 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
792 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
793 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
794 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
795 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
796 |
|
1390 | 797 |
cutSelection |
798 |
self cut |
|
799 |
||
800 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
801 |
! |
|
802 |
||
1590 | 803 |
deselect |
804 |
"remove the selection" |
|
805 |
||
806 |
^ self unselect |
|
807 |
||
808 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
809 |
! |
|
810 |
||
2101 | 811 |
enabled:aBoolean |
812 |
||
813 |
self readOnly:aBoolean not |
|
814 |
||
815 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
816 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
817 |
! |
|
818 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
819 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
820 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
821 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
822 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
823 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
824 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
825 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
826 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
827 |
"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
|
828 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
829 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
830 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
831 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
832 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
833 |
col < 1 ifTrue:[ |
4823 | 834 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
835 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
836 |
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
|
837 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
838 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
839 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
840 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
841 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
842 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
843 |
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
|
844 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
845 |
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
|
846 |
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
|
847 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
848 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
849 |
"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
|
850 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
851 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
852 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
853 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
854 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
855 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
857 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 858 |
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
|
859 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
860 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 861 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
862 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
863 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
864 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
865 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
866 |
v insertAndSelect:'<- hello there' at:5. |
125 | 867 |
" |
1390 | 868 |
! |
869 |
||
870 |
pasteSelection |
|
871 |
self paste |
|
872 |
||
873 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 874 |
! |
875 |
||
876 |
replaceSelectionWith:aString |
|
877 |
^ self replaceSelectionBy:aString |
|
878 |
||
879 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
880 |
! |
|
881 |
||
882 |
selectAt:pos |
|
883 |
"move the cursor before cursorPosition." |
|
884 |
||
885 |
self cursorToCharacterPosition:pos |
|
886 |
||
887 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
888 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
889 |
! |
|
890 |
||
2101 | 891 |
textHasChanged |
892 |
^ self modified |
|
893 |
||
894 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
895 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
896 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
897 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
898 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
899 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
900 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
901 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
902 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
903 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
904 |
|
4585 | 905 |
!EditTextView methodsFor:'accessing'! |
906 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
908 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
909 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
910 |
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
|
911 |
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
|
912 |
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
|
913 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
914 |
"/ 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
|
915 |
"/ 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
|
916 |
^((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
|
917 |
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
|
918 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
919 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
920 |
"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
|
921 |
! |
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: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
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
|
925 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
926 |
"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
|
927 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
928 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
929 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
930 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
931 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
932 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
933 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
934 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
935 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
936 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
937 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
938 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
939 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
940 |
"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
|
941 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
942 |
|
4609 | 943 |
editedClass |
944 |
|cm| |
|
945 |
||
946 |
cm := self editedMethodOrClass. |
|
947 |
cm isBehavior ifTrue:[^ cm]. |
|
948 |
cm isMethod ifTrue:[^ cm mclass]. |
|
949 |
^ nil |
|
950 |
! |
|
951 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
952 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
953 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
954 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
955 |
"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
|
956 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
957 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
958 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
959 |
"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
|
960 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
961 |
"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
|
962 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
963 |
|
4609 | 964 |
editedMethod |
965 |
|cm| |
|
966 |
||
967 |
cm := self editedMethodOrClass. |
|
968 |
cm isMethod ifTrue:[^ cm]. |
|
969 |
cm isBehavior ifTrue:[^ nil]. |
|
970 |
^ nil |
|
971 |
! |
|
972 |
||
973 |
editedMethodOrClass |
|
974 |
^ nil |
|
975 |
! |
|
976 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
977 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
978 |
"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
|
979 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
980 |
"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
|
981 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
982 |
|
4585 | 983 |
hasSelectionOrTextInCursorLine |
984 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
985 |
! |
|
986 |
||
4589 | 987 |
selectionOrTextOfCursorLine |
988 |
^ self selectionOrTextOfCursorLine:true |
|
989 |
! |
|
990 |
||
4585 | 991 |
selectionOrTextOfCursorLine:doSelect |
992 |
|sel lNr line| |
|
993 |
||
994 |
sel := self selectionAsString. |
|
995 |
sel notNil ifTrue:[^ sel]. |
|
996 |
||
997 |
lNr := self cursorLine. |
|
998 |
line := self listAt:lNr. |
|
999 |
line notEmptyOrNil ifTrue:[ |
|
1000 |
doSelect ifTrue:[ |
|
1001 |
self selectLine:lNr. |
|
1002 |
]. |
|
1003 |
^ line |
|
1004 |
]. |
|
1005 |
||
1006 |
^ nil |
|
1007 |
! ! |
|
1008 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1009 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1010 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1011 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1012 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1013 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1014 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1015 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1016 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1017 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1018 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1019 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1020 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1021 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1022 |
|
2792 | 1023 |
acceptChannel |
1024 |
"return the valueHolder holding true if text was accepted. |
|
1025 |
By placing a true into this channel, an accept can also be forced." |
|
1026 |
||
1027 |
^ acceptChannel |
|
1028 |
||
1029 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1030 |
! |
|
1031 |
||
1032 |
acceptChannel:aValueHolder |
|
1033 |
"set the valueHolder holding true if text was accepted. |
|
1034 |
By placing a true into this channel, an accept can also be forced." |
|
1035 |
||
1036 |
|prev| |
|
1037 |
||
1038 |
prev := acceptChannel. |
|
1039 |
acceptChannel := aValueHolder. |
|
1040 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1041 |
||
1042 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1043 |
! |
|
1044 |
||
1108 | 1045 |
acceptEnabled:aBoolean |
1046 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1047 |
||
1048 |
acceptEnabled := aBoolean |
|
1049 |
||
1050 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1051 |
! |
|
1052 |
||
2792 | 1053 |
accepted |
1054 |
"return true if text was accepted" |
|
1055 |
||
1056 |
^ acceptChannel value |
|
1057 |
||
1058 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1059 |
! |
|
1060 |
||
1061 |
accepted:aBoolean |
|
1062 |
"set/clear the accepted flag. |
|
1063 |
This may force my current contents to be placed into my model." |
|
1064 |
||
1065 |
acceptChannel value:aBoolean. |
|
1066 |
||
1067 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1068 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1069 |
! |
|
1070 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1071 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1072 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1073 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1074 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1075 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1076 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1077 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1078 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1079 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1080 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1081 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1082 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1083 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1084 |
|
2774 | 1085 |
cursorMovementWhenUpdating |
3160 | 1086 |
"return what is be done with the cursor, |
2774 | 1087 |
when I get a new text (via the model or the #contents/#list) |
1088 |
Allowed arguments are: |
|
4823 | 1089 |
#keep / nil -> stay where it was |
1090 |
#endOfText -> position cursor to the end |
|
1091 |
#beginOfText -> position cursor to the beginning |
|
1092 |
#endOfLine -> position cursor to the current lines end |
|
1093 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1094 |
The default is #beginOfText. |
1095 |
This may be useful for fields which get new values assigned from |
|
1096 |
the program (i.e. not from the user)" |
|
1097 |
||
1098 |
^ cursorMovementWhenUpdating |
|
1099 |
||
1100 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1101 |
! |
|
1102 |
||
2133 | 1103 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1104 |
"define what should be done with the cursor, |
2133 | 1105 |
when I get a new text (via the model or the #contents/#list) |
1106 |
Allowed arguments are: |
|
4823 | 1107 |
#keep / nil -> stay where it was |
1108 |
#endOfText -> position cursor to the end |
|
1109 |
#beginOfText -> position cursor to the beginning |
|
1110 |
#endOfLine -> position cursor to the current lines end |
|
1111 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1112 |
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
|
1113 |
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
|
1114 |
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
|
1115 |
|
2133 | 1116 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1117 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1118 |
"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
|
1119 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1120 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1121 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1122 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1123 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1124 |
|
2438 | 1125 |
dontReplaceSelectionOnInput |
4742 | 1126 |
"remember that the current selection was created by a paste operation |
1127 |
(as opposed to an explicit selection by the user). |
|
1128 |
This selection will not be replaced by followup user input, |
|
1129 |
so multiple pastes will be possible." |
|
1130 |
||
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
|
1131 |
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
|
1132 |
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
|
1133 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1134 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1135 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1136 |
! |
1137 |
||
3235 | 1138 |
editModeHolder |
1139 |
^ editMode. |
|
1140 |
! |
|
1141 |
||
1142 |
editModeInsert |
|
1143 |
editMode value:EditMode insertMode |
|
1144 |
! |
|
1145 |
||
1146 |
editModeInsertAndSelect |
|
1147 |
editMode value:EditMode insertAndSelectMode |
|
1148 |
! |
|
1149 |
||
1150 |
editModeOverwrite |
|
1151 |
editMode value:EditMode overwriteMode |
|
1152 |
! |
|
1153 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1154 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1155 |
"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
|
1156 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1157 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1158 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1159 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1160 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1161 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1162 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1163 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1164 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1165 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1166 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1167 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1168 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1169 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1170 |
readOnly == true ifFalse:[ |
4823 | 1171 |
readOnly := true. |
1172 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1173 |
menu disableAll:#(cut paste replace indent) |
|
1174 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1175 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1176 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1177 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1178 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1179 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1180 |
insertMode:aBoolean |
3235 | 1181 |
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
|
1182 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1183 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1184 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1185 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1186 |
insertModeHolder |
3235 | 1187 |
^ BlockValue |
4823 | 1188 |
with:[:m | m isInsertMode] |
1189 |
argument:(editMode). |
|
3465 | 1190 |
|
1191 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1192 |
! |
1193 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1194 |
isInInsertMode |
3235 | 1195 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1196 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1197 |
|
5216 | 1198 |
isNotReadOnly |
1199 |
"return true, if the text is not readonly." |
|
1200 |
||
1201 |
^ self isReadOnly not |
|
1202 |
! |
|
1203 |
||
2792 | 1204 |
isReadOnly |
1205 |
"return true, if the text is readonly." |
|
1206 |
||
1207 |
^ readOnly value |
|
1208 |
||
1209 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1210 |
! |
|
1211 |
||
2796 | 1212 |
modeLabelHolder |
1213 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1214 |
||
3160 | 1215 |
^ BlockValue |
4041 | 1216 |
with:[:e :l | |
1217 |
self isReadOnly ifTrue:[ |
|
1218 |
'' |
|
1219 |
] ifFalse:[ |
|
5724 | 1220 |
l ifTrue:[ 'L' allBold withColor:#red] |
4041 | 1221 |
ifFalse:[ e infoPrintString]]] |
1222 |
argument:(self editModeHolder) |
|
1223 |
argument:(self learnModeHolder). |
|
3465 | 1224 |
|
1225 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1226 |
! |
1227 |
||
2792 | 1228 |
modified |
1229 |
"return true if text was modified" |
|
1230 |
||
1231 |
^ modifiedChannel value |
|
1232 |
! |
|
1233 |
||
1234 |
modified:aBoolean |
|
1235 |
"set/clear the modified flag" |
|
1236 |
||
1237 |
modifiedChannel value:aBoolean |
|
1238 |
||
1239 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1240 |
! |
|
1241 |
||
1242 |
modifiedChannel |
|
1243 |
"return the valueHolder holding true if text was modified" |
|
1244 |
||
1245 |
^ modifiedChannel |
|
1246 |
! |
|
1247 |
||
1248 |
modifiedChannel:aValueHolder |
|
1249 |
"set the valueHolder holding true if text was modified" |
|
1250 |
||
1251 |
|prev| |
|
1252 |
||
1253 |
prev := modifiedChannel. |
|
1254 |
modifiedChannel := aValueHolder. |
|
1255 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1256 |
||
1257 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1258 |
! |
|
1259 |
||
1260 |
readOnly |
|
1261 |
"make the text readonly. |
|
4664 | 1262 |
Obsolete because it is obfuscating (looks like a getter) |
1263 |
- use #readOnly:" |
|
2792 | 1264 |
|
1265 |
<resource:#obsolete> |
|
1266 |
||
1267 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1268 |
self readOnly:true. |
2792 | 1269 |
|
4664 | 1270 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1271 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1272 |
! |
1273 |
||
1274 |
readOnly:aBoolean |
|
1275 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1276 |
The argument may also be a valueHolder." |
|
1277 |
||
1278 |
readOnly := aBoolean |
|
1279 |
||
1280 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1281 |
! |
|
1282 |
||
4782 | 1283 |
reallyModifiedChannel |
1284 |
"return the valueHolder holding true if text was really modified. |
|
1285 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1286 |
||
1287 |
^ self modifiedChannel |
|
1288 |
! |
|
1289 |
||
5255 | 1290 |
st80Mode:aBooleanOrNil |
4192 | 1291 |
"set/clear the st80Mode flag. |
1292 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1293 |
if off, we have the Rand-editor behavior (random access) |
1294 |
if nil, the setting follows the current userPref setting." |
|
1295 |
||
1296 |
st80Mode := aBooleanOrNil |
|
4192 | 1297 |
|
1298 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1299 |
! |
|
1300 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1301 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1302 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1303 |
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
|
1304 |
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
|
1305 |
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
|
1306 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1307 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1308 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1309 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1310 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1311 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1312 |
"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
|
1313 |
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
|
1314 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1315 |
|
3160 | 1316 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1317 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1318 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1319 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1320 |
"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
|
1321 |
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
|
1322 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1323 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1324 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1325 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1326 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1327 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1328 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1329 |
at:lineNr basicPut:aLine |
5413 | 1330 |
"change a line without change notification. |
1331 |
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
|
1332 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1333 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1334 |
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
|
1335 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1336 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1337 |
|
522 | 1338 |
at:lineNr put:aLine |
5413 | 1339 |
"replace a line by something new. |
1340 |
this is not undoably, unless you care for yourself" |
|
1341 |
||
5393 | 1342 |
|oldLine| |
1343 |
||
1344 |
oldLine := (self at:lineNr) ? ''. |
|
1345 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1346 |
super at:lineNr put:aLine. |
1347 |
self textChanged |
|
522 | 1348 |
]. |
1349 |
! |
|
1350 |
||
4700 | 1351 |
characterAfterCursor |
1352 |
"return the character one after the cursor - space if beyond line." |
|
1353 |
||
1354 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1355 |
! |
|
1356 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1357 |
characterBeforeCursor |
4700 | 1358 |
"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
|
1359 |
|
5142 | 1360 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1361 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1362 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1363 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1364 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1365 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1366 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1367 |
characterUnderCursor |
2707 | 1368 |
"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
|
1369 |
For non-block cursors, this is the character immediately to the right |
5413 | 1370 |
of the insertion-bar or caret. |
1371 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1372 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1373 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1374 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1376 |
contents |
2213 | 1377 |
"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
|
1378 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1379 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1380 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1381 |
^ super contents. |
3313 | 1382 |
|
1383 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1384 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1385 |
|
5413 | 1386 |
contents:aStringOrStringCollectionOrNil |
1387 |
"replace the whole contents by something new. |
|
5414 | 1388 |
this is not undoably, unless you care for yourself. |
1389 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1390 |
|
1391 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1392 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1393 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1394 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1395 |
"set the contents and optionally clear the undo history. |
1396 |
The contents-change is not undoable." |
|
1397 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1398 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1399 |
keepUndoHistory ifFalse:[ |
4823 | 1400 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1401 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1402 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1403 |
|
2213 | 1404 |
contentsAsString |
1405 |
"return the contents as a String (i.e. without emphasis)" |
|
1406 |
||
1407 |
list isNil ifTrue:[^ '']. |
|
1408 |
self removeTrailingBlankLines. |
|
1409 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1410 |
ifFalse:[each string] |
1411 |
]) asStringWithCRs |
|
2213 | 1412 |
! |
1413 |
||
5067 | 1414 |
contentsAsStringWithTabs |
1415 |
"return the contents as a String (i.e. without emphasis) |
|
1416 |
and with leading spaces replaced by tab characters |
|
1417 |
(i.e. as would be written to a file)" |
|
1418 |
||
1419 |
list isNil ifTrue:[^ '']. |
|
1420 |
self removeTrailingBlankLines. |
|
1421 |
^ (list collect:[:each | |
|
1422 |
each isNil |
|
1423 |
ifTrue:[''] |
|
1424 |
ifFalse:[each string withTabs] |
|
1425 |
]) asStringWithCRs |
|
1426 |
! |
|
1427 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1428 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1429 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1430 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1431 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1432 |
^ cursorCol |
125 | 1433 |
! |
1434 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1435 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1436 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1437 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1438 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1439 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1440 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
cursorLine |
3160 | 1442 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1443 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1444 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1445 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1446 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1447 |
|
5400 | 1448 |
cursorLineAndColumnLabelHolder |
5399 | 1449 |
"return a valueHolder for the cursors line and column as an info string |
1450 |
of the form 'line : col'. |
|
1451 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1452 |
||
1453 |
^ BlockValue |
|
1454 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1455 |
argument:self cursorLineHolder |
|
1456 |
argument:self cursorColHolder |
|
1457 |
! |
|
1458 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1459 |
cursorLineHolder |
3160 | 1460 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1461 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1462 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1463 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1464 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1465 |
|
4713 | 1466 |
lineStringBeforeCursor |
1467 |
"return the line's string before the cursor. |
|
1468 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1469 |
||
1470 |
|line| |
|
1471 |
||
1472 |
line := ((self at:cursorLine) ? '') string. |
|
1473 |
line size < (cursorCol-1) ifTrue:[ |
|
1474 |
^ line paddedTo:(cursorCol-1) |
|
1475 |
]. |
|
1476 |
^ line copyTo:(cursorCol-1) |
|
1477 |
! |
|
1478 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1479 |
list:something |
5413 | 1480 |
"replace the whole contents by something new. |
1481 |
this is not undoably, unless you care for yourself. |
|
1482 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1483 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1484 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1485 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1486 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1487 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1488 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1489 |
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
|
1490 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1491 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1492 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1493 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1494 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1495 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1496 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1497 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1498 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1499 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1500 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1501 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1502 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1503 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1504 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1505 |
^ 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
|
1506 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1507 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1508 |
"/ 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
|
1509 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1510 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1511 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1512 |
setContents:something |
5413 | 1513 |
"replace the whole contents by something new |
1514 |
AND clear the remembered undo actions" |
|
1515 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1516 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1517 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1518 |
undoSupport resetHistories. |
2955 | 1519 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1520 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1521 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1522 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1523 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1524 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1525 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1526 |
|
4609 | 1527 |
!EditTextView methodsFor:'accessing-dimensions'! |
1528 |
||
1529 |
xOfCursor |
|
4728 | 1530 |
|point| |
1531 |
||
1532 |
cursorVisibleLine isNil ifTrue:[ |
|
1533 |
"/ take the end of the selection, if any |
|
1534 |
(selectionStartLine notNil |
|
1535 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1536 |
ifTrue:[ |
|
1537 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1538 |
]. |
|
1539 |
||
1540 |
"/ point := device |
|
1541 |
"/ translatePoint:(device pointerPosition) |
|
1542 |
"/ fromView:nil |
|
1543 |
"/ toView:self. |
|
1544 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1545 |
"/ ^ point x |
|
1546 |
"/ ]. |
|
1547 |
"/ ^ 0 |
|
1548 |
^ nil |
|
1549 |
]. |
|
4609 | 1550 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1551 |
||
1552 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1553 |
! ! |
|
4590 | 1554 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1555 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1556 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1557 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1558 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1559 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1560 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1561 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1562 |
wasOn := self hideCursor. |
5643 | 1563 |
cursorFgColor := color1 onDevice:device. |
1564 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1565 |
wasOn ifTrue:[self showCursor] |
1333 | 1566 |
! |
1567 |
||
1899 | 1568 |
cursorType |
1569 |
"return the style of the text cursor. |
|
4721 | 1570 |
Currently, supported are: #none |
1571 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1572 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1573 |
|
1574 |
^ cursorType |
|
1575 |
||
1576 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1577 |
! |
|
1578 |
||
1333 | 1579 |
cursorType:aCursorTypeSymbol |
1580 |
"set the style of the text cursor. |
|
4721 | 1581 |
Currently, supported are: #none |
1582 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1583 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1584 |
|
1334 | 1585 |
cursorType := aCursorTypeSymbol. |
1333 | 1586 |
|
1587 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1588 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1589 |
! |
1590 |
||
1899 | 1591 |
cursorTypeNoFocus |
1592 |
"return the style of the text cursor when the view has no focus. |
|
1593 |
If left unspecified, this is the same as the regular cursorType." |
|
1594 |
||
1595 |
^ cursorTypeNoFocus |
|
1596 |
||
1597 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1598 |
! |
|
1599 |
||
1334 | 1600 |
cursorTypeNoFocus:aCursorTypeSymbol |
1601 |
"set the style of the text cursor when the view has no focus. |
|
1602 |
If left unspecified, this is the same as the regular cursorType." |
|
1603 |
||
1604 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1605 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1606 |
|
4048 | 1607 |
!EditTextView methodsFor:'accessing-replace'! |
1608 |
||
4746 | 1609 |
lastReplacementInfo |
1610 |
^ lastReplacementInfo |
|
1611 |
! |
|
1612 |
||
4048 | 1613 |
lastStringToReplace: aString |
4818 | 1614 |
! |
1615 |
||
1616 |
previousReplacements |
|
1617 |
"accessor for the code completion" |
|
1618 |
||
1619 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1620 |
! ! |
1621 |
||
2119 | 1622 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
|
125 | 1624 |
accept |
1625 |
"accept the current contents by executing the accept-action and/or |
|
1626 |
changeMessage." |
|
1627 |
||
1108 | 1628 |
acceptEnabled == false ifTrue:[ |
3945 | 1629 |
self beep. |
1630 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1631 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1632 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1633 |
^ self |
1108 | 1634 |
]. |
1635 |
||
125 | 1636 |
lockUpdates := true. |
1013 | 1637 |
|
1638 |
"/ |
|
1639 |
"/ ST-80 way of doing it |
|
1640 |
"/ |
|
1641 |
model notNil ifTrue:[ |
|
4142 | 1642 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
5525 | 1643 |
acceptChannel notNil ifTrue:[ |
1644 |
acceptChannel value:true withoutNotifying:self. |
|
1645 |
]. |
|
2999 | 1646 |
]. |
1647 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1648 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1649 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1650 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1651 |
"/ 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
|
1652 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1653 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1654 |
acceptAction notNil ifTrue:[ |
3945 | 1655 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1656 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1657 |
|
125 | 1658 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1659 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1660 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1661 |
! |
1662 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1663 |
argForChangeMessage |
597 | 1664 |
"return the argument to be passed with the change notification. |
1665 |
Defined as separate method for easier subclassability." |
|
1666 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1667 |
^ self contents |
597 | 1668 |
|
1669 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1670 |
! |
1671 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1672 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1673 |
"get my contents from the model. |
597 | 1674 |
Redefined to ignore updates resulting from my own changes |
1675 |
(i.e. if lockUpdates is true)." |
|
121 | 1676 |
|
1677 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1678 |
ignore updates from my own change |
121 | 1679 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1680 |
lockUpdates ifTrue:[ |
4823 | 1681 |
lockUpdates := false. |
1682 |
^ self |
|
121 | 1683 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1684 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1685 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1686 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1687 |
"/ validate the cursorLine |
3160 | 1688 |
(cursorLine notNil |
2310 | 1689 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1690 |
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
|
1691 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1692 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1693 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1694 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1695 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1696 |
acceptChannel value == true ifTrue:[ |
1697 |
self accept. |
|
1698 |
]. |
|
1699 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1700 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1701 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1702 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1703 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1704 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1705 |
! ! |
1706 |
||
1707 |
!EditTextView methodsFor:'cursor handling'! |
|
1708 |
||
4820 | 1709 |
basicCursorReturn |
1710 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1711 |
||
1712 |
|wasOn| |
|
1713 |
||
1714 |
self checkForExistingLine:(cursorLine + 1). |
|
1715 |
cursorVisibleLine notNil ifTrue:[ |
|
1716 |
nFullLinesShown notNil ifTrue:[ |
|
1717 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1718 |
] |
|
1719 |
]. |
|
1720 |
||
1721 |
wasOn := self hideCursor. |
|
1722 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1723 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1724 |
||
1725 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1726 |
! |
|
1727 |
||
2406 | 1728 |
characterPositionOfCursor |
1729 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1730 |
! |
|
1731 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1732 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1733 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1734 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1735 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1736 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1737 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1738 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1739 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1740 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1741 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1742 |
|
2822 | 1743 |
(cursorCol == newCol) ifTrue:[^ self]. |
1744 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1745 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1746 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1747 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1748 |
|
1749 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1751 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1752 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1753 |
"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
|
1754 |
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
|
1755 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1756 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1757 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1758 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1759 |
|
2707 | 1760 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1761 |
cursorLine > list size ifTrue:[ |
4595 | 1762 |
wasOn := self hideCursor. |
1763 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1764 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1765 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1766 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1767 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1768 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1770 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1771 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1772 |
"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
|
1773 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1774 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1775 |
|
4595 | 1776 |
(nL := cursorLine) isNil ifTrue:[ |
1777 |
nL := firstLineShown |
|
1778 |
]. |
|
1779 |
||
1780 |
self st80EditMode ifTrue:[ |
|
1781 |
nL == list size ifTrue:[ |
|
1782 |
wasOn := self hideCursor. |
|
1783 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1784 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1785 |
self beep. |
|
1786 |
^ self. |
|
1787 |
] |
|
1788 |
]. |
|
1789 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1790 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1791 |
wasOn := self hideCursor. |
1792 |
nv := cursorVisibleLine + n - 1. |
|
1793 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1794 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1795 |
]. |
|
1796 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1797 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1798 |
] ifFalse:[ |
4595 | 1799 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1800 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1801 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1802 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1803 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1804 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1805 |
|
121 | 1806 |
cursorHome |
597 | 1807 |
"scroll to top AND move cursor to first line of text." |
121 | 1808 |
|
674 | 1809 |
self cursorLine:1 col:1 |
1810 |
||
1811 |
"/ |wasOn| |
|
1812 |
"/ |
|
1813 |
"/ wasOn := self hideCursor. |
|
1814 |
"/ self scrollToTop. |
|
1815 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1816 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1817 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1818 |
||
1819 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1820 |
! |
1821 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1822 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1823 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1824 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1825 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1826 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1827 |
] ifFalse:[ |
4823 | 1828 |
cursorLine ~~ 1 ifTrue:[ |
1829 |
self st80EditMode ifTrue:[ |
|
1830 |
self cursorUp. |
|
1831 |
self cursorToEndOfLine. |
|
1832 |
] |
|
1833 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1834 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1835 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1836 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1837 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1838 |
|
4126 | 1839 |
cursorLeft:n |
1840 |
"move cursor to left" |
|
1841 |
||
1842 |
n timesRepeat:[ |
|
1843 |
self cursorLeft |
|
1844 |
]. |
|
1845 |
! |
|
1846 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1847 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1848 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
|
5056 | 1850 |
self cursorLine:line col:col makeVisible:true |
1851 |
! |
|
1852 |
||
1853 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1854 |
"this positions onto physical - not visible - line" |
|
1855 |
||
676 | 1856 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
|
2822 | 1858 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1859 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1860 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1861 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1862 |
|
672 | 1863 |
(col < 1) ifTrue:[ |
4823 | 1864 |
newCol := 1 |
672 | 1865 |
] ifFalse:[ |
4823 | 1866 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1867 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1868 |
self st80EditMode ifTrue:[ |
4823 | 1869 |
(cursorLine == list size |
1870 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1871 |
newCol := (self listAt:(list size)) size + 1. |
|
1872 |
] |
|
1419 | 1873 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1874 |
self setValidatedCursorCol:newCol. |
5056 | 1875 |
makeVisibleBoolean ifTrue:[ |
1876 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1877 |
] ifFalse:[ |
|
1878 |
wasOn ifTrue:[self showCursor] |
|
1879 |
]. |
|
672 | 1880 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1881 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1882 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1883 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1884 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1885 |
"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
|
1886 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1887 |
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
|
1888 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1889 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1890 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1891 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1892 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1893 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1894 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1895 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1896 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1897 |
"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
|
1898 |
|
4820 | 1899 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1900 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1901 |
|
5529 | 1902 |
cursorReturn:withPossibleAutoIndent |
1903 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1904 |
||
1905 |
self basicCursorReturn |
|
1906 |
! |
|
1907 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1908 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1909 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1910 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1911 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1912 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1913 |
self st80EditMode ifTrue:[ |
4823 | 1914 |
l := (self listAt:cursorLine). |
1915 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 1916 |
cursorLine <= list size ifTrue:[ |
1917 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 1918 |
]. |
1919 |
^ self |
|
1920 |
] |
|
3160 | 1921 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1922 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1923 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1924 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1925 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1926 |
|
4126 | 1927 |
cursorRight:n |
1928 |
"move cursor to right" |
|
1929 |
||
1930 |
n timesRepeat:[ |
|
1931 |
self cursorRight |
|
1932 |
]. |
|
1933 |
! |
|
1934 |
||
1833 | 1935 |
cursorShown:aBoolean |
1936 |
"change cursor visibility |
|
1937 |
return true if cursor was visible before." |
|
1938 |
||
1939 |
|oldState| |
|
1940 |
||
4494 | 1941 |
aBoolean == cursorShown ifTrue:[ |
1942 |
^ cursorShown |
|
1943 |
]. |
|
1833 | 1944 |
oldState := cursorShown. |
1945 |
||
1946 |
aBoolean ifTrue:[ |
|
4494 | 1947 |
self drawCursor. |
1833 | 1948 |
] ifFalse:[ |
4494 | 1949 |
(cursorShown and:[shown]) ifTrue: [ |
1950 |
self undrawCursor. |
|
1951 |
]. |
|
1833 | 1952 |
]. |
1953 |
cursorShown := aBoolean. |
|
1954 |
||
1955 |
^ oldState |
|
1956 |
||
1957 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1958 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1959 |
! |
|
1960 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1961 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1962 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1963 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1964 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1965 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1966 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1967 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1968 |
"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
|
1969 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1970 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1971 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1972 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1973 |
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
|
1974 |
cursorCol > textStart ifTrue:[ |
4823 | 1975 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1976 |
] ifFalse:[ |
4823 | 1977 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1978 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1979 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1980 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1981 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1984 |
"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
|
1985 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1987 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1988 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1989 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1990 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
(newTop < 1) ifTrue:[ |
4823 | 1992 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1993 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1995 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1996 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1997 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1998 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1999 |
|
674 | 2000 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2001 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2002 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2003 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2004 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2005 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2006 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2007 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2008 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2009 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2010 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2011 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2012 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2013 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2014 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2015 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2016 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2017 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2018 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2019 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2020 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2021 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2022 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2023 |
cursorLine >= lineNr ifTrue:[ |
4823 | 2024 |
line := self listAt:cursorLine. |
2025 |
(line isEmptyOrNil) ifTrue:[ |
|
2026 |
^ self |
|
2027 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2028 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2029 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2030 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2031 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2032 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2033 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2034 |
(newTop < 1) ifTrue:[ |
4823 | 2035 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2036 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2037 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2038 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2039 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2040 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2041 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2042 |
|
674 | 2043 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2044 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2045 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2047 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2048 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2049 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2050 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2051 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2052 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2053 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2054 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2055 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2056 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2057 |
cursorToEndOfText |
4288 | 2058 |
"move cursor to the end of the text (behind the last character in last line)" |
2059 |
||
2060 |
|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
|
2061 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2062 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2063 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2064 |
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
|
2065 |
(newTop < 1) ifTrue:[ |
4288 | 2066 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2067 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2068 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2069 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2070 |
self setValidatedCursorLine:list size. |
4288 | 2071 |
lastLineLength := (self listAt:cursorLine) size. |
2072 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2073 |
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
|
2074 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2075 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2076 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2077 |
"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
|
2078 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2079 |
|
3310 | 2080 |
cursorToEndOfWord |
2081 |
"move the cursor to the end of the word" |
|
2082 |
||
2083 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2084 |
||
2085 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2086 |
:beginLine :beginCol :endLine :endCol :style | |
2087 |
||
2088 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2089 |
] |
2090 |
||
2091 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2092 |
! |
|
2093 |
||
131 | 2094 |
cursorToFirstVisibleLine |
2095 |
"place cursor into the first visible line; do not scroll." |
|
2096 |
||
2097 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2098 |
! |
|
2099 |
||
2100 |
cursorToLastVisibleLine |
|
2101 |
"place cursor into the first visible line; do not scroll." |
|
2102 |
||
2103 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2104 |
! |
|
2105 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2106 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2107 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2108 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2112 |
|
3890 | 2113 |
self |
4707 | 2114 |
wordAtLine:cursorLine col:cursorCol |
2115 |
do:[ |
|
3890 | 2116 |
:beginLine :beginCol :endLine :endCol :style | |
2117 |
||
2118 |
line := endLine. |
|
2119 |
col := endCol + 1. |
|
2120 |
searching := true. |
|
4707 | 2121 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2122 |
self wordAtLine:line col:col do:[ |
2123 |
:beginLine :beginCol :endLine :endCol :style | |
|
2124 |
||
2125 |
(line > list size) ifTrue:[ |
|
2126 |
"break out" |
|
2127 |
searching := false |
|
2128 |
] ifFalse:[ |
|
2129 |
line := endLine. |
|
2130 |
col := endCol + 1. |
|
2131 |
] |
|
2132 |
] |
|
2133 |
]. |
|
2134 |
self cursorLine:line col:col |
|
4707 | 2135 |
] |
121 | 2136 |
! |
2137 |
||
499 | 2138 |
cursorToPreviousWord |
2139 |
"move the cursor to the beginning of this or the previous word" |
|
2140 |
||
2141 |
|col line searching l| |
|
2142 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2143 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2144 |
|
2145 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2146 |
:beginLine :beginCol :endLine :endCol :style | |
2147 |
||
2148 |
line := beginLine. |
|
2149 |
col := beginCol. |
|
2150 |
style == #wordLeft ifTrue:[ |
|
2151 |
col := col + 1 |
|
2152 |
]. |
|
2153 |
||
2154 |
(cursorLine == line |
|
2155 |
and:[cursorCol == col]) ifTrue:[ |
|
2156 |
searching := true. |
|
2157 |
||
2158 |
col > 1 ifTrue:[ |
|
2159 |
col := col - 1. |
|
2160 |
]. |
|
2161 |
||
2162 |
[searching] whileTrue:[ |
|
2163 |
(col == 1) ifTrue:[ |
|
2164 |
line == 1 ifTrue:[ |
|
2165 |
searching := false |
|
2166 |
] ifFalse:[ |
|
2167 |
line := line - 1. |
|
2168 |
l := list at:line. |
|
2169 |
col := l size + 1. |
|
2170 |
] |
|
2171 |
] ifFalse:[ |
|
2172 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2173 |
self wordAtLine:line col:col do:[ |
|
2174 |
:beginLine :beginCol :endLine :endCol :style | |
|
2175 |
||
2176 |
line := beginLine. |
|
2177 |
col := beginCol. |
|
2178 |
style == #wordLeft ifTrue:[ |
|
2179 |
col := col + 1 |
|
2180 |
]. |
|
2181 |
searching := false. |
|
2182 |
] |
|
2183 |
] ifTrue:[ |
|
2184 |
col := col - 1 |
|
2185 |
] |
|
2186 |
] |
|
2187 |
] |
|
2188 |
]. |
|
2189 |
self cursorLine:line col:col |
|
499 | 2190 |
] |
2191 |
||
2192 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2193 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2194 |
! |
|
2195 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2196 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2197 |
"move cursor to absolute home" |
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 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2200 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2201 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2202 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2203 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2204 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2205 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2206 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2207 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2208 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2209 |
"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
|
2210 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2212 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2213 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2214 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2215 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2216 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2218 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2219 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2220 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2221 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2222 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2223 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2224 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2225 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2226 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2227 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2228 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2229 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2230 |
] |
672 | 2231 |
|
674 | 2232 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2233 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2234 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2235 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2236 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2237 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2238 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2240 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2241 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2242 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2243 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2244 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2245 |
|
676 | 2246 |
newCol := colNr. |
2247 |
(newCol < 1) ifTrue:[ |
|
4823 | 2248 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2249 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2250 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2251 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2252 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2253 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2254 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2256 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2257 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2258 |
"put cursor to position next to x/y coordinate in view" |
121 | 2259 |
|
2260 |
|line col| |
|
2261 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2263 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2264 |
self cursorVisibleLine:line col:col. |
121 | 2265 |
! |
2266 |
||
2267 |
drawCursor |
|
2268 |
"draw the cursor if shown and cursor is visible. |
|
2269 |
(but not, if there is a selection - to avoid confusion)" |
|
2270 |
||
2271 |
shown ifTrue:[ |
|
4823 | 2272 |
cursorVisibleLine notNil ifTrue:[ |
2273 |
self hasSelection ifFalse:[ |
|
2274 |
self drawCursorCharacter |
|
2275 |
] |
|
2276 |
] |
|
121 | 2277 |
] |
2278 |
! |
|
2279 |
||
2280 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2281 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2282 |
of cursor should be drawn. |
4721 | 2283 |
Currently, supported are: #none, |
2284 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2285 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2286 |
|
2570 | 2287 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2288 |
|
2289 |
self hasSelection ifTrue:[ |
|
4580 | 2290 |
" |
2291 |
hide cursor, if there is a selection |
|
2292 |
" |
|
2293 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2294 |
]. |
2295 |
||
1334 | 2296 |
cursorType == #none ifTrue:[ |
4580 | 2297 |
^ self |
1334 | 2298 |
]. |
2299 |
||
121 | 2300 |
cursorType == #block ifTrue:[ |
4829 | 2301 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2302 |
^ self |
121 | 2303 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2304 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2305 |
y := self yOfVisibleLine:cursorVisibleLine. |
2306 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2307 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2308 |
cursorType == #frame ifTrue:[ |
4580 | 2309 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2310 |
||
2311 |
char := self characterUnderCursor asString. |
|
4829 | 2312 |
self paint:bgColor. |
4889 | 2313 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2314 |
] ifFalse:[ |
4580 | 2315 |
self paint:bgColor. |
2316 |
cursorType == #ibeam ifTrue:[ |
|
2317 |
x1 := x - 1. |
|
5581 | 2318 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2319 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2320 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2321 |
^ self |
|
2322 |
]. |
|
2323 |
||
2324 |
cursorType == #Ibeam ifTrue:[ |
|
2325 |
x1 := x - 1. |
|
2326 |
y := y + 1. |
|
5581 | 2327 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2328 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2329 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2330 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2331 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2332 |
^ self |
|
2333 |
]. |
|
2334 |
||
2335 |
y := y + fontHeight - 3. |
|
2336 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2337 |
w := (fontWidth * 2 // 3) max:4. |
|
2338 |
y2 := y + w + (w//2). |
|
2339 |
] ifFalse:[ |
|
2340 |
w := (fontWidth // 2) max:4. |
|
2341 |
y2 := y + w. |
|
2342 |
]. |
|
2343 |
x1 := x - w. |
|
2344 |
x2 := x + w. |
|
2345 |
||
2346 |
oldClip := self clippingRectangleOrNil. |
|
2347 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2348 |
||
2349 |
cursorType == #caret ifTrue:[ |
|
2350 |
self lineWidth:2. |
|
2351 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2352 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2353 |
] ifFalse:[ |
|
2354 |
"anything else: solidCaret" |
|
2355 |
||
2356 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2357 |
with:(x @ y) |
|
2358 |
with:(x2 @ y2)) |
|
2359 |
]. |
|
2360 |
||
2361 |
self clippingRectangle:oldClip |
|
121 | 2362 |
]. |
133 | 2363 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2364 |
|
2088 | 2365 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2366 |
! |
2367 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2368 |
drawCursorCharacter |
3160 | 2369 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2370 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2371 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2372 |
|
3160 | 2373 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2374 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2375 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2376 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2377 |
] ifFalse:[ |
4823 | 2378 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2379 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2380 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2381 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2382 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2383 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2384 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2385 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2386 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2387 |
self hasSelection ifTrue:[ |
5260 | 2388 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2389 |
]. |
2390 |
cursorType == #none ifTrue:[ |
|
4823 | 2391 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2392 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2393 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2394 |
|
2395 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
drawNoFocusCursor |
3160 | 2399 |
"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
|
2400 |
|
1334 | 2401 |
|cType| |
2402 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2403 |
self hasSelection ifTrue:[ |
4823 | 2404 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2405 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2406 |
|
1334 | 2407 |
cType := cursorTypeNoFocus ? cursorType. |
2408 |
cType == #none ifTrue:[ |
|
4823 | 2409 |
^ self undrawCursor |
1334 | 2410 |
]. |
2411 |
||
2412 |
cType == #block ifTrue:[ |
|
4823 | 2413 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2414 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2415 |
|
1334 | 2416 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2417 |
||
2418 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2419 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2420 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2421 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2422 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2423 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2424 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2425 |
self makeLineVisible:aLineNumber. |
2951 | 2426 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2427 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2428 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2429 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2430 |
hideCursor |
1833 | 2431 |
"make cursor invisible if currently invisible" |
2432 |
||
2433 |
^ self cursorShown:false |
|
2434 |
||
2435 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2436 |
! |
2437 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2438 |
makeCursorVisible |
3160 | 2439 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2440 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2441 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2442 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2443 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2444 |
cursorLine notNil ifTrue:[ |
4823 | 2445 |
line := cursorLine. |
2446 |
col := cursorCol. |
|
2447 |
" |
|
2448 |
if there is a selection, its better to |
|
2449 |
have its start being visible, instead of the end |
|
2450 |
" |
|
2451 |
(selectionStartLine notNil |
|
2452 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2453 |
expandingTop ~~ false ifTrue:[ |
|
2454 |
line := selectionStartLine. |
|
2455 |
col := selectionStartCol. |
|
2456 |
] ifFalse:[ |
|
2457 |
line := selectionEndLine. |
|
2458 |
col := selectionEndCol |
|
2459 |
] |
|
2460 |
]. |
|
2461 |
self makeLineVisible:line. |
|
2462 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2463 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2464 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2465 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2466 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2467 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2468 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2469 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2470 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2471 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2472 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2473 |
flag ifTrue:[self showCursor] |
121 | 2474 |
! |
2475 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2476 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2477 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2478 |
|
2815 | 2479 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2480 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2481 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2482 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2483 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2484 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2485 |
|
3303 | 2486 |
"/ self assert:(lineNr notNil). |
2487 |
||
2488 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2489 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2490 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2491 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2492 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2493 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2494 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2495 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2496 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2497 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2498 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2499 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2500 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2501 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2502 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2503 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2504 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2505 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2506 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2507 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2508 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2509 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2510 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2511 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2512 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2513 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2514 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2515 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2516 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2517 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2518 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2519 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2520 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2521 |
|
1833 | 2522 |
^ self cursorShown:true |
2523 |
||
2524 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2525 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2526 |
|
5761 | 2527 |
singleQuoteSelection |
2528 |
"place single quotes around the selected text" |
|
2529 |
||
2530 |
|line1 col1 line2 col2| |
|
2531 |
||
2532 |
line1 := self selectionStartLine. |
|
2533 |
col1 := self selectionStartCol. |
|
2534 |
line2 := self selectionEndLine. |
|
2535 |
col2 := self selectionEndCol. |
|
2536 |
(line1 notNil |
|
2537 |
and:[ col1 notNil |
|
2538 |
and:[ line2 notNil |
|
2539 |
and:[ col2 notNil ]]]) |
|
2540 |
ifTrue:[ |
|
2541 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
2542 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2543 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
2544 |
] ifFalse:[ |
|
2545 |
self beep. |
|
2546 |
] |
|
2547 |
||
2548 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2549 |
! |
|
2550 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2551 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2552 |
"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
|
2553 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2554 |
|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
|
2555 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2556 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2557 |
prevCol := cursorCol - 1. |
2558 |
||
2559 |
"/ if there is any italic stuff in the cursor line, |
|
2560 |
"/ redraw it completely (because characters overlap). |
|
2561 |
cursorCol > 1 ifTrue:[ |
|
2562 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2563 |
line hasChangeOfEmphasis ifTrue:[ |
|
2564 |
line size >= (cursorCol-1) ifTrue:[ |
|
2565 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2566 |
line size >= (cursorCol) ifTrue:[ |
|
2567 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2568 |
line size >= (cursorCol+1) ifTrue:[ |
|
2569 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2570 |
]. |
|
2571 |
]. |
|
2572 |
]. |
|
2573 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2574 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2575 |
] |
|
2576 |
] |
|
2577 |
] |
|
2578 |
]. |
|
2579 |
||
2580 |
((cursorType == #caret) |
|
2581 |
or:[cursorType == #solidCaret |
|
2582 |
or:[cursorType == #bigSolidCaret |
|
2583 |
or:[cursorType == #bigCaret |
|
2584 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2585 |
"caret-cursor touches 4 characters" |
|
2586 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2587 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2588 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2589 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2590 |
] ifFalse:[ |
|
2591 |
"care for left margin" |
|
2592 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2593 |
]. |
|
2594 |
^ self |
|
2595 |
]. |
|
2596 |
||
2597 |
cursorType == #ibeam ifTrue:[ |
|
2598 |
"ibeam-cursor touches 2 characters" |
|
2599 |
cursorCol > 1 ifTrue:[ |
|
2600 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2601 |
] ifFalse:[ |
|
2602 |
"care for left margin" |
|
2603 |
super redrawVisibleLine:cursorVisibleLine. |
|
2604 |
]. |
|
2605 |
^ self |
|
2606 |
]. |
|
2607 |
||
2608 |
"block cursor is simple - just one character under cursor" |
|
2609 |
||
2610 |
"/ however, if italic characters are involved, we must care |
|
2611 |
"/ for the chars before/after the cursor. |
|
2612 |
"/ We redraw the part of the previous character which got |
|
2613 |
"/ detroyed by the block cursor. |
|
2614 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2615 |
||
2616 |
line := self visibleAt:cursorVisibleLine. |
|
2617 |
(line notNil and:[line isText]) ifTrue:[ |
|
2618 |
cursorCol > 1 ifTrue:[ |
|
2619 |
oldClip := self clippingRectangleOrNil. |
|
2620 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2621 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2622 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2623 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2624 |
self clippingRectangle:oldClip. |
|
2625 |
^ self. |
|
2626 |
]. |
|
2627 |
]. |
|
2628 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2629 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2630 |
|
2088 | 2631 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2632 |
! |
2633 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2634 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2635 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2636 |
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
|
2637 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2638 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2639 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2640 |
|
672 | 2641 |
validateCursorCol:col inLine:line |
674 | 2642 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2643 |
Here, no limits are enforced (and col is returned), |
5593 | 2644 |
but it may be redefined in EditFields or views which don't like the |
674 | 2645 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2646 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2647 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2648 |
|
1419 | 2649 |
"/ in ST80 mode, |
2707 | 2650 |
"/ the cursor may not be positioned beyond the |
2651 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2652 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2653 |
self st80EditMode ifTrue:[ |
4823 | 2654 |
l := (self listAt:line). |
2655 |
max := l size + 1. |
|
2656 |
col > max ifTrue:[ |
|
2657 |
^ max |
|
2658 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2659 |
]. |
672 | 2660 |
^ col |
2661 |
||
1419 | 2662 |
"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
|
2663 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2664 |
! |
2665 |
||
2666 |
validateCursorLine:line |
|
2667 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2668 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2669 |
redefined in views which don't like the cursor to be positioned |
674 | 2670 |
behind the end of the text (vi/st-80 behavior), or want to |
2671 |
skip reserved regions" |
|
2672 |
||
1419 | 2673 |
"/ |
2674 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2675 |
"/ beyond the last line |
2676 |
"/ (but it must be posible to place it on one line below the last one |
|
2677 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2678 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2679 |
self st80EditMode ifTrue:[ |
5367 | 2680 |
^ (line min:(list size + 1)) max:1 |
1419 | 2681 |
]. |
674 | 2682 |
^ line |
2683 |
||
1419 | 2684 |
"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
|
2685 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2686 |
! |
2687 |
||
121 | 2688 |
withCursorOffDo:aBlock |
2689 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2690 |
||
2691 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2692 |
^ aBlock value |
121 | 2693 |
]. |
2694 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2695 |
aBlock ensure:[ |
4823 | 2696 |
self showCursor |
121 | 2697 |
] |
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 |
|
2589 | 2700 |
!EditTextView methodsFor:'drag & drop'! |
2701 |
||
2702 |
allowDrop:aBoolean |
|
3236 | 2703 |
"enable/disable drop support" |
2704 |
||
2589 | 2705 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2706 |
dropTarget := nil. |
2589 | 2707 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2708 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2709 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2710 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2711 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2712 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2713 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2714 |
] |
3236 | 2715 |
]. |
2716 |
! |
|
2717 |
||
3412 | 2718 |
canDrop:aDropContext |
2719 |
"public from d&d. |
|
2720 |
I accept textObjects and fileObjects only." |
|
2721 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2722 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2723 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2724 |
^ self canDropObjects:aDropContext dropObjects |
|
2725 |
||
2726 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2727 |
! |
|
2728 |
||
2729 |
canDropObjects:aCollectionOfDropObjects |
|
2730 |
"public from d&d. |
|
2731 |
I accept textObjects and fileObjects only." |
|
2589 | 2732 |
|
2733 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2734 |
||
3412 | 2735 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2736 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2737 |
||
2738 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2739 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2740 |
! |
|
2741 |
||
2742 |
drop:aDropContext |
|
2743 |
"public from d&d. |
|
2744 |
drop objects (new API)" |
|
2745 |
||
2746 |
self dropObjects:(aDropContext dropObjects) |
|
2747 |
||
2748 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2749 |
! |
|
2750 |
||
2751 |
dropFileObject:aDropObject |
|
2589 | 2752 |
"drop objects |
3236 | 2753 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2754 |
||
4136 | 2755 |
|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
|
2756 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2757 |
pasteWhat := #name. |
3412 | 2758 |
|
2759 |
fn := aDropObject asFilename. |
|
2760 |
(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
|
2761 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2762 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2763 |
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
|
2764 |
pasteWhat := enforcedDropMode. |
3886 | 2765 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2766 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2767 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2768 |
pasteWhat := #name. |
3886 | 2769 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2770 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2771 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2772 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2773 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2774 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2775 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2776 |
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
|
2777 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2778 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2779 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2780 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2781 |
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
|
2782 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2783 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2784 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2785 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2786 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2787 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2788 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2789 |
] |
3886 | 2790 |
] |
2791 |
]. |
|
2792 |
]. |
|
2793 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2794 |
pasteWhat == #name ifTrue:[ |
3886 | 2795 |
text := fn pathName |
2796 |
] ifFalse:[ |
|
2797 |
self withWaitCursorDo:[ |
|
5063 | 2798 |
text := fn contentsAsString |
4136 | 2799 |
]. |
2800 |
(app := self application) notNil ifTrue:[ |
|
2801 |
app droppedFile:fn in:self |
|
2802 |
]. |
|
3886 | 2803 |
]. |
2804 |
||
3799 | 2805 |
self |
2806 |
undoablePaste:text |
|
2807 |
info:'Drop File'. |
|
3412 | 2808 |
|
2809 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2810 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2811 |
! |
2812 |
||
2813 |
dropObject:aDropObject |
|
2814 |
"drop objects |
|
2815 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2816 |
||
3415 | 2817 |
|text| |
2818 |
||
3412 | 2819 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2820 |
self dropFileObject:aDropObject |
3412 | 2821 |
] ifFalse:[ |
3799 | 2822 |
aDropObject isTextObject ifTrue:[ |
2823 |
text := aDropObject theObject. |
|
2824 |
text isStringCollection ifTrue:[ |
|
2825 |
text := text asStringWithoutFinalCR |
|
2826 |
]. |
|
2827 |
] ifFalse:[ |
|
2828 |
text := aDropObject theObject asString |
|
2829 |
]. |
|
2830 |
self |
|
2831 |
undoablePaste:text |
|
2832 |
info:'Drop'. |
|
3412 | 2833 |
]. |
2834 |
||
2835 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2836 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2837 |
! |
2838 |
||
2839 |
dropObjects:aCollectionOfDropObjects |
|
2840 |
"public from d&d. |
|
2841 |
drop objects (old API)" |
|
2842 |
||
3868 | 2843 |
aCollectionOfDropObjects do:[:el | |
2844 |
self dropObject:el |
|
3412 | 2845 |
]. |
2846 |
||
2847 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2848 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2849 |
! ! |
2850 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2851 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2852 |
|
5761 | 2853 |
applyConverterToSelection:converter |
2854 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2855 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2856 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2857 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2858 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2859 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2860 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2861 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2862 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2863 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2864 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2865 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2866 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2867 |
line1 to:line2 do:[:lineNr | |
5761 | 2868 |
|line col1 col2 newLine| |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2869 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2870 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2871 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2872 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2873 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2874 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2875 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2876 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2877 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2878 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2879 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2880 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2881 |
]. |
5761 | 2882 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
2883 |
self withoutRedrawAt:lineNr put:newLine. |
|
2884 |
self invalidateLine:lineNr. |
|
2885 |
]. |
|
2886 |
]. |
|
2887 |
] |
|
2888 |
||
2889 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
2890 |
! |
|
2891 |
||
2892 |
convertSelectionToLowercase |
|
2893 |
"to-lower selected text" |
|
2894 |
||
2895 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
2896 |
col1 to:col2 do:[:col | |
|
2897 |
|ch| |
|
2898 |
||
2899 |
ch := line at:col. |
|
2900 |
line at:col put:ch asLowercase. |
|
2901 |
]. |
|
2902 |
line. |
|
2903 |
]. |
|
2904 |
||
2905 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
2906 |
! |
|
2907 |
||
2908 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
2909 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
2910 |
||
2911 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
2912 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
|
2913 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
2914 |
||
2915 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
2916 |
col1 to:col2 do:[:col | |
|
2917 |
|ch| |
|
2918 |
||
2919 |
ch := line at:col. |
|
2920 |
ch isUppercase ifTrue:[ |
|
2921 |
isAllLower := false. |
|
2922 |
col == col1 ifTrue:[ |
|
2923 |
isLowerFirst := false. |
|
2924 |
]. |
|
2925 |
] ifFalse:[ |
|
2926 |
ch isLowercase ifTrue:[ |
|
2927 |
isAllUpper := false. |
|
2928 |
col == col1 ifTrue:[ |
|
2929 |
isUpperFirst := false. |
|
2930 |
]. |
|
2931 |
] |
|
2932 |
]. |
|
2933 |
]. |
|
2934 |
||
2935 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
2936 |
isLowerFirst ifTrue:[ |
|
2937 |
makeUppercaseFirst := true. |
|
2938 |
] ifFalse:[ |
|
2939 |
"/ must remember where we come from - otherwise, we end up |
|
2940 |
"/ in upperFirst - lowerFirst cycle. |
|
2941 |
"/ think about a good place to store this state |
|
2942 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
2943 |
makeLowercaseFirst := true. |
|
2944 |
] ifFalse:[ |
|
2945 |
isAllUpper ifTrue:[ |
|
2946 |
makeLowercase := true. |
|
2947 |
] ifFalse:[ |
|
2948 |
makeUppercase := true. |
|
2949 |
] |
|
2950 |
] |
|
2951 |
]. |
|
2952 |
makeUppercaseFirst ifTrue:[ |
|
2953 |
line at:col1 put:(line at:col1) asUppercase. |
|
2954 |
] ifFalse:[ |
|
2955 |
makeLowercaseFirst ifTrue:[ |
|
2956 |
line at:col1 put:(line at:col1) asLowercase. |
|
2957 |
] ifFalse:[ |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2958 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2959 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2960 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2961 |
ch := line at:col. |
5761 | 2962 |
ch := makeLowercase |
2963 |
ifTrue:[ ch asLowercase ] |
|
2964 |
ifFalse:[ |
|
2965 |
makeUppercase |
|
2966 |
ifTrue:[ ch asUppercase ] |
|
2967 |
ifFalse:[ |
|
2968 |
col == col1 |
|
2969 |
ifTrue:[ ch asUppercase ] |
|
2970 |
ifFalse:[ ch asLowercase ] |
|
2971 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2972 |
]. |
5761 | 2973 |
line at:col put:ch. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2974 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2975 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2976 |
]. |
5761 | 2977 |
line |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2978 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2979 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2980 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 2981 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
2982 |
! |
|
2983 |
||
2984 |
convertSelectionToUppercase |
|
2985 |
"to-upper selected text" |
|
2986 |
||
2987 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
2988 |
col1 to:col2 do:[:col | |
|
2989 |
|ch| |
|
2990 |
||
2991 |
ch := line at:col. |
|
2992 |
line at:col put:ch asUppercase. |
|
2993 |
]. |
|
2994 |
line. |
|
2995 |
]. |
|
2996 |
||
2997 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
2998 |
! |
|
2999 |
||
3000 |
convertSelectionToUppercaseFirst |
|
3001 |
"to-upperFirst selected text" |
|
3002 |
||
3003 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3004 |
|state| |
|
3005 |
||
3006 |
state := #first. |
|
3007 |
col1 to:col2 do:[:col | |
|
3008 |
|ch| |
|
3009 |
||
3010 |
ch := line at:col. |
|
3011 |
ch isSeparator ifFalse:[ |
|
3012 |
state == #first ifTrue:[ |
|
3013 |
line at:col put:ch asUppercase. |
|
3014 |
state := #skipRest |
|
3015 |
] |
|
3016 |
] ifTrue:[ |
|
3017 |
state := #first |
|
3018 |
] |
|
3019 |
]. |
|
3020 |
line. |
|
3021 |
]. |
|
3022 |
||
3023 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3024 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3025 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3026 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3027 |
"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
|
3028 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3029 |
selectionStartLine notNil ifTrue:[ |
4823 | 3030 |
self setClipboardText:(self selection). |
3031 |
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
|
3032 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3033 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3034 |
"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
|
3035 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3036 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3037 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3038 |
"delete single character under cursor; does not merge lines" |
121 | 3039 |
|
3040 |
|wasOn| |
|
3041 |
||
3042 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3043 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3044 |
wasOn ifTrue:[self showCursor] |
3045 |
! |
|
3046 |
||
827 | 3047 |
deleteCharAtLine:lineNr col:colNr |
3048 |
"delete a single character at colNr in line lineNr" |
|
3049 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3050 |
self st80EditMode ifTrue:[ |
4823 | 3051 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3052 |
| wasOn | |
|
3053 |
wasOn := self hideCursor. |
|
3054 |
self |
|
3055 |
cursorReturn; |
|
3056 |
cursorCol:1; |
|
3057 |
deleteCharBeforeCursor. |
|
3058 |
wasOn ifTrue:[ self showCursor]. |
|
3059 |
^ self. |
|
3060 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3061 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3062 |
|
827 | 3063 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3064 |
! |
|
3065 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3066 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3067 |
"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
|
3068 |
|
4592 | 3069 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3070 |
|
3071 |
wasOn := self hideCursor. |
|
4814 | 3072 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 3073 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 3074 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 3075 |
ln size < prevTab ifTrue:[ |
3076 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3077 |
]. |
|
3078 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3079 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3080 |
cursorCol > prevTab ifTrue:[ |
|
3081 |
self st80EditMode ifTrue:[ |
|
3082 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3083 |
"/ not allow a cursor position beyond the end of line, |
|
5742 | 3084 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
4592 | 3085 |
originalLine size < prevTab ifTrue:[ |
5742 | 3086 |
self checkForExistingLine:cursorLine. |
4771 | 3087 |
self basicListAt:cursorLine put:ln |
4592 | 3088 |
] |
3089 |
]. |
|
3090 |
self cursorLine:cursorLine col:prevTab. |
|
3091 |
wasOn ifTrue:[ self showCursor ]. |
|
3092 |
^ self |
|
3093 |
]. |
|
3094 |
] ifFalse:[ |
|
3095 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3096 |
self cursorLine:cursorLine col:prevTab. |
|
3097 |
wasOn ifTrue:[ self showCursor ]. |
|
3098 |
^ self. |
|
3099 |
] |
|
3100 |
]. |
|
827 | 3101 |
]. |
3102 |
||
2491 | 3103 |
"/ (autoIndent |
3104 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3105 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3106 |
"/ ifTrue:[ |
3107 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3108 |
"/ |
|
3109 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3110 |
"/ ln := list at:cursorLine. |
|
3111 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3112 |
"/ soCol := 1 |
|
3113 |
"/ ] |
|
3114 |
"/ ] |
|
3115 |
"/ ] ifFalse:[ |
|
4592 | 3116 |
soCol := 1. |
2491 | 3117 |
"/ ]. |
3118 |
||
1419 | 3119 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 3120 |
" |
3121 |
somewhere in the middle of a line |
|
3122 |
" |
|
3123 |
self cursorLeft. |
|
3124 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3125 |
] ifFalse:[ |
4592 | 3126 |
" |
3127 |
at begin of line - merge with previous line; |
|
3128 |
except for the very first line. |
|
3129 |
" |
|
3130 |
(cursorLine == 1) ifFalse:[ |
|
3131 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3132 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3133 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3134 |
"/ we are beyond the end of the text. |
|
3135 |
"/ move the cursor to the previous line. |
|
3136 |
self cursorLine:lineNrAboveCursor col:1. |
|
3137 |
] ifFalse:[ |
|
3138 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3139 |
] |
|
3140 |
] |
|
3141 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3142 |
]. |
827 | 3143 |
wasOn ifTrue:[ self showCursor ] |
3144 |
||
1419 | 3145 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3146 |
! |
3147 |
||
3148 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3149 |
"delete characters from colNr up to the end in line lineNr" |
|
3150 |
||
3151 |
|line| |
|
3152 |
||
3153 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3154 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3155 |
] |
3156 |
||
3157 |
! |
|
3158 |
||
4458 | 3159 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3160 |
"delete characters from startCol to endCol in line lineNr" |
|
3161 |
||
3162 |
|deleted| |
|
3163 |
||
3164 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3165 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3166 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3167 |
! |
|
3168 |
||
827 | 3169 |
deleteCharsAtLine:lineNr toCol:colNr |
3170 |
"delete characters from start up to colNr in line lineNr" |
|
3171 |
||
3172 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3173 |
||
3174 |
||
121 | 3175 |
! |
3176 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3177 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3178 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3179 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3180 |
self deleteLine:cursorLine |
121 | 3181 |
! |
3182 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3183 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3184 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3185 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3186 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3187 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3188 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3189 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3190 |
col1 == 0 ifTrue:[ |
4823 | 3191 |
line1 := line1 - 1. |
3192 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3193 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3194 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3195 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3196 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3197 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3198 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3199 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3200 |
|
2954 | 3201 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3202 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3203 |
joining lines if nescessary" |
|
3204 |
||
3205 |
|line newLine lineSize nMore| |
|
3206 |
||
3207 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3208 |
list isNil ifTrue:[^ self]. |
|
3209 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3210 |
||
3211 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3212 |
"/ delete chars within a line |
3213 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3214 |
^ self |
|
2954 | 3215 |
]. |
3216 |
||
3217 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3218 |
"/ delete full lines only |
3219 |
endLine > startLine ifTrue:[ |
|
3220 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3221 |
]. |
|
3222 |
^ self |
|
2954 | 3223 |
]. |
3224 |
||
3225 |
"/ delete right rest of 1st line |
|
4786 | 3226 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3227 |
|
3228 |
"/ delete the inner lines ... |
|
3229 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3230 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3231 |
]. |
3232 |
||
3233 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3234 |
"/ delete the left rest of the last line |
3235 |
||
3236 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3237 |
||
3238 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3239 |
startLine <= list size ifTrue:[ |
|
3240 |
line := list at:startLine. |
|
3241 |
lineSize := line size. |
|
3242 |
(startCol > lineSize) ifTrue:[ |
|
3243 |
newLine := line. |
|
3244 |
line isNil ifTrue:[ |
|
3245 |
newLine := String new:(startCol - 1) |
|
3246 |
] ifFalse:[ |
|
3247 |
nMore := startCol - 1 - lineSize. |
|
3248 |
nMore > 0 ifTrue:[ |
|
3249 |
newLine := line , (line species new:nMore) |
|
3250 |
] |
|
3251 |
]. |
|
3252 |
newLine ~~ line ifTrue:[ |
|
4771 | 3253 |
self basicListAt:startLine put:newLine. |
4225 | 3254 |
]. |
3255 |
"/ TODO: remember old maxwidth of linerange, |
|
3256 |
"/ only clear widthOfWidestLine, if this max |
|
3257 |
"/ length was (one of) the longest. |
|
3258 |
"/ avoids slow delete with huge texts. |
|
3259 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3260 |
self textChanged. |
|
3261 |
] |
|
3262 |
] |
|
2954 | 3263 |
]. |
3264 |
||
3265 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3266 |
self mergeLine:startLine removeBlanks:false |
|
3267 |
||
4225 | 3268 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3269 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3270 |
! |
3271 |
||
4458 | 3272 |
deleteFromLine:startLineNr toLine:endLineNr |
3273 |
"delete some lines" |
|
3274 |
||
3275 |
|deleted| |
|
3276 |
||
3277 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3278 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3279 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3280 |
! |
|
3281 |
||
827 | 3282 |
deleteLine:lineNr |
3283 |
"delete line" |
|
3284 |
||
3285 |
self deleteFromLine:lineNr toLine:lineNr |
|
3286 |
||
3287 |
||
3288 |
! |
|
3289 |
||
4458 | 3290 |
deleteLineWithoutRedraw:lineNr |
3291 |
"delete line - no redraw; |
|
3292 |
return true, if something was really deleted" |
|
3293 |
||
3294 |
|deleted ret| |
|
3295 |
||
3296 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3297 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3298 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3299 |
^ ret. |
|
3300 |
! |
|
3301 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3302 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3303 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3304 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3305 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3306 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3307 |
|
4771 | 3308 |
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
|
3309 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3310 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3311 |
(endLine > list size) ifTrue:[ |
4771 | 3312 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3313 |
] ifFalse:[ |
4771 | 3314 |
lastLine := endLine |
3315 |
]. |
|
3316 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3317 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3318 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3319 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3320 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3321 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3322 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3323 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3324 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3325 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3326 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3328 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3329 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3330 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3331 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3332 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3333 |
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
|
3334 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3335 |
selectionStartLine notNil ifTrue:[ |
4823 | 3336 |
wasOn := self hideCursor. |
3337 |
||
3338 |
startLine := selectionStartLine. |
|
3339 |
startCol := selectionStartCol. |
|
3340 |
endLine := selectionEndLine. |
|
3341 |
endCol := selectionEndCol. |
|
3342 |
self unselectWithoutRedraw. |
|
3343 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3344 |
self setCursorLine:startLine col:startCol. |
|
3345 |
||
3346 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3347 |
] |
121 | 3348 |
! |
3349 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3350 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3351 |
"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
|
3352 |
|
2952 | 3353 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3354 |
|
3799 | 3355 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3356 |
cursorCol <= 1 ifTrue:[ |
3357 |
self deleteCharBeforeCursor. |
|
3358 |
^ self |
|
3359 |
]. |
|
3799 | 3360 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3361 |
wasOn := self hideCursor. |
3799 | 3362 |
self |
3363 |
undoableDo:[ |
|
3364 |
endCol := cursorCol-1. |
|
3365 |
endLine := cursorLine. |
|
3366 |
self cursorToPreviousWord. |
|
3367 |
beginCol := cursorCol. |
|
3368 |
beginLine := cursorLine. |
|
3369 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3370 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3371 |
] |
3372 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3373 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3374 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3375 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3376 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3377 |
|
5761 | 3378 |
indentSelectionBy1 |
3379 |
"indent selected line-range |
|
3380 |
by 1 space (i.e. to the right)" |
|
3381 |
||
3382 |
self indentBy:1 |
|
3383 |
||
3384 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3385 |
! |
|
3386 |
||
4458 | 3387 |
insert:aCharacter atLine:lineNr col:colNr |
3388 |
"insert a single character at lineNr/colNr; |
|
3389 |
set emphasis to character at current position" |
|
3390 |
||
3391 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3392 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3393 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3394 |
] |
3395 |
! |
|
3396 |
||
121 | 3397 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3398 |
"insert a single character at cursor-position - advance cursor." |
121 | 3399 |
|
3400 |
|wasOn| |
|
3401 |
||
3402 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3403 |
aCharacter == Character tab ifTrue:[ |
4820 | 3404 |
"/ needs special care to advance cursor correctly |
3405 |
self insertTabAtCursor |
|
121 | 3406 |
] ifFalse:[ |
4820 | 3407 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3408 |
aCharacter == (Character cr) ifTrue:[ |
|
3409 |
self basicCursorReturn |
|
3410 |
] ifFalse:[ |
|
3411 |
self cursorRight. |
|
3412 |
]. |
|
121 | 3413 |
]. |
3414 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3415 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3416 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3417 |
! |
3418 |
||
641 | 3419 |
insertLine:aString before:lineNr |
3420 |
"insert the line aString before line lineNr" |
|
3421 |
||
3422 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3423 |
||
3424 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3425 |
! |
|
3426 |
||
155 | 3427 |
insertLines:aStringCollection before:lineNr |
3428 |
"insert a bunch before line lineNr" |
|
3429 |
||
3430 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3431 |
||
3432 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3433 |
! |
|
3434 |
||
4771 | 3435 |
insertLines:someText from:start to:end before:lineNr |
3436 |
"insert a bunch of lines before line lineNr. |
|
3437 |
The cursor position is left unchanged." |
|
3438 |
||
3439 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3440 |
srcY "{ Class: SmallInteger }" |
|
3441 |
dstY "{ Class: SmallInteger }" | |
|
3442 |
||
5357 | 3443 |
"wrong when pasting multiple lines" |
3444 |
false "autoIndent" ifTrue:[ |
|
4771 | 3445 |
indent := self leftIndentForLine:lineNr. |
3446 |
||
4812 | 3447 |
text := someText |
3448 |
collect:[:ln||line| |
|
3449 |
ln notNil ifTrue:[ |
|
3450 |
line := ln withoutLeadingSeparators. |
|
3451 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3452 |
line := (String new:indent), line |
|
3453 |
]. |
|
3454 |
line |
|
3455 |
] ifFalse:[ |
|
3456 |
nil |
|
3457 |
] |
|
3458 |
]. |
|
4771 | 3459 |
] ifFalse:[ |
3460 |
text := someText |
|
3461 |
]. |
|
3462 |
||
3463 |
visLine := self listLineToVisibleLine:lineNr. |
|
3464 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3465 |
self withoutRedrawInsertLines:text |
|
3466 |
from:start to:end |
|
3467 |
before:lineNr. |
|
3468 |
] ifFalse:[ |
|
3469 |
nLines := end - start + 1. |
|
3470 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3471 |
self withoutRedrawInsertLines:text |
|
3472 |
from:start to:end |
|
3473 |
before:lineNr. |
|
3474 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3475 |
] ifFalse:[ |
|
3476 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3477 |
and:(firstLineShown + nLines + nLinesShown). |
|
3478 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3479 |
dstY := srcY + (nLines * fontHeight). |
|
3480 |
||
3481 |
"/ |
|
3482 |
"/ scroll ... |
|
3483 |
"/ |
|
3484 |
" |
|
3485 |
stupid: must catchExpose before inserting new |
|
3486 |
stuff - since catchExpose may perform redraws |
|
3487 |
" |
|
3488 |
self catchExpose. |
|
3489 |
self withoutRedrawInsertLines:text |
|
3490 |
from:start to:end |
|
3491 |
before:lineNr. |
|
3492 |
self |
|
3493 |
copyFrom:self |
|
3494 |
x:textStartLeft y:srcY |
|
3495 |
toX:textStartLeft y:dstY |
|
3496 |
width:w |
|
3497 |
height:(height - dstY) |
|
3498 |
async:true. |
|
3499 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3500 |
self waitForExpose |
|
3501 |
]. |
|
3502 |
]. |
|
3503 |
widthOfWidestLine notNil ifTrue:[ |
|
3504 |
text do:[:line | |
|
3505 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3506 |
] |
|
3507 |
]. |
|
3508 |
self textChanged. |
|
3509 |
||
3510 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3511 |
! |
|
3512 |
||
654 | 3513 |
insertLines:lines withCR:withCr |
3160 | 3514 |
"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
|
3515 |
Cursor is moved behind insertion. |
641 | 3516 |
If withCr is true, append cr after last line" |
3517 |
||
3518 |
|start end nLines wasOn| |
|
3519 |
||
3520 |
lines notNil ifTrue:[ |
|
4649 | 3521 |
nLines := lines size. |
3522 |
(nLines == 1) ifTrue:[ |
|
3523 |
self insertStringAtCursor:(lines at:1). |
|
3524 |
withCr ifTrue:[ |
|
3525 |
self insertCharAtCursor:(Character cr) |
|
3526 |
] |
|
3527 |
] ifFalse:[ |
|
3528 |
(cursorCol ~~ 1) ifTrue:[ |
|
3529 |
self insertStringAtCursor:(lines at:1). |
|
3530 |
self insertCharAtCursor:(Character cr). |
|
3531 |
start := 2 |
|
3532 |
] ifFalse:[ |
|
3533 |
start := 1 |
|
3534 |
]. |
|
3535 |
withCr ifTrue:[ |
|
3536 |
end := nLines |
|
3537 |
] ifFalse:[ |
|
3538 |
end := nLines - 1 |
|
3539 |
]. |
|
3540 |
(start <= nLines) ifTrue:[ |
|
3541 |
(end >= start) ifTrue:[ |
|
3542 |
wasOn := self hideCursor. |
|
3543 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3544 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3545 |
wasOn ifTrue:[self showCursor]. |
|
3546 |
] |
|
3547 |
]. |
|
3548 |
withCr ifFalse:[ |
|
3549 |
"last line without cr" |
|
3550 |
self insertStringAtCursor:(lines at:nLines) |
|
3551 |
] |
|
3552 |
] |
|
641 | 3553 |
] |
654 | 3554 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3555 |
"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
|
3556 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3557 |
! |
3558 |
||
3559 |
insertLines:lines withCr:withCr |
|
3560 |
"insert a bunch of lines at cursor position. Cursor |
|
3561 |
is moved behind insertion. |
|
3562 |
If withCr is true, append cr after last line" |
|
3563 |
||
2363 | 3564 |
<resource:#obsolete> |
3565 |
||
1292 | 3566 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3567 |
self insertLines:lines withCR:withCr. |
|
3568 |
||
3569 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3570 |
! |
3571 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3572 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3573 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3575 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3576 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3577 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3578 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3579 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3580 |
self selectFromLine:startLine col:startCol |
4823 | 3581 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3582 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3583 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3584 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3585 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3586 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3587 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3588 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3589 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3590 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3591 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3592 |
col == 0 ifTrue:[ |
3593 |
line > 1 ifTrue:[ |
|
3594 |
line := line - 1. |
|
5216 | 3595 |
col := (self listAt:line) size + 1. |
5060 | 3596 |
] ifFalse:[ |
3597 |
col := 1. |
|
3598 |
] |
|
3599 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3600 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3601 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3602 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3603 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3604 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3605 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3606 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3607 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3608 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3609 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3610 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3611 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3612 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3613 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3614 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3615 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3616 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3617 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3618 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3619 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3620 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3621 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3622 |
[start <= end] whileTrue:[ |
4823 | 3623 |
stop := aString indexOf:(Character cr) startingAt:start. |
3624 |
stop == 0 ifTrue:[ |
|
3625 |
stop := end + 1 |
|
3626 |
]. |
|
3627 |
subString := aString copyFrom:start to:(stop - 1). |
|
3628 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3629 |
(stop <= end) ifTrue:[ |
|
3630 |
c := c + subString size. |
|
3631 |
self insert:(Character cr) atLine:l col:c. |
|
3632 |
l := l + 1. |
|
3633 |
c := 1 |
|
3634 |
]. |
|
3635 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3637 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3638 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3639 |
! |
3640 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3641 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3642 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3643 |
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
|
3644 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3645 |
aString isNil ifTrue:[ |
4823 | 3646 |
"new:" |
3647 |
self insertCharAtCursor:(Character cr). |
|
3648 |
^ self |
|
105 | 3649 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3650 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3651 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3652 |
]. |
3653 |
||
654 | 3654 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3655 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3656 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3657 |
! |
3658 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3659 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3660 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3661 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3662 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3663 |
shown ifTrue:[ |
4889 | 3664 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3665 |
self invalidateLine:lineNr. |
3666 |
] ifFalse:[ |
|
3667 |
self redrawLine:lineNr from:colNr |
|
3668 |
] |
|
3669 |
] |
|
3670 |
||
4191 | 3671 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3672 |
! |
3673 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3674 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3675 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3676 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3677 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3678 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3679 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3680 |
aString size > 0 ifTrue:[ |
4823 | 3681 |
wasOn := self hideCursor. |
3682 |
(aString includes:Character tab) ifTrue:[ |
|
3683 |
self checkForExistingLine:cursorLine. |
|
3684 |
oldLen := (list at:cursorLine) size. |
|
3685 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3686 |
newLen := (list at:cursorLine) size. |
|
3687 |
deltaLen := newLen - oldLen. |
|
3688 |
] ifFalse:[ |
|
3689 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3690 |
deltaLen := aString size. |
|
3691 |
]. |
|
3692 |
self setCursorCol:(cursorCol + deltaLen). |
|
3693 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3694 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3695 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3696 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3697 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3698 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3699 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3700 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3701 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3702 |
|wasOn nextTab| |
105 | 3703 |
|
121 | 3704 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3705 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3706 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3707 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3708 |
! |
3709 |
||
3542 | 3710 |
joinLines |
3890 | 3711 |
"join lines (remove line-break)" |
3712 |
||
3583 | 3713 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3714 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3715 |
self |
3890 | 3716 |
undoableDo:[ |
3717 |
|line col lineLen| |
|
3718 |
||
3719 |
line := cursorLine. |
|
3720 |
col := cursorCol. |
|
3721 |
lineLen := (list at:line) size. |
|
3722 |
col > lineLen ifTrue:[ |
|
3723 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3724 |
] ifFalse:[ |
|
3725 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3726 |
]. |
|
3727 |
self mergeLine:line removeBlanks:true. |
|
3728 |
self cursorLine:line col:col. |
|
3729 |
] |
|
3730 |
info:'Join' |
|
3542 | 3731 |
! |
3732 |
||
2952 | 3733 |
mergeLine:lineNr |
3734 |
"merge line lineNr with line lineNr+1" |
|
3735 |
||
3736 |
self mergeLine:lineNr removeBlanks:true |
|
3737 |
||
3738 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3739 |
! |
|
3740 |
||
4458 | 3741 |
mergeLine:lineNr removeBlanks:removeBlanks |
3742 |
"merge line lineNr with line lineNr+1" |
|
3743 |
||
3744 |
|len| |
|
3745 |
||
3746 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3747 |
||
3748 |
len := (self listAt:lineNr) size. |
|
3749 |
self nonUndoableDo:[ |
|
4823 | 3750 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3751 |
]. |
3752 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3753 |
! |
|
3754 |
||
5761 | 3755 |
parenthizeSelection |
3756 |
"place parenthesis around the selected text. |
|
3757 |
if already parenthized, de-parenthize it" |
|
3758 |
||
3759 |
self parenthizeSelectionWith:$( and:$) |
|
3760 |
||
3761 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
3762 |
! |
|
3763 |
||
2506 | 3764 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 3765 |
"if already parenthized, de-parenthize it" |
3766 |
||
5560 | 3767 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3768 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3769 |
self hasSelection ifFalse:[^ self]. |
5560 | 3770 |
startLine := selectionStartLine. |
3771 |
endLine := selectionEndLine. |
|
3772 |
startCol := selectionStartCol. |
|
3773 |
endCol := selectionEndCol. |
|
3774 |
||
3775 |
newSelectionEnd := endCol. |
|
3776 |
||
3777 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
3778 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
3779 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 3780 |
newSelectionEnd := newSelectionEnd-1. |
3781 |
]. |
|
5560 | 3782 |
self deleteCharAtLine:startLine col:startCol. |
3783 |
startLine == endLine ifTrue:[ |
|
4823 | 3784 |
newSelectionEnd := newSelectionEnd-1. |
3785 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3786 |
] ifFalse:[ |
5560 | 3787 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 3788 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 3789 |
self insert:openingCharacter atLine:startLine col:startCol. |
3790 |
startLine == endLine ifTrue:[ |
|
4823 | 3791 |
newSelectionEnd := newSelectionEnd+1. |
3792 |
] |
|
3160 | 3793 |
]. |
3794 |
self |
|
5560 | 3795 |
selectFromLine:startLine col:startCol |
3796 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 3797 |
|
3798 |
"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
|
3799 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3800 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3801 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3802 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3803 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3804 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3805 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3806 |
|
5114 | 3807 |
NoModificationError handle:[:ex | |
3808 |
^ self |
|
3809 |
] do:[ |
|
3810 |
lastLine := list size. |
|
3811 |
finished := false. |
|
3812 |
[finished] whileFalse:[ |
|
3813 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3814 |
finished := true |
3815 |
] ifFalse:[ |
|
5114 | 3816 |
line := list at:lastLine. |
3817 |
line notNil ifTrue:[ |
|
3818 |
line isBlank ifTrue:[ |
|
3819 |
self basicListAt:lastLine put:nil. |
|
3820 |
line := nil |
|
3821 |
] |
|
3822 |
]. |
|
3823 |
line notNil ifTrue:[ |
|
3824 |
finished := true |
|
3825 |
] ifFalse:[ |
|
3826 |
lastLine := lastLine - 1 |
|
3827 |
] |
|
4771 | 3828 |
] |
5114 | 3829 |
]. |
3830 |
(lastLine ~~ list size) ifTrue:[ |
|
3831 |
list grow:lastLine. |
|
3832 |
"/ self textChanged |
|
4771 | 3833 |
] |
118 | 3834 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3835 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3836 |
|
4458 | 3837 |
replace:aCharacter atLine:lineNr col:colNr |
3838 |
"replace a single character at lineNr/colNr" |
|
3839 |
||
3840 |
|originalChar| |
|
3841 |
||
3842 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3843 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3844 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3845 |
! |
|
3846 |
||
4713 | 3847 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3848 |
|pattern replacePattern| |
3849 |
||
3850 |
pattern := patternArg string. |
|
3851 |
replacePattern := replacePatternArg string. |
|
4630 | 3852 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3853 |
self rememberSearchPattern:pattern. |
|
3854 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3855 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3856 |
self |
3857 |
undoableDo:[ |
|
3858 |
all ifTrue:[ |
|
3859 |
self |
|
3860 |
replaceString:pattern |
|
3861 |
to:replacePattern |
|
4713 | 3862 |
ignoreCase:ignoreCase |
4630 | 3863 |
] ifFalse:[ |
3864 |
(self selectionAsString notNil |
|
4713 | 3865 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3866 |
ifTrue:[ |
4742 | 3867 |
self replaceSelectionBy:replacePattern. |
4630 | 3868 |
self |
3869 |
search:pattern |
|
4713 | 3870 |
ignoreCase:ignoreCase |
4630 | 3871 |
forward:(lastSearchDirection = #forward). |
3872 |
]. |
|
3873 |
] |
|
3874 |
] |
|
3875 |
info:'Replace' |
|
3430 | 3876 |
] |
3877 |
||
3878 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3879 |
! |
|
3880 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3881 |
replaceCharAtCursor:aCharacter |
5413 | 3882 |
"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
|
3883 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3884 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3885 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3886 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3887 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3888 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3889 |
] ifFalse:[ |
4823 | 3890 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3891 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3892 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3893 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3894 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3895 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3896 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3897 |
|
4458 | 3898 |
replaceContentsWith:newContents |
5413 | 3899 |
"undoably replace everything" |
4458 | 3900 |
|
3901 |
|originalContents| |
|
3902 |
||
3903 |
originalContents := self contents. |
|
3904 |
self contents:newContents keepUndoHistory:true. |
|
3905 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3906 |
! |
|
3907 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3908 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 3909 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3910 |
|
5216 | 3911 |
"/ 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
|
3912 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3913 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3914 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3915 |
|
4458 | 3916 |
replaceLine:lineNr with:newText |
5413 | 3917 |
"undoably replace a line at lineNr" |
4458 | 3918 |
|
3919 |
|originalLine| |
|
3920 |
||
3921 |
originalLine := self listAt:lineNr. |
|
3922 |
originalLine isNil ifTrue:[ |
|
4823 | 3923 |
self checkForExistingLine:lineNr |
4458 | 3924 |
]. |
3925 |
self list at:lineNr put:newText. |
|
3926 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3927 |
self invalidateLine:lineNr. |
|
3928 |
||
3929 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3930 |
! |
|
3931 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3932 |
replaceLines:lines withCR:withCr |
5413 | 3933 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3934 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3935 |
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
|
3936 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3937 |
|
1809 | 3938 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3939 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3940 |
lines notNil ifTrue:[ |
4661 | 3941 |
wasOn := self hideCursor. |
3942 |
nLines := lines size. |
|
3943 |
line := cursorLine. |
|
3944 |
col := cursorCol. |
|
3945 |
lines keysAndValuesDo:[:i :l | |
|
3946 |
self replaceString:(l ? '') atLine:line col:col. |
|
3947 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3948 |
line := line + 1. |
|
3949 |
col := 1. |
|
3950 |
] ifFalse:[ |
|
3951 |
col := col + (l size). |
|
3952 |
] |
|
3953 |
]. |
|
3954 |
self cursorLine:line col:col. |
|
3955 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3956 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3957 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3958 |
|
4661 | 3959 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3960 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3961 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3962 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3963 |
replaceSelectionBy:something |
5413 | 3964 |
"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
|
3965 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3966 |
|
4666 | 3967 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3968 |
! |
3969 |
||
3970 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 3971 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 3972 |
leave cursor after insertion or leave it, depending on keep" |
3973 |
||
4666 | 3974 |
self replaceSelectionBy:something keepCursor:keep select:false |
3975 |
||
3976 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3977 |
! |
|
3978 |
||
3979 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 3980 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 3981 |
leave cursor after insertion or leave it, depending on keep. |
3982 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3983 |
||
3984 |
|sel l c selStartLine selStartCol| |
|
105 | 3985 |
|
3986 |
l := cursorLine. |
|
3987 |
c := cursorCol. |
|
3988 |
||
4818 | 3989 |
sel := self selectionAsString. |
4666 | 3990 |
sel isNil ifTrue:[ |
3991 |
selStartLine := l. |
|
3992 |
selStartCol := c. |
|
3993 |
] ifFalse:[ |
|
3994 |
selStartLine := selectionStartLine. |
|
3995 |
selStartCol := selectionStartCol. |
|
3996 |
||
4053 | 3997 |
self setLastStringToReplace: sel. |
3998 |
||
4010 | 3999 |
self deleteSelection. |
4000 |
replacing := true. |
|
4818 | 4001 |
lastReplacementInfo rememberReplacement. |
4048 | 4002 |
lastReplacementInfo lastReplacement: ''. |
4818 | 4003 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 4004 |
undoSupport actionInfo:'replace'. |
3161 | 4005 |
]. |
4006 |
||
4007 |
something isCharacter ifTrue:[ |
|
4051 | 4008 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 4009 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 4010 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 4011 |
]. |
4010 | 4012 |
]. |
4013 |
self isInInsertMode ifTrue:[ |
|
4014 |
self insertCharAtCursor:something |
|
4015 |
] ifFalse:[ |
|
4016 |
self replaceCharAtCursor:something |
|
4017 |
] |
|
105 | 4018 |
] ifFalse:[ |
4010 | 4019 |
something isString ifTrue:[ |
4048 | 4020 |
lastReplacementInfo lastReplacement: something. |
4010 | 4021 |
self isInInsertMode ifTrue:[ |
4022 |
self insertStringAtCursor:something |
|
4023 |
] ifFalse:[ |
|
4024 |
self replaceStringAtCursor:something |
|
4025 |
] |
|
4026 |
] ifFalse:[ |
|
4027 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4028 |
]. |
|
105 | 4029 |
]. |
4030 |
keep ifTrue:[ |
|
4010 | 4031 |
self cursorLine:l col:c |
4666 | 4032 |
]. |
4033 |
selectNewText ifTrue:[ |
|
4034 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 4035 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4036 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4037 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4038 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4039 |
|
4458 | 4040 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4041 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4042 |
This is not prepared to encounter special chars (except TAB) in the string." |
4043 |
||
4044 |
|originalString| |
|
4045 |
||
4046 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4047 |
||
4048 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4049 |
||
4050 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4051 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4052 |
! |
|
4053 |
||
4713 | 4054 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4055 |
|continue count| |
4056 |
||
4057 |
self cursorToTop. |
|
4058 |
self selectFromBeginning. |
|
4059 |
count := 0. |
|
4060 |
continue := true. |
|
4061 |
[ continue ] whileTrue:[ |
|
4713 | 4062 |
(self selectionAsString notNil |
4063 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4064 |
ifTrue:[ |
|
4742 | 4065 |
self replaceSelectionBy:aNewString. |
4713 | 4066 |
count := count + 1. |
4067 |
]. |
|
4068 |
self |
|
4069 |
searchFwd:aString |
|
4070 |
ignoreCase:ignoreCase |
|
4071 |
ifAbsent:[ |
|
4072 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4073 |
bindWith:aString with:aNewString with:count). |
|
4074 |
continue := false. |
|
4075 |
]. |
|
3549 | 4076 |
]. |
3430 | 4077 |
|
4078 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4079 |
! |
|
4080 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4081 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4082 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4083 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4084 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4085 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4086 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4087 |
(aString includes:Character tab) ifTrue:[ |
4823 | 4088 |
"/ need special care for TAB (to move cursor correctly) |
4089 |
i1 := 1. |
|
4090 |
[i1 ~~ 0] whileTrue:[ |
|
4091 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4092 |
i2 ~~ 0 ifTrue:[ |
|
4093 |
i1 ~~ i2 ifTrue:[ |
|
4094 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4095 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4096 |
]. |
|
4097 |
self replaceTABAtCursor. |
|
4098 |
i2 := i2 + 1. |
|
4099 |
] ifFalse:[ |
|
4100 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4101 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4102 |
]. |
|
4103 |
i1 := i2. |
|
4104 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4105 |
] ifFalse:[ |
4823 | 4106 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 4107 |
self setValidatedCursorCol:(cursorCol + aString size). |
4108 |
"/ self cursorCol:(cursorCol + aString size). |
|
4109 |
]. |
|
4110 |
wasOn ifTrue:[ |
|
4111 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
4112 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
4113 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4114 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4115 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4116 |
"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
|
4117 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4118 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4119 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4120 |
"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
|
4121 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4122 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4123 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4124 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4125 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4126 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4127 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4128 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4129 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4130 |
! |
4131 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4132 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4133 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4134 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4135 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4136 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4137 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4138 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4139 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4140 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4141 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4142 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4143 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4144 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4145 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4146 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4147 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4148 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4149 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4150 |
|
4458 | 4151 |
splitLine:lineNr before:colNr |
4152 |
"split the line linNr before colNr; the right part (from colNr) |
|
4153 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4154 |
||
4155 |
self basicSplitLine:lineNr before:colNr. |
|
4156 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4157 |
! |
|
4158 |
||
5761 | 4159 |
toggleTabSetting |
4160 |
"toggle between 4-col |
|
4161 |
and 8-col tabs" |
|
4162 |
||
4163 |
(tabPositions == self class tab4Positions) |
|
4164 |
ifTrue:[self setTab8] |
|
4165 |
ifFalse:[self setTab4] |
|
4166 |
||
4167 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4168 |
! |
|
4169 |
||
4170 |
undentSelectionBy1 |
|
4171 |
"undent selected line-range |
|
4172 |
by 1 space (i.e. to the left)" |
|
4173 |
||
4174 |
self undentBy:1 |
|
4175 |
||
4176 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4177 |
! |
|
4178 |
||
5146 | 4179 |
withAutoIndent:aBoolean do:aBlock |
4180 |
|sav| |
|
4181 |
||
4182 |
sav := autoIndent. |
|
4183 |
autoIndent := aBoolean. |
|
4184 |
aBlock ensure:[ autoIndent := sav ]. |
|
4185 |
! |
|
4186 |
||
4458 | 4187 |
withoutRedrawAt:lineNr put:aString |
4188 |
"replace a line at lineNr" |
|
4189 |
||
4190 |
|originalLine| |
|
4191 |
||
4192 |
originalLine := self listAt:lineNr. |
|
4193 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4194 |
super withoutRedrawAt:lineNr put:aString. |
|
4195 |
! |
|
4196 |
||
4197 |
withoutRedrawInsertLine:aString before:lineNr |
|
4198 |
"insert the argument, aString before line lineNr; the string |
|
4199 |
becomes line lineNr; everything else is moved down; the view |
|
4200 |
is not redrawn" |
|
4201 |
||
4771 | 4202 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4203 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4204 |
! |
|
4205 |
||
4206 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4207 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4208 |
||
4209 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4210 |
self isReadOnly ifFalse:[ |
|
4823 | 4211 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4212 |
]. |
4213 |
! |
|
4214 |
||
4215 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4216 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4217 |
||
4218 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4219 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4220 |
! |
|
4221 |
||
3890 | 4222 |
wrapLines |
4223 |
"wrap lines (insert line-break)" |
|
4224 |
||
4225 |
|lineLength answerString string| |
|
4226 |
||
4227 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4228 |
||
4229 |
self hasSelection ifFalse:[ |
|
4230 |
self selectLine:cursorLine. |
|
4231 |
]. |
|
4232 |
string := self selectionAsString. |
|
4233 |
string isEmptyOrNil ifTrue:[ |
|
4234 |
Dialog information:(resources string:'Nothing selected.'). |
|
4235 |
^ self. |
|
4236 |
]. |
|
4237 |
||
4238 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4239 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4240 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4241 |
lineLength < 1 ifTrue:[ |
4242 |
lineLength := 1. |
|
4243 |
]. |
|
4244 |
||
4245 |
self |
|
4246 |
undoableDo:[ |
|
4247 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4248 |
||
4249 |
line := selectionStartLine. |
|
4250 |
col := selectionStartCol. |
|
4251 |
||
4252 |
self cutSelection. |
|
4253 |
self cursorLine:line col:col. |
|
4254 |
||
4255 |
lastGoodCol := col. |
|
4256 |
||
4257 |
inStream := string readStream. |
|
4258 |
[ inStream atEnd ] whileFalse:[ |
|
4259 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4260 |
word := WriteStream on:(String new:10). |
|
4261 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4262 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4263 |
self insertCharAtCursor:(Character cr). |
|
4264 |
col := 1. |
|
4265 |
] ifFalse:[ |
|
4266 |
col ~~ 1 ifTrue:[ |
|
4267 |
self insertStringAtCursor:' '. |
|
4268 |
col := col + 1. |
|
4269 |
] |
|
4270 |
]. |
|
4271 |
self insertStringAtCursor:word contents. |
|
4272 |
col := col + word size. |
|
4273 |
]. |
|
4274 |
] |
|
4275 |
info:'Wrap' |
|
4388 | 4276 |
|
4277 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4278 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4279 |
|
2752 | 4280 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4281 |
|
2952 | 4282 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4283 |
"delete characters from startCol to endCol in line lineNr" |
4284 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4285 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4286 |
|
4673 | 4287 |
self unselect. |
4288 |
||
4289 |
cursorLine == lineNr ifTrue:[ |
|
4290 |
cursorCol >= startCol ifTrue:[ |
|
4291 |
cursorCol >= endCol ifTrue:[ |
|
4292 |
cursorCol := startCol. |
|
4293 |
] ifFalse:[ |
|
4294 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
5489 | 4295 |
"/ self assert:(cursorCol >= 0). |
4296 |
cursorCol := cursorCol max:1. |
|
4673 | 4297 |
] |
4298 |
]. |
|
4299 |
]. |
|
4300 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4301 |
line := self listAt:lineNr. |
827 | 4302 |
|
4673 | 4303 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4304 |
||
4305 |
lineSize := line size. |
|
4306 |
||
4307 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4308 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4309 |
||
4310 |
stop >= start ifTrue:[ |
|
4311 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4312 |
ifFalse:[ newLine := '' ]. |
|
4313 |
||
4314 |
stop == lineSize ifFalse:[ |
|
4315 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4316 |
newLine := line string species fromString:newLine. |
|
4190 | 4317 |
]. |
4673 | 4318 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4319 |
]. |
|
4320 |
||
4321 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4322 |
newLine := nil |
|
4323 |
]. |
|
4324 |
||
4325 |
prevWidth := self widthOfLine:lineNr. |
|
4326 |
||
4771 | 4327 |
self basicListAt:lineNr put:newLine. |
4673 | 4328 |
|
4329 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4330 |
"/ remember old width of this line, |
|
4331 |
"/ only clear widthOfWidestLine, if this lines |
|
4332 |
"/ length was (one of) the longest. |
|
4333 |
"/ avoids slow delete with huge texts. |
|
4334 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4335 |
||
4336 |
"/ scroll left if reqiured |
|
4337 |
viewOrigin x > 0 ifTrue:[ |
|
4338 |
newWidth := self widthOfLine:lineNr. |
|
4339 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4340 |
self scrollHorizontalTo:(newWidth |
|
4341 |
- width |
|
4342 |
+ margin + margin |
|
4889 | 4343 |
+ (gc font widthOf:' ')) |
4673 | 4344 |
] |
4190 | 4345 |
]. |
4673 | 4346 |
self textChanged. |
4347 |
] ifFalse:[ |
|
4348 |
self textChanged "/ textChangedButNoSizeChange |
|
4349 |
]. |
|
4889 | 4350 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4351 |
self invalidateLine:lineNr. |
4352 |
] ifFalse:[ |
|
4353 |
self redrawLine:lineNr from:start. |
|
4354 |
]. |
|
4355 |
]. |
|
827 | 4356 |
|
4191 | 4357 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4358 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4359 |
|
2952 | 4360 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4361 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4362 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4363 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4364 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4365 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4366 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4367 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4368 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4369 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4370 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4371 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4372 |
startLineNr <= list size ifTrue:[ |
4771 | 4373 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4374 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4375 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4376 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4377 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4378 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4379 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4380 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4381 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4382 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4383 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4384 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4385 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4386 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4387 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4388 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4389 |
|
4226 | 4390 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4391 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4392 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4393 |
|
2952 | 4394 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4395 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4396 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4397 |
|
2952 | 4398 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4400 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4401 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4402 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4403 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4404 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4405 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4406 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4407 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4408 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4409 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4410 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4411 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4412 |
|
2952 | 4413 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4414 |
"insert a single character at lineNr/colNr; |
827 | 4415 |
set emphasis to character at current position" |
4416 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4417 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4418 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4419 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4420 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4421 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4422 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4423 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4424 |
]. |
827 | 4425 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4426 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4427 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4428 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4429 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4430 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4431 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4432 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4433 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4434 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4435 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4436 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4437 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4438 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4439 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4440 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4441 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4442 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4443 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4444 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4445 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4446 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4447 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4448 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4449 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4450 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4451 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4452 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4453 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4454 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4455 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4456 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4457 |
]. |
827 | 4458 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4459 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4460 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4461 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4462 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4463 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4464 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4465 |
newLine at:colNr put:aCharacter. |
827 | 4466 |
|
4467 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4468 |
newLine emphasisAt:colNr put:attribute. |
827 | 4469 |
]. |
4470 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4471 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4472 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4473 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4474 |
]. |
827 | 4475 |
|
4771 | 4476 |
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
|
4477 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4478 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4479 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4480 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4481 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4482 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4483 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4484 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4485 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4486 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4487 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4488 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4489 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4490 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4491 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4492 |
|
4889 | 4493 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4494 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4495 |
] ifFalse:[ |
4190 | 4496 |
drawCharacterOnly ifTrue:[ |
4889 | 4497 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4498 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4499 |
] ifFalse:[ |
|
4500 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4501 |
self redrawLine:lineNr from:colNr-1 |
|
4502 |
]. |
|
4503 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4504 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4505 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4506 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4507 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4508 |
]. |
4889 | 4509 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4510 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4511 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4512 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4513 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4514 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4515 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4516 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4517 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4518 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4519 |
|
4191 | 4520 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4521 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4522 |
|
4771 | 4523 |
basicListAt:lineNr put:newLine |
4524 |
"redefinable for special subclasses (with virtual list)" |
|
4525 |
||
4526 |
list at:lineNr put:newLine. |
|
4527 |
! |
|
4528 |
||
4529 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4530 |
"redefinable for special subclasses (with virtual list)" |
|
4531 |
||
4532 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4533 |
! |
|
4534 |
||
2952 | 4535 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4536 |
"merge line lineNr with line lineNr+1" |
4537 |
||
827 | 4538 |
|leftPart rightPart bothParts nextLineNr i| |
4539 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4540 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4541 |
"/ empty list or beyond end of text |
4542 |
^ self |
|
827 | 4543 |
]. |
4544 |
leftPart := self listAt:lineNr. |
|
4545 |
||
4546 |
leftPart isNil ifTrue:[ |
|
4771 | 4547 |
leftPart := ''. |
4548 |
autoIndent ifTrue:[ |
|
4549 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4550 |
leftPart := String new:i |
|
4551 |
] |
|
4552 |
] |
|
827 | 4553 |
]. |
4554 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4555 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4556 |
||
4557 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4558 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4559 |
rightPart := '' |
|
4560 |
] ifFalse:[ |
|
4561 |
removeBlanks ifTrue:[ |
|
4562 |
rightPart := rightPart withoutLeadingSeparators. |
|
4563 |
] |
|
4564 |
]. |
|
4565 |
||
4566 |
bothParts := leftPart , rightPart. |
|
4567 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4568 |
self basicListAt:lineNr put:bothParts. |
|
4569 |
self redrawLine:lineNr. |
|
4570 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4571 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4572 |
|
1319 | 4573 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4574 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4575 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4576 |
|
2952 | 4577 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4578 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4579 |
|
5045 | 4580 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4581 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4582 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4583 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4584 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4585 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4586 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4587 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4588 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4589 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4590 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4591 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4592 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4593 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4594 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4595 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4596 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4597 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4598 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4599 |
(lineSize == 0) ifTrue:[ |
4190 | 4600 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4601 |
] ifFalse: [ |
5045 | 4602 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4603 |
newLineSpecies := aCharacter stringSpecies |
|
4604 |
] ifFalse:[ |
|
4605 |
newLineSpecies := line species |
|
4606 |
]. |
|
4607 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4608 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4609 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4610 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4611 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4612 |
newLine := self withTabsExpanded:newLine. |
4613 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4614 |
]. |
4771 | 4615 |
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
|
4616 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4617 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4618 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4619 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4620 |
shown ifTrue:[ |
4889 | 4621 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4622 |
self invalidateLine:lineNr. |
4623 |
] ifFalse:[ |
|
4624 |
drawCharacterOnly ifTrue:[ |
|
4625 |
self redrawLine:lineNr col:colNr |
|
4626 |
] ifFalse:[ |
|
4627 |
self redrawLine:lineNr from:colNr |
|
4628 |
] |
|
4629 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4630 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4631 |
|
4190 | 4632 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4633 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4634 |
! |
4635 |
||
3235 | 4636 |
basicReplaceString:aString atLine:lineNr col:colNr |
4637 |
"replace multiple characters starting at lineNr/colNr. |
|
4638 |
This is not prepared to encounter special chars (except TAB) |
|
4639 |
in the string." |
|
4640 |
||
5045 | 4641 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4642 |
|
4643 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4644 |
||
4645 |
self checkForExistingLine:lineNr. |
|
4646 |
line := list at:lineNr. |
|
4647 |
lineSize := line size. |
|
4648 |
||
4649 |
endCol := colNr + aString size - 1. |
|
4650 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4651 |
newLine := aString species new:endCol. |
3235 | 4652 |
] ifFalse: [ |
5571 | 4653 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4654 |
newLineSpecies := aString stringSpecies |
4655 |
] ifFalse:[ |
|
4656 |
newLineSpecies := line species |
|
4657 |
]. |
|
4658 |
||
4659 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4660 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4661 |
]. |
4662 |
newLine replaceFrom:colNr with:aString. |
|
4663 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4664 |
newLine := self withTabsExpanded:newLine. |
3235 | 4665 |
]. |
4771 | 4666 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4667 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4668 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4669 |
]. |
4670 |
self textChanged. |
|
4671 |
shown ifTrue:[ |
|
4889 | 4672 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4673 |
self invalidateLine:lineNr. |
4674 |
] ifFalse:[ |
|
4675 |
self redrawLine:lineNr from:colNr |
|
4676 |
] |
|
3235 | 4677 |
] |
4678 |
||
4190 | 4679 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4680 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4681 |
! |
4682 |
||
2952 | 4683 |
basicSplitLine:lineNr before:colNr |
4684 |
"split the line linNr before colNr; the right part (from colNr) |
|
4685 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4686 |
||
3160 | 4687 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4688 |
srcY "{ Class: SmallInteger }" | |
4689 |
||
3027 | 4690 |
list isNil ifTrue:[ ^ self ]. |
4691 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4692 |
||
4693 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4694 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4695 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4696 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4697 |
^ self |
3027 | 4698 |
]. |
4699 |
||
4700 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4701 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4702 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4703 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4704 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4705 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4706 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4707 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4708 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4709 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4710 |
] |
3027 | 4711 |
]. |
4712 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4713 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4714 |
]. |
4771 | 4715 |
self basicListAt:lineNr put:leftRest. |
3027 | 4716 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4717 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4718 |
]. |
4719 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4720 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4721 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4722 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4723 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4724 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4725 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4726 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4727 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4728 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4729 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4730 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4731 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4732 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4733 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4734 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4735 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4736 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4737 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4738 |
]. |
4739 |
widthOfWidestLine := nil. "/ unknown |
|
4740 |
self textChanged. |
|
2952 | 4741 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4742 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4743 |
! |
4744 |
||
2954 | 4745 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4746 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4747 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4748 |
because the text might have been pasted from an alien view." |
|
2954 | 4749 |
|
4750 |
|newLine newLines nLines| |
|
4751 |
||
4752 |
nLines := end - start + 1. |
|
4753 |
newLines := Array new:(lines size). |
|
4754 |
start to:end do:[:index | |
|
4328 | 4755 |
newLine := lines at:index. |
4756 |
newLine notNil ifTrue:[ |
|
4757 |
newLine isString ifTrue:[ |
|
4758 |
newLine isBlank ifTrue:[ |
|
4759 |
newLine := nil |
|
4760 |
] ifFalse:[ |
|
4761 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4762 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4763 |
] |
|
4764 |
] |
|
4765 |
] |
|
4766 |
]. |
|
4767 |
newLines at:index put:newLine |
|
2954 | 4768 |
]. |
4769 |
list isNil ifTrue: [ |
|
4328 | 4770 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4771 |
] ifFalse: [ |
4328 | 4772 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4773 |
]. |
4774 |
||
4775 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4776 |
overlapping copy - if it didn't, we had to use:" |
4777 |
" |
|
4778 |
index := list size. |
|
4779 |
[index > lineNr] whileTrue: [ |
|
4328 | 4780 |
pIndex := index - 1. |
4781 |
list at:index put:(list at:pIndex). |
|
4782 |
index := pIndex |
|
2954 | 4783 |
]. |
4784 |
" |
|
4785 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4786 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4787 |
self contentsChanged |
|
4788 |
||
4328 | 4789 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4790 |
! |
4791 |
||
4792 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4793 |
"insert aString (which has no crs) at lineNr/colNr. |
4794 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4795 |
because the text might have been pasted from an alien view." |
|
2954 | 4796 |
|
4360 | 4797 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4798 |
|
4623 | 4799 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4800 |
|
4801 |
strLen := aString size. |
|
4802 |
self checkForExistingLine:lineNr. |
|
4803 |
||
4804 |
stringType := aString string species. |
|
4805 |
isText := aString isText. |
|
4806 |
line := list at:lineNr. |
|
4807 |
||
4808 |
line notNil ifTrue:[ |
|
4328 | 4809 |
lineSize := line size. |
4810 |
line isString ifFalse:[ |
|
4811 |
stringType := line species |
|
4812 |
] ifTrue:[ |
|
4360 | 4813 |
lineCharWidth := line bitsPerCharacter. |
4814 |
stringCharWidth := aString bitsPerCharacter. |
|
4815 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4816 |
stringType := line string species |
4360 | 4817 |
] ifFalse:[ |
4818 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4819 |
stringType := aString string species |
|
4820 |
] |
|
4328 | 4821 |
]. |
4822 |
line isText ifTrue:[ isText := true ] |
|
4823 |
]. |
|
2954 | 4824 |
] ifFalse:[ |
4328 | 4825 |
lineSize := 0 |
2954 | 4826 |
]. |
4827 |
||
4828 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4829 |
newLine := aString |
2954 | 4830 |
] ifFalse:[ |
4328 | 4831 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4832 |
sz := colNr + strLen - 1 |
|
4833 |
] ifFalse:[ |
|
4834 |
sz := lineSize + strLen |
|
4835 |
]. |
|
4836 |
||
4360 | 4837 |
newLine := stringType new:sz. |
4838 |
isText ifTrue:[ |
|
4839 |
newLine := Text string:newLine |
|
4328 | 4840 |
]. |
4841 |
||
4842 |
(lineSize ~~ 0) ifTrue: [ |
|
4843 |
(colNr > lineSize) ifTrue: [ |
|
4844 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4845 |
] ifFalse: [ |
|
4846 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4847 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4848 |
] |
|
4849 |
]. |
|
4850 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4851 |
]. |
4852 |
||
4853 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4854 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4855 |
]. |
4856 |
||
4771 | 4857 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4858 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4859 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4860 |
]. |
4861 |
self textChanged. |
|
4862 |
||
4360 | 4863 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4864 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4865 |
|
2752 | 4866 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4867 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4868 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4869 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4870 |
|
5216 | 4871 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4872 |
dragIsActive := false. |
4873 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4874 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4875 |
"/ 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
|
4876 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4877 |
]. |
4609 | 4878 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4879 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4880 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4881 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4882 |
|
4420 | 4883 |
"On X11, be nice and paste PRIMARY when middle click. |
4884 |
Note, that middle button on X11 is translated to button |
|
4885 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 4886 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4887 |
self undoableDo:[ |
4888 |
self paste: (self getClipboardText:#selection). |
|
4889 |
]. |
|
4890 |
^self. |
|
4891 |
]. |
|
4892 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4893 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4894 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4895 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4896 |
"/ 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
|
4897 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4898 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4899 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4900 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4901 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4902 |
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
|
4903 |
|
4420 | 4904 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4905 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4906 |
! |
4907 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4908 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4909 |
"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
|
4910 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4911 |
|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
|
4912 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4913 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4914 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4915 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4916 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4917 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4918 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4919 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4920 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4921 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4922 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4923 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4924 |
cursorType ~~ #block ifTrue:[ |
3790 | 4925 |
clickPos notNil ifTrue:[ |
4926 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4927 |
"/ (i.e. if its an ibeam). |
|
4928 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4929 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4930 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4931 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4932 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4933 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4934 |
]. |
5056 | 4935 |
"/ the following fixes the ugly select behavior when double clicking on |
4936 |
"/ a partially visible last line (where the first click used to |
|
4937 |
"/ scroll the text so that the second click was handled on another |
|
4938 |
"/ line. An alternative (possibly better) solution would be to |
|
4939 |
"/ remember the last click posision and adjust in the double click |
|
4940 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4941 |
"/ Time will show, if this hack works. |
|
5057 | 4942 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4943 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4944 |
Processor |
|
4945 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5742 | 4946 |
after:0.3 seconds. |
5057 | 4947 |
] ifFalse:[ |
4948 |
self cursorLine:clickLine col:newCursorCol. |
|
4949 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4950 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4951 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4952 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4953 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4954 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4955 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4956 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4957 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4958 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4959 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4960 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4961 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4962 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4963 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4964 |
] ifFalse:[ |
4048 | 4965 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4966 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4967 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4968 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4969 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4970 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4971 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4972 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4973 |
|
2580 | 4974 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4975 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4976 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4977 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4978 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4979 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4980 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4981 |
self changeTypeOfSelectionTo:nil. |
2580 | 4982 |
|
4983 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4984 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4985 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4986 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4987 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4988 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4989 |
self validateNewSelection. |
4420 | 4990 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4991 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4992 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4993 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4994 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4995 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4996 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4997 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4998 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4999 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5000 |
"/ 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
|
5001 |
"/ 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
|
5002 |
"/ 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
|
5003 |
"/ (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
|
5004 |
"/ 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
|
5005 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5006 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5007 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5008 |
]. |
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
|
5009 |
|
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
|
5010 |
"/ 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
|
5011 |
"/ 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
|
5012 |
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
|
5013 |
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
|
5014 |
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
|
5015 |
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
|
5016 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5017 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5018 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5019 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5020 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5021 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5022 |
^ self |
2580 | 5023 |
]. |
5024 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5025 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5026 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5027 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5028 |
selectionEndCol := cursorCol - 1. |
4970 | 5029 |
"/ selectionEndCol == 1 ifTrue:[ |
5030 |
"/ selectionEndCol := 0. |
|
5031 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5032 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5033 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5034 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5035 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5036 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5037 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5038 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5039 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5040 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5041 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5042 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5043 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5044 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5045 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5046 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5047 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5048 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5049 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5050 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5051 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5052 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5053 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5054 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5055 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5056 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5057 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5058 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5059 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5060 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5061 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5062 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5063 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5064 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5065 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5066 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5067 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5068 |
] 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
|
5069 |
"/ 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
|
5070 |
"/ 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
|
5071 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5072 |
"/ 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
|
5073 |
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
|
5074 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5075 |
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
|
5076 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5077 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5078 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5079 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5080 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5081 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5082 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5083 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5084 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5085 |
^ self |
2580 | 5086 |
]. |
5087 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5088 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5089 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5090 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5091 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5092 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5093 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5094 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5095 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5096 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5097 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5098 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5099 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5100 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5101 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5102 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5103 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5104 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5105 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5106 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5107 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5108 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5109 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5110 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5111 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5112 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5113 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5114 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5115 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5116 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5117 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5118 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5119 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5120 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5121 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5122 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5123 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5124 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5125 |
"/ 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
|
5126 |
"/ 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
|
5127 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5128 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5129 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5130 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5131 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5132 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5133 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5134 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5135 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5136 |
] 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
|
5137 |
"/ 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
|
5138 |
"/ 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
|
5139 |
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
|
5140 |
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
|
5141 |
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
|
5142 |
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
|
5143 |
^ 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
|
5144 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5145 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5146 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5147 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5148 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5149 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5150 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5151 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5152 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5153 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5154 |
] 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
|
5155 |
"/ 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
|
5156 |
"/ 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
|
5157 |
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
|
5158 |
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
|
5159 |
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
|
5160 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5161 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5162 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5163 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5164 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5165 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5166 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5167 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5168 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5169 |
]. |
2580 | 5170 |
]. |
4420 | 5171 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5172 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 5173 |
! |
5174 |
||
2952 | 5175 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5176 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5177 |
|
4521 | 5178 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 5179 |
#Replace #Undo #Redo #Accept |
3780 | 5180 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 5181 |
#DeleteSpaces #Join |
3780 | 5182 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 5183 |
#SelectWord #ExpandSelectionByWord |
3780 | 5184 |
#SelectToEnd #SelectFromBeginning |
4707 | 5185 |
#SelectLine #ExpandSelectionByLine |
3780 | 5186 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5187 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5188 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5189 |
#GotoLine #BeginOfText #EndOfText |
|
5190 |
#InsertLine #DeleteLine |
|
5191 |
#SelectLineFromBeginning |
|
5192 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5193 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5194 |
#'F*' #'f*')> |
2017 | 5195 |
|
4730 | 5196 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5197 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5198 |
|
5199 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5200 |
|
4701 | 5201 |
"/ experimental |
4818 | 5202 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5203 |
(immediateCompletion |
4818 | 5204 |
or:[currentUserPrefs codeCompletionOnControlKey |
5205 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5206 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5207 |
self initializeCompletionSupport. |
4609 | 5208 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5209 |
]. |
5394 | 5210 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5211 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5212 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5213 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5214 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5215 |
completionSupport notNil ifTrue:[ |
5394 | 5216 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5217 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5218 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5219 |
|
4818 | 5220 |
key isSymbol ifTrue:[ |
5643 | 5221 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 5222 |
lastReplacementInfo stillCollectingInput:false. |
5223 |
] |
|
5224 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5225 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5226 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5227 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5228 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5229 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5230 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5231 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5232 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5233 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5234 |
]. |
3799 | 5235 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5236 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5237 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5238 |
self learnMode ifTrue:[ |
4482 | 5239 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5240 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5241 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5242 |
|
4238 | 5243 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5244 |
"the macro named key exists" |
|
3780 | 5245 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5246 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5247 |
|
4482 | 5248 |
key isSymbol ifFalse:[ |
5249 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5250 |
self handleNonCommandKey:key. |
|
5251 |
^ self |
|
5252 |
]. |
|
5253 |
||
5254 |
event isNil ifTrue:[ |
|
5255 |
event := WindowGroup lastEventQuerySignal query. |
|
5256 |
]. |
|
5257 |
shiftPressed := event hasShift. |
|
5258 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5259 |
rawKey := event rawKey. |
4482 | 5260 |
|
5133 | 5261 |
key == #InsertUUID ifTrue:[ |
5262 |
self insertUUID. |
|
5263 |
^ self. |
|
5264 |
]. |
|
5265 |
||
4253 | 5266 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5267 |
self deleteWordBeforeCursor. |
|
5268 |
^ self. |
|
5269 |
]. |
|
5270 |
||
5119 | 5271 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5272 |
selectionStartLine notNil ifTrue:[ |
5273 |
((key == #BasicBackspace) |
|
4818 | 5274 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5275 |
ifTrue:[ |
5276 |
self deleteSelection. |
|
5277 |
] ifFalse: [ |
|
5278 |
self copyAndDeleteSelection. |
|
5279 |
]. |
|
4609 | 5280 |
] ifFalse:[ |
5281 |
self makeCursorVisible. |
|
5282 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5283 |
"/ self deleteWordBeforeCursor. |
|
5284 |
"/ ] ifFalse:[ |
|
5285 |
self deleteCharBeforeCursor. |
|
5286 |
"/ ]. |
|
3780 | 5287 |
]. |
4738 | 5288 |
true "immediateCompletion" ifTrue:[ |
5394 | 5289 |
completionSupport notNil ifTrue:[ |
5290 |
completionSupport postKeyPress:key |
|
5291 |
]. |
|
4731 | 5292 |
]. |
3780 | 5293 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5294 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5295 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5296 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5297 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5298 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5299 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5300 |
|
3235 | 5301 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5302 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5303 |
^ self. |
3160 | 5304 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5305 |
|
4162 | 5306 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5307 |
CharacterSetView notNil ifTrue:[ |
|
5308 |
self specialCharacters. |
|
5309 |
^ self. |
|
5310 |
] |
|
5311 |
]. |
|
5312 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5313 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5314 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5315 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5316 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5317 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5318 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5319 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5320 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5321 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5322 |
(('[fF][0-9]' match:key) |
5323 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5324 |
shiftPressed ifFalse:[ |
|
4818 | 5325 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5326 |
fKeyMacros notNil ifTrue:[ |
5327 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5328 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5329 |
^ self |
|
5330 |
] |
|
5331 |
] |
|
5332 |
] |
|
5333 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5334 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5335 |
|
2506 | 5336 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5337 |
self parenthizeSelectionWith:$( and:$). |
5338 |
^ self. |
|
2506 | 5339 |
]. |
5340 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5341 |
self parenthizeSelectionWith:$" and:$". |
5342 |
^ self. |
|
2506 | 5343 |
]. |
5344 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5345 |
self parenthizeSelectionWith:$' and:$'. |
5346 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5347 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5348 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5349 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5350 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5351 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5352 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5353 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5354 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5355 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5356 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5357 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5358 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5359 |
|
3542 | 5360 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5361 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5362 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5363 |
self makeCursorVisible. |
|
5364 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5365 |
^ self |
|
5366 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5367 |
(key == #SelectWord) ifTrue:[ |
3780 | 5368 |
self makeCursorVisible. |
5369 |
self selectWordUnderCursor. |
|
5370 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5371 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5372 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5373 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5374 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5375 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5376 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5377 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5378 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5379 |
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
|
5380 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5381 |
(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
|
5382 |
(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
|
5383 |
(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
|
5384 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5385 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5386 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5387 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5388 |
shiftPressed ifTrue: [ |
5389 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5390 |
"/ self unselect. |
|
5391 |
"/ self cursorHome. |
|
5392 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5393 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5394 |
"/ 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
|
5395 |
"/ 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
|
5396 |
"/ self selectFromBeginOfLine. |
3780 | 5397 |
] ifFalse: [ |
5398 |
self unselect. |
|
5399 |
ctrlPressed ifTrue:[ |
|
5400 |
self cursorHome. |
|
5401 |
] ifFalse:[ |
|
5402 |
self cursorToBeginOfLine. |
|
5403 |
] |
|
5404 |
]. |
|
5405 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5406 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5407 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5408 |
shiftPressed ifTrue:[ |
5409 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5410 |
"/ self unselect. |
|
5411 |
"/ self cursorToBottom |
|
4257 | 5412 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5413 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5414 |
"/ 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
|
5415 |
"/ 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
|
5416 |
"/ self selectToEndOfLine. |
3780 | 5417 |
] ifFalse:[ |
5418 |
self unselect. |
|
5419 |
ctrlPressed ifTrue:[ |
|
5420 |
self cursorToBottom |
|
5421 |
] ifFalse:[ |
|
5422 |
self cursorToEndOfLine. |
|
5423 |
] |
|
5424 |
]. |
|
5425 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5426 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5427 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5428 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5429 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5430 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5431 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5432 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5433 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5434 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5435 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5436 |
]. |
3310 | 5437 |
(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
|
5438 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5439 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5440 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5441 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5442 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5443 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5444 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5445 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5446 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5447 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5448 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5449 |
|
5119 | 5450 |
(rawKey == #CursorRight |
5451 |
or:[rawKey == #CursorDown |
|
5452 |
or:[rawKey == #CursorLeft |
|
5453 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5454 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5455 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5456 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5457 |
|
5119 | 5458 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5459 |
self unselect. self cursorReturn. |
5460 |
^ self |
|
3257 | 5461 |
]. |
5462 |
||
5463 |
(key == #Return) ifTrue:[ |
|
3780 | 5464 |
shiftPressed ifTrue:[ |
5465 |
self unselect. self cursorReturn. |
|
5466 |
^ self |
|
5467 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5468 |
|
3780 | 5469 |
self isReadOnly ifTrue:[ |
5470 |
self unselect; makeCursorVisible. |
|
5471 |
self cursorReturn |
|
5472 |
] ifFalse:[ |
|
5473 |
self isInInsertMode ifFalse:[ |
|
5529 | 5474 |
self cursorReturn:true. |
3780 | 5475 |
autoIndent == true ifTrue:[ |
5476 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5477 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5478 |
self cursorCol:(i+1 max:1) |
5479 |
] |
|
3780 | 5480 |
] |
5481 |
] ifTrue:[ |
|
4826 | 5482 |
|left right oldIndent| |
4812 | 5483 |
|
3780 | 5484 |
"/ old version just unselected ... |
5485 |
"/ self unselect; makeCursorVisible. |
|
5486 |
||
5487 |
"/ new version deletes ... |
|
5488 |
typeOfSelection == #paste ifTrue:[ |
|
5489 |
self unselect; makeCursorVisible. |
|
5490 |
] ifFalse:[ |
|
5491 |
self copyAndDeleteSelection. |
|
5492 |
]. |
|
4816 | 5493 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5494 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5495 |
self insertCharAtCursor:(Character cr). |
5112 | 5496 |
|
3780 | 5497 |
autoIndent == true ifTrue:[ |
4816 | 5498 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5499 |
"/ nothing to do. |
|
4812 | 5500 |
] ifFalse:[ |
5501 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5502 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5503 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5504 |
left := left withoutSeparators. |
5505 |
right := right withoutSeparators. |
|
5506 |
(left endsWith:'[') ifTrue:[ |
|
5507 |
"/ i := i + 4. |
|
4816 | 5508 |
] ifFalse:[ |
4823 | 5509 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5510 |
i := i - 4. |
5511 |
]. |
|
4812 | 5512 |
]. |
4826 | 5513 |
oldIndent := self leftIndentOfLine:cursorLine. |
5514 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5515 |
self st80EditMode ifTrue:[ |
|
5516 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5517 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5518 |
]. |
|
5519 |
]. |
|
4812 | 5520 |
self cursorCol:(i+1 max:1) |
5521 |
]. |
|
5522 |
] |
|
3780 | 5523 |
]. |
5524 |
]. |
|
5525 |
]. |
|
5526 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5527 |
]. |
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
|
5528 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5529 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5530 |
self unselect. self cursorTab. |
5531 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5532 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5533 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5534 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5535 |
||
5536 |
self hasSelection ifTrue:[ |
|
5537 |
selectStyle == #line ifTrue:[ |
|
4238 | 5538 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5539 |
macroName := #IndentBy4. |
|
5540 |
] ifFalse:[ |
|
5541 |
macroName := #UndentBy4. |
|
5542 |
]. |
|
5543 |
macroName notNil ifTrue:[ |
|
5544 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5545 |
]. |
5546 |
] |
|
5547 |
]. |
|
5548 |
||
5549 |
self unselect. |
|
5550 |
(key == #Tab) ifTrue:[ |
|
5551 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5552 |
self cursorTab. |
|
5553 |
^ self |
|
5554 |
]. |
|
5555 |
self insertTabAtCursor. |
|
5556 |
^ self |
|
5557 |
]. |
|
5558 |
self cursorBacktab. |
|
5559 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5560 |
]. |
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
|
5561 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5562 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5563 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5564 |
shiftPressed ifTrue:[ |
5565 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5566 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5567 |
self makeCursorVisible. |
|
5568 |
self deleteCharAtCursor. |
|
5569 |
]. |
|
5570 |
^ self |
|
5571 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5572 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5573 |
|
5119 | 5574 |
(rawKey == #Delete |
870 | 5575 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5576 |
selectionStartLine notNil ifTrue:[ |
4130 | 5577 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5578 |
"/ To remove text repetetively, use Cut instead. |
|
5579 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5580 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5581 |
((key == #BasicDelete) |
4818 | 5582 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5583 |
self deleteSelection. |
5584 |
] ifFalse:[ |
|
5585 |
self copyAndDeleteSelection. |
|
5586 |
]. |
|
5587 |
^ self |
|
5588 |
]. |
|
5589 |
self makeCursorVisible. |
|
5590 |
self deleteCharAtCursor. |
|
5591 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
]. |
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
|
5593 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5594 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5595 |
self unselect. |
5596 |
cursorVisibleLine == 1 ifTrue:[ |
|
5597 |
self cursorHome. |
|
5598 |
] ifFalse:[ |
|
5599 |
self cursorToFirstVisibleLine |
|
5600 |
]. |
|
5601 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5602 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5603 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5604 |
self unselect. |
5605 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5606 |
self cursorToBottom. |
|
5607 |
] ifFalse:[ |
|
5608 |
self cursorToLastVisibleLine |
|
5609 |
]. |
|
5610 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5611 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5612 |
((key == #Escape) |
3257 | 5613 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5614 |
self makeCursorVisible. |
5615 |
self unselect. self selectCursorLineFromBeginning. |
|
5616 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5617 |
]. |
3257 | 5618 |
(key == #SelectLine) ifTrue:[ |
3780 | 5619 |
self makeCursorVisible. |
5620 |
self unselect. self selectCursorLine. |
|
5621 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5622 |
]. |
3257 | 5623 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5624 |
"/ self makeCursorVisible. |
3780 | 5625 |
self selectExpandCursorLine. |
5626 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
]. |
3257 | 5628 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5629 |
self makeCursorVisible. |
5630 |
self unselect. self deleteCursorLine. |
|
5631 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
]. |
3257 | 5633 |
(key == #InsertLine) ifTrue:[ |
3780 | 5634 |
self makeCursorVisible. |
5635 |
self unselect. self insertLine:nil before:cursorLine. |
|
5636 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
]. |
3781 | 5638 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5639 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5640 |
|
3310 | 5641 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5642 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5643 |
"Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5644 |
! |
5645 |
||
2952 | 5646 |
executeKeyboardMacro:cmdMacro |
5647 |
Error handle:[:ex | |
|
4823 | 5648 |
self warn:'Error in keyboard macro: ' , ex description. |
5649 |
ex return. |
|
2952 | 5650 |
] do:[ |
4823 | 5651 |
AbortOperationRequest handle:[:ex | |
5652 |
self warn:'Keyboard macro aborted'. |
|
5653 |
ex return. |
|
5654 |
] do:[ |
|
5655 |
Parser |
|
5656 |
evaluate:cmdMacro asString |
|
5657 |
receiver:self |
|
5658 |
notifying:nil |
|
5659 |
compile:false. |
|
5660 |
]. |
|
2952 | 5661 |
]. |
5662 |
! |
|
5663 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5664 |
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
|
5665 |
| 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
|
5666 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5667 |
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
|
5668 |
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
|
5669 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5670 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5671 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5672 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5673 |
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
|
5674 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5675 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5676 |
"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
|
5677 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5678 |
(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
|
5679 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5680 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5681 |
(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
|
5682 |
(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
|
5683 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5684 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5685 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5686 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5687 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5688 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5689 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5690 |
"/ 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
|
5691 |
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
|
5692 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5693 |
"/ 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
|
5694 |
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
|
5695 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5696 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5697 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5698 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5699 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5700 |
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
|
5701 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5702 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5703 |
! |
5704 |
||
5705 |
handleNonCommandKey:keyArg |
|
4700 | 5706 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5707 |
|
5708 |
self isReadOnly ifTrue:[ |
|
4988 | 5709 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5710 |
^ self. |
2952 | 5711 |
]. |
5712 |
||
5713 |
key := keyArg. |
|
5714 |
||
5715 |
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
|
5716 |
"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
|
5717 |
|
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
|
5718 |
"/ 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
|
5719 |
"/ 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
|
5720 |
"/ 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
|
5721 |
"/ 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
|
5722 |
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
|
5723 |
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
|
5724 |
|
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
|
5725 |
"/ 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
|
5726 |
self unselect. |
2952 | 5727 |
]. |
5728 |
||
4700 | 5729 |
selStartLineBefore := selectionStartLine. |
5730 |
selStartColBefore := self selectionStartCol. |
|
5731 |
selEndLineBefore := selectionEndLine. |
|
5732 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5733 |
|
4940 | 5734 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5735 |
key isCharacter ifTrue:[ |
4940 | 5736 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5737 |
] ifFalse:[ |
4940 | 5738 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5739 |
]. |
2952 | 5740 |
]. |
5741 |
||
5742 |
"replace selection by what is typed in - |
|
3235 | 5743 |
if word was selected with a space, keep it. |
4700 | 5744 |
if there was no selection, the key's character is inserted" |
3235 | 5745 |
|
5746 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5747 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5748 |
]. |
2952 | 5749 |
|
5750 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5751 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5752 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5753 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5754 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5755 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5756 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5757 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5758 |
] |
3160 | 5759 |
]. |
2952 | 5760 |
selectStyle := nil. |
5761 |
||
3235 | 5762 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5763 |
selectionStartLine := selStartLineBefore. |
5764 |
selectionStartCol := selStartColBefore. |
|
5765 |
selectionEndLine := selEndLineBefore. |
|
5766 |
selectionEndCol := selEndColBefore. |
|
3235 | 5767 |
]. |
5768 |
||
2952 | 5769 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5770 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5771 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5772 |
"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
|
5773 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5774 |
" |
2952 | 5775 |
" |
4481 | 5776 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5777 |
" |
4481 | 5778 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5779 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5780 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5781 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5782 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5783 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5784 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5785 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5786 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5787 |
self cursorLine:line col:col. |
4940 | 5788 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5789 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5790 |
"/ 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
|
5791 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5792 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5793 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5794 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5795 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5796 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5797 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5798 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5799 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5800 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5801 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5802 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5803 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5804 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5805 |
] |
2952 | 5806 |
]. |
5807 |
||
5808 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5809 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5810 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5811 |
"/ |
|
5812 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5813 |
"/ self selection. |
|
5814 |
"/ typeOfSelection := #paste. |
|
3160 | 5815 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5816 |
"/ ]. |
3235 | 5817 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5818 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5819 |
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
|
5820 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5821 |
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
|
5822 |
]. |
3235 | 5823 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5824 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5825 |
|
5826 |
"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
|
5827 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5828 |
! |
5829 |
||
5830 |
keyPress:key x:x y:y |
|
5831 |
"handle keyboard input" |
|
5832 |
||
4771 | 5833 |
|wasOn| |
5834 |
||
5835 |
wasOn := cursorShown. |
|
5836 |
||
5689 | 5837 |
NoModificationError |
5838 |
handle:[:ex | |
|
5839 |
self flashReadOnly. |
|
5840 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
5841 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5842 |
]. |
|
5843 |
] |
|
5844 |
do:[ |
|
5845 |
self undoableDo:[ |
|
5846 |
self doKeyPress:key x:x y:y |
|
5847 |
]. |
|
5848 |
]. |
|
5849 |
||
4242 | 5850 |
self repairDamage |
5851 |
||
5852 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 5853 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 5854 |
! |
5855 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5856 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5857 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5859 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5860 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5861 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5862 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5863 |
requestAutoAccept |
5068 | 5864 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5865 |
This forces my value to be accepted into my model. |
|
5866 |
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
|
5867 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5868 |
acceptEnabled == false ifTrue:[ |
4823 | 5869 |
"/ nope - |
5870 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5871 |
]. |
5404 | 5872 |
"/ cg: only do this if modified. |
5873 |
"/ otherwise, users would have to make sure that the contents is |
|
5874 |
"/ always correct (which they don't). If you change this back, |
|
5875 |
"/ please check the expecco file-save or file-reimport dialog, |
|
5876 |
"/ which has a problem with that behavior. |
|
5877 |
self modified ifTrue:[ |
|
5878 |
self accept. |
|
5879 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5880 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5881 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5882 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5883 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5884 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5886 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5887 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5888 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5889 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5890 |
cv notNil ifTrue:[ |
4823 | 5891 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5892 |
] |
4967 | 5893 |
! |
5894 |
||
5895 |
unmapped |
|
5896 |
super unmapped. |
|
5897 |
||
5898 |
completionSupport notNil ifTrue:[ |
|
5899 |
completionSupport release. |
|
5900 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5901 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5902 |
|
1807 | 5903 |
!EditTextView methodsFor:'focus handling'! |
5904 |
||
4818 | 5905 |
focusOut |
5906 |
super focusOut. |
|
5907 |
||
5908 |
completionSupport notNil ifTrue:[ |
|
5909 |
completionSupport release. |
|
5910 |
]. |
|
5911 |
! |
|
5912 |
||
1807 | 5913 |
hasKeyboardFocus:aBoolean |
5914 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5915 |
(otherwise, I would not know about this)" |
|
5916 |
||
5917 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5918 |
|
3160 | 5919 |
(cursorShown |
5920 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5921 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5922 |
self drawCursor |
5923 |
]. |
|
5924 |
||
5925 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5926 |
completionSupport notNil ifTrue:[ |
4821 | 5927 |
"/ this is a hack for Windows: |
5928 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5929 |
"/ then an activate is sent to the completion popup. |
|
5930 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5931 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5932 |
"/ before forcing it to be closed... |
|
5773 | 5933 |
completionSupport startTimeoutForEditViewLostFocus. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5934 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5935 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5936 |
|
4821 | 5937 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5938 |
! |
5939 |
||
5940 |
showFocus:explicit |
|
5941 |
"in addition to however my superclass thinks how a focusView is to be |
|
5942 |
displayed, show the cursor when I got the focus" |
|
5943 |
||
5239 | 5944 |
self hasKeyboardFocus:true. |
1807 | 5945 |
self showCursor. |
5946 |
super showFocus:explicit |
|
5947 |
||
5948 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5949 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5950 |
|
4967 | 5951 |
showNoFocus:explicit |
5952 |
"the view lost the keyboard focus |
|
5953 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5954 |
- change any display attributes as req'd." |
|
5955 |
||
5956 |
super showNoFocus:explicit. |
|
5149 | 5957 |
|
5958 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
5959 |
"/ not when the focus is lost normally (because this also happens when |
|
5960 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
5961 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
5962 |
explicit ifTrue:[ |
|
5963 |
completionSupport notNil ifTrue:[ |
|
5964 |
completionSupport release. |
|
5965 |
]. |
|
4818 | 5966 |
]. |
5967 |
! |
|
5968 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5969 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5970 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5971 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5972 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5973 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5974 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5975 |
and:[self enabled |
4781 | 5976 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5977 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5978 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5979 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5980 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5981 |
^ false |
1807 | 5982 |
! ! |
5983 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5984 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5985 |
|
4237 | 5986 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5987 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5988 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5989 |
|
4482 | 5990 |
|cmdMacro| |
5991 |
||
5992 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5993 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5994 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5995 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5996 |
^ true |
4238 | 5997 |
|
5998 |
" |
|
4483 | 5999 |
EditTextView open |
4238 | 6000 |
contents:'bla'; |
6001 |
selectAll; |
|
6002 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6003 |
EditTextView open |
4238 | 6004 |
contents:'bla'; |
6005 |
selectAll; |
|
6006 |
executekeyboardMacroNamed:#blabla. |
|
6007 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6008 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6009 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6010 |
! |
6011 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6012 |
indent |
3221 | 6013 |
"indent a line-range - this is done by searching for the |
6014 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6015 |
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
|
6016 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6017 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6018 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6019 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6020 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6021 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6022 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6023 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 6024 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6025 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6026 |
self unselect. |
3160 | 6027 |
self |
3786 | 6028 |
undoableDo:[self indentFromLine:start toLine:end] |
6029 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6030 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6031 |
|
4237 | 6032 |
indentBy4 |
5050 | 6033 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6034 |
||
6035 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6036 |
! |
|
6037 |
||
6038 |
indentBy8 |
|
6039 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6040 |
|
6041 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6042 |
! |
|
6043 |
||
5050 | 6044 |
indentBy:n |
6045 |
|line1 line2| |
|
6046 |
||
6047 |
line1 := self selectionStartLine. |
|
6048 |
line2 := self selectionEndLine. |
|
6049 |
line1 isNil ifTrue:[ |
|
6050 |
line1 := self cursorLine. |
|
6051 |
line1 notNil ifTrue:[ |
|
6052 |
line2 := line1+1 |
|
6053 |
] |
|
5769 | 6054 |
] ifFalse:[ |
6055 |
line2 notNil ifTrue:[ |
|
6056 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
6057 |
]. |
|
6058 |
]. |
|
5050 | 6059 |
line1 notNil ifTrue:[ |
6060 |
self indentFromLine:line1 toLine:line2 by:n. |
|
6061 |
] |
|
6062 |
! |
|
6063 |
||
6064 |
indentByTab |
|
6065 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6066 |
! |
|
6067 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6068 |
indentFromLine:start toLine:end |
3221 | 6069 |
"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
|
6070 |
last non-empty line before start, and change the indent |
4742 | 6071 |
of the selected line-range based on that line's indent." |
6072 |
||
4811 | 6073 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6074 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6075 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6076 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6077 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6078 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6079 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6080 |
self indentFromLine:start toLine:end by:delta |
6081 |
! |
|
6082 |
||
6083 |
indentFromLine:start toLine:end by:delta |
|
6084 |
"indent a line-range - this is done by searching for the |
|
6085 |
last non-empty line before start, and change the indent |
|
6086 |
of the selected line-range based on that line's indent." |
|
6087 |
||
6088 |
|d line spaces anyChange| |
|
6089 |
||
6090 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6091 |
(delta > 0) ifTrue:[ |
4742 | 6092 |
spaces := String new:delta |
6093 |
]. |
|
6094 |
||
6095 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6096 |
start to:end do:[:lineNr | |
4742 | 6097 |
line := self listAt:lineNr. |
6098 |
line notNil ifTrue:[ |
|
6099 |
line isBlank ifTrue:[ |
|
4771 | 6100 |
self basicListAt:lineNr put:nil |
4742 | 6101 |
] ifFalse:[ |
6102 |
(delta > 0) ifTrue:[ |
|
6103 |
line := spaces , line. |
|
6104 |
widthOfWidestLine notNil ifTrue:[ |
|
6105 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6106 |
] |
|
6107 |
] ifFalse:[ |
|
6108 |
"check if deletion is ok" |
|
6109 |
d := delta negated + 1. |
|
6110 |
||
6111 |
line size > d ifTrue:[ |
|
6112 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6113 |
line := line copyFrom:d |
|
6114 |
] |
|
6115 |
]. |
|
6116 |
widthOfWidestLine := nil |
|
6117 |
]. |
|
6118 |
self replaceLine:lineNr with:line. |
|
6119 |
anyChange := true. |
|
6120 |
] |
|
6121 |
] |
|
6122 |
]. |
|
6123 |
||
6124 |
anyChange ifTrue:[ self textChanged ]. |
|
6125 |
||
3221 | 6126 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6127 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6128 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6129 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6130 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6131 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6132 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6133 |
this is done by searching for the last non-empty line before it |
4823 | 6134 |
and returning its indent. |
6135 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6136 |
|
827 | 6137 |
"SHOULD GO TO ListView" |
6138 |
||
6139 |
|line lnr indent| |
|
6140 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6141 |
lnr := lineNr. |
827 | 6142 |
|
4823 | 6143 |
"/ [lnr ~~ 1] whileTrue:[ |
6144 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 6145 |
lnr := lnr - 1. |
6146 |
line := self listAt:lnr. |
|
6147 |
||
6148 |
line notNil ifTrue:[ |
|
6149 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
6150 |
indent ~~ 0 ifTrue:[ |
|
6151 |
(line endsWith:$[) ifTrue:[ |
|
6152 |
^ indent + 4 - 1 |
|
6153 |
]. |
|
6154 |
^ indent - 1 |
|
6155 |
] |
|
6156 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6157 |
]. |
827 | 6158 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6159 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6160 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 6161 |
! |
6162 |
||
6163 |
undentBy4 |
|
5050 | 6164 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6165 |
||
6166 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6167 |
! |
|
6168 |
||
6169 |
undentBy8 |
|
6170 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6171 |
|
6172 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6173 |
! |
6174 |
||
6175 |
undentBy:n |
|
6176 |
self indentBy:(n negated) |
|
6177 |
! |
|
6178 |
||
6179 |
undentByTab |
|
6180 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6181 |
! ! |
6182 |
||
0 | 6183 |
!EditTextView methodsFor:'initialization'! |
6184 |
||
941 | 6185 |
fetchDeviceResources |
6186 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6187 |
||
6188 |
super fetchDeviceResources. |
|
6189 |
||
5643 | 6190 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6191 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6192 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6193 |
|
6194 |
"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
|
6195 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6196 |
! |
6197 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6198 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6199 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6200 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6201 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6202 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6203 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6204 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6205 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6206 |
"initialize style specific stuff" |
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 |
super initStyle. |
4576 | 6209 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6210 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6211 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6212 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6213 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6214 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6215 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6216 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6217 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6218 |
cursorTypeNoFocus := cursorType. |
|
6219 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6220 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6221 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6222 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6223 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6224 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6225 |
cursorType ~~ #block ifTrue:[ |
6226 |
cursorNoFocusFgColor := cursorBgColor |
|
6227 |
] ifFalse:[ |
|
6228 |
cursorNoFocusFgColor := cursorFgColor |
|
6229 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6230 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6231 |
|
2088 | 6232 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6233 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6234 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6235 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6236 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6237 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6239 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6241 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6242 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6243 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6244 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6245 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6246 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6247 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6248 |
cursorCol := 1. |
5251 | 6249 |
cursorLineHolder := ValueHolder with:1. |
6250 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6251 |
modifiedChannel := ValueHolder with:false. |
6252 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6253 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6254 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6255 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6256 |
tabMeansNextField := false. |
5106 | 6257 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6258 |
autoIndent := false. |
|
5251 | 6259 |
editMode := ValueHolder with:EditMode insertMode. |
6260 |
learnMode := ValueHolder with:false. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6261 |
trimBlankLines := self st80EditMode not. |
2131 | 6262 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6263 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6264 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6265 |
"/ enable drop by default |
2589 | 6266 |
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
|
6267 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6268 |
undoSupport := UndoSupport for:self. |
5251 | 6269 |
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
|
6270 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6271 |
"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
|
6272 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6273 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6274 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6275 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6276 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6277 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6278 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6279 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6280 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6281 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6282 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6283 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6284 |
! |
6285 |
||
6286 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6287 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6288 |
completionSupport release |
4771 | 6289 |
]. |
6290 |
super release |
|
0 | 6291 |
! ! |
6292 |
||
2580 | 6293 |
!EditTextView methodsFor:'macros'! |
6294 |
||
6295 |
executeLearnedKeyboardMacro |
|
4673 | 6296 |
"replay the characters as learned previously" |
6297 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6298 |
(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
|
6299 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6300 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6301 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6302 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6303 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6304 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6305 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6306 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6307 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6308 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6309 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6310 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6311 |
]. |
2580 | 6312 |
] ifFalse:[ |
5153 | 6313 |
self flash:'no macro'. |
2580 | 6314 |
]. |
6315 |
! |
|
6316 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6317 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6318 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6319 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6320 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6321 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6322 |
|
2580 | 6323 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6324 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6325 |
|
2580 | 6326 |
|fg bg| |
6327 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6328 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6329 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6330 |
aBoolean ifTrue:[ |
5795 | 6331 |
learnedMacro := OrderedCollection new. |
6332 |
fg := self whiteColor. |
|
6333 |
bg := self blackColor. |
|
2580 | 6334 |
] ifFalse:[ |
5795 | 6335 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6336 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6337 |
]. |
6338 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6339 |
! |
|
6340 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6341 |
learnModeHolder |
4673 | 6342 |
"a holder returning true, if in learn mode" |
6343 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6344 |
learnMode isNil ifTrue:[ |
5251 | 6345 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6346 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6347 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6348 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6349 |
|
4673 | 6350 |
rememberLearnedMacroAs: nameString |
6351 |
Macros isNil ifTrue:[ |
|
6352 |
Macros := Dictionary new. |
|
6353 |
]. |
|
6354 |
Macros at:nameString put:learnedMacro |
|
6355 |
! |
|
6356 |
||
2580 | 6357 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6358 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6359 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6360 |
self learnMode:(self learnMode not). |
2580 | 6361 |
! ! |
6362 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6363 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6364 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6365 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6366 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6367 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6368 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6369 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6370 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6371 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6372 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6373 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
6374 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 6375 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
6376 |
] do:[ |
|
6377 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
6378 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6379 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6380 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6381 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6382 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6383 |
self unselect. |
3799 | 6384 |
self |
6385 |
undoablePaste:translated |
|
6386 |
info:'Translate' |
|
3495 | 6387 |
|
6388 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6389 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6390 |
|
3517 | 6391 |
compareWithClipboard |
6392 |
"compare the selection against the clipboard contents" |
|
6393 |
||
6394 |
|t1 t2| |
|
6395 |
||
6396 |
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
|
6397 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6398 |
Dialog information:'Clipboard is empty.'. |
6399 |
^ self. |
|
3517 | 6400 |
]. |
6401 |
||
6402 |
self hasSelection ifTrue:[ |
|
4823 | 6403 |
t1 := self selectionAsString. |
3517 | 6404 |
] ifFalse:[ |
4823 | 6405 |
t1 := self contents asString |
3517 | 6406 |
]. |
6407 |
t1 := t1 string. |
|
6408 |
||
6409 |
t1 = t2 ifTrue:[ |
|
4823 | 6410 |
Dialog information:'Strings are equal.'. |
6411 |
^ self. |
|
3517 | 6412 |
]. |
6413 |
DiffTextView |
|
4823 | 6414 |
openOn:t1 label:'Editor' |
6415 |
and:t2 label:'Clipboard' |
|
3517 | 6416 |
! |
6417 |
||
5689 | 6418 |
copySelection |
6419 |
"copy contents into smalltalk copybuffer. |
|
6420 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6421 |
||
6422 |
self hasSelection ifTrue:[ |
|
6423 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6424 |
]. |
|
6425 |
super copySelection. |
|
6426 |
||
6427 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6428 |
! |
|
6429 |
||
121 | 6430 |
cut |
6431 |
"cut selection into copybuffer" |
|
6432 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6433 |
self deleteCopyToClipboard:true |
121 | 6434 |
! |
6435 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6436 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6437 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6438 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6439 |
cursorLine notNil ifTrue:[ |
4823 | 6440 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6441 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6442 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6443 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6444 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6445 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6446 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6447 |
|
4129 | 6448 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6449 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6450 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6451 |
self flashReadOnly. |
3786 | 6452 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6453 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6454 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6455 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6456 |
sel notNil ifTrue:[ |
4129 | 6457 |
self setLastStringToReplace: sel. |
4053 | 6458 |
|
3786 | 6459 |
line := selectionStartLine. |
6460 |
col := selectionStartCol. |
|
6461 |
||
6462 |
toClipboard ifTrue:[ |
|
6463 |
" |
|
6464 |
remember in CopyBuffer |
|
6465 |
" |
|
6466 |
self setClipboardText:sel. "/ lastString. |
|
6467 |
]. |
|
6468 |
||
6469 |
" |
|
6470 |
append to DeleteHistory (if there is one) |
|
6471 |
" |
|
6472 |
history := Smalltalk at:#DeleteHistory. |
|
6473 |
history notNil ifTrue:[ |
|
6474 |
history addAll:(sel asStringCollection). |
|
6475 |
history size > 1000 ifTrue:[ |
|
6476 |
history := history copyFrom:(history size - 1000) |
|
6477 |
]. |
|
6478 |
]. |
|
6479 |
||
6480 |
" |
|
6481 |
now, delete it |
|
6482 |
" |
|
6483 |
self |
|
6484 |
undoableDo:[self deleteSelection] |
|
6485 |
info:'Delete'. |
|
4048 | 6486 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6487 |
] ifFalse:[ |
3786 | 6488 |
" |
6489 |
a cut without selection will search&cut again |
|
6490 |
" |
|
6491 |
self undoableDo:[ |
|
6492 |
self again |
|
6493 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6494 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6495 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6496 |
"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
|
6497 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6498 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6499 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6500 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6501 |
|
3781 | 6502 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
6503 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 6504 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6505 |
#ToggleAutoIndent #ToggleInsertMode |
6506 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6507 |
<resource: #programMenu> |
1054 | 6508 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6509 |
|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
|
6510 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6511 |
|
2460 | 6512 |
items := #( |
3781 | 6513 |
('Redo' redo Redo ) |
6514 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 6515 |
('-' ) |
6516 |
('Search...' search Find ) |
|
6517 |
('Goto Line...' gotoLine GotoLine ) |
|
6518 |
('-' ) |
|
4940 | 6519 |
('Tools' tools ) |
5529 | 6520 |
('Font...' changeFont ) |
4940 | 6521 |
('Insert Unicode...' insertUnicode ) |
6522 |
). |
|
4213 | 6523 |
CharacterSetView notNil ifTrue:[ |
6524 |
items := items , |
|
6525 |
#( |
|
6526 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6527 |
). |
|
6528 |
]. |
|
6529 |
items := items , #( |
|
3731 | 6530 |
('-' ) |
6531 |
('Save As...' save SaveAs ) |
|
6532 |
('Print' doPrint Print ) |
|
6533 |
('=' ) |
|
4213 | 6534 |
('Misc' misc ShiftCtrl) ). |
2460 | 6535 |
|
2866 | 6536 |
miscItems := #( |
3781 | 6537 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6538 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 6539 |
('-' ) |
6540 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 6541 |
('Join Lines' joinLines Join ) |
4388 | 6542 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 6543 |
('-' ) |
3781 | 6544 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
6545 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6546 |
('-' ) |
3811 | 6547 |
('Insert File...' insertFile ) |
6548 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6549 |
('Insert new UUID' insertUUID ) |
6550 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6551 |
('-' ) |
6552 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6553 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6554 |
). |
4213 | 6555 |
"/ CharacterSetView notNil ifTrue:[ |
6556 |
"/ miscItems := miscItems , |
|
6557 |
"/ #( |
|
5529 | 6558 |
"/ ('-' ) |
4213 | 6559 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6560 |
"/ ('Font...' changeFont ) |
4213 | 6561 |
"/ ). |
5529 | 6562 |
"/ ] ifFalse:[ |
6563 |
"/ miscItems := miscItems , |
|
6564 |
"/ #( |
|
6565 |
"/ ('Font...' changeFont ) |
|
6566 |
"/"/ ('Encoding...' changeEncoding ) |
|
6567 |
"/ ). |
|
6568 |
"/ ]. |
|
2866 | 6569 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6570 |
translateItems := #( |
3731 | 6571 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6572 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6573 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6574 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6575 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6576 |
('-' ) |
|
6577 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6578 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6579 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6580 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6581 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6582 |
). |
|
3221 | 6583 |
|
6584 |
sortItems := #( |
|
3731 | 6585 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6586 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6587 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6588 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6589 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6590 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6591 |
('-' ) |
|
4373 | 6592 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6593 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6594 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6595 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6596 |
('-' ) |
6597 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6598 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6599 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6600 |
|
2762 | 6601 |
toolItems := #( |
3731 | 6602 |
('Indent' indent ) |
4287 | 6603 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6604 |
('Sort' sort ) |
5370 | 6605 |
('Split...' splitLinesAtCharacterOrString ) |
3731 | 6606 |
('-' ) |
4742 | 6607 |
('Google Spell Check' googleSpellingSuggestion ) |
6608 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6609 |
('Translate' babelFishTranslate ) |
6610 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6611 |
). |
|
2762 | 6612 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6613 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6614 |
toolItems := toolItems , #( |
6615 |
('-' ) |
|
6616 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6617 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
5578 | 6618 |
('Inspect Selected String' inspectSelectedString ) |
3731 | 6619 |
). |
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6620 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6621 |
|
2460 | 6622 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6623 |
sub receiver:self. |
2460 | 6624 |
|
2919 | 6625 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6626 |
toolSub receiver:self. |
|
6627 |
sub subMenuAt:#tools put:toolSub. |
|
6628 |
||
3495 | 6629 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6630 |
transSub receiver:self. |
|
6631 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6632 |
||
6633 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6634 |
sortSub receiver:self. |
|
6635 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6636 |
|
2866 | 6637 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6638 |
subSub receiver:self. |
|
2952 | 6639 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6640 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6641 |
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
|
6642 |
|
2866 | 6643 |
sub subMenuAt:#misc put:subSub. |
6644 |
||
3495 | 6645 |
mainItems := #( |
3731 | 6646 |
('Undo' undo Undo ) |
6647 |
('Again' again Again ) |
|
6648 |
('-' ) |
|
6649 |
('Cut' cut Cut ) |
|
6650 |
('Copy' copySelection Copy ) |
|
6651 |
('Paste' pasteOrReplace Paste ) |
|
6652 |
('-' ) |
|
6653 |
('Accept' accept Accept ) |
|
6654 |
('=' ) |
|
6655 |
('More' others Ctrl ) |
|
6656 |
). |
|
3495 | 6657 |
main := PopUpMenu itemList:mainItems resources:resources. |
6658 |
main subMenuAt:#others put:sub. |
|
6659 |
||
6660 |
sensor := self sensor. |
|
6661 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6662 |
sensor shiftDown ifTrue:[ |
|
3731 | 6663 |
m := subSub |
6664 |
] ifFalse:[ |
|
6665 |
m := sub |
|
6666 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6667 |
] ifFalse:[ |
3731 | 6668 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6669 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6670 |
|
4742 | 6671 |
"/ the 'Smalltalk at:' code is here to |
6672 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6673 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6674 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6675 |
m disable:#googleSpellingSuggestion |
|
2676 | 6676 |
]. |
4742 | 6677 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6678 |
m disable:#internalSpellingSuggestion |
|
6679 |
]. |
|
2676 | 6680 |
|
3811 | 6681 |
HTTPInterface isNil ifTrue:[ |
6682 |
m disableAll:#(insertURL) |
|
6683 |
]. |
|
6684 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6685 |
self isReadOnly ifTrue:[ |
4475 | 6686 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6687 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6688 |
cut indent autoIndent: insertMode: |
|
3811 | 6689 |
insertFile insertFileAsStringLiteral insertURL |
6690 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6691 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6692 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
4940 | 6693 |
insertUnicode specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6694 |
]. |
2817 | 6695 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6696 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6697 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6698 |
self hasSelection ifFalse:[ |
5371 | 6699 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5578 | 6700 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 6701 |
] ifTrue:[ |
3731 | 6702 |
(Error handle:[:ex | |
6703 |
ex return:false |
|
6704 |
] do:[ |
|
4042 | 6705 |
|fn| |
6706 |
fn := self selectionAsString. |
|
6707 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6708 |
]) ifFalse:[ |
6709 |
m disableAll:#(openFileBrowserOnIt). |
|
6710 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6711 |
]. |
2569 | 6712 |
self hasUndoAction ifFalse:[ |
3731 | 6713 |
m disable:#undo. |
3115 | 6714 |
] ifTrue:[ |
3731 | 6715 |
what := undoSupport undoActionInfo. |
6716 |
what notNil ifTrue:[ |
|
6717 |
undoIdx := m indexOf:#undo. |
|
6718 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6719 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6720 |
]. |
2952 | 6721 |
self hasRedoAction ifFalse:[ |
3731 | 6722 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6723 |
] ifTrue:[ |
3731 | 6724 |
what := undoSupport redoActionInfo. |
6725 |
what notNil ifTrue:[ |
|
6726 |
redoIdx := sub indexOf:#redo. |
|
6727 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6728 |
] |
|
2952 | 6729 |
]. |
5216 | 6730 |
self canAccept ifFalse:[ |
3731 | 6731 |
m disable:#accept |
1108 | 6732 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6733 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6734 |
|
4388 | 6735 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6736 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6737 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6738 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6739 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6740 |
|
5643 | 6741 |
history := device getCopyBufferHistory copy. |
3160 | 6742 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6743 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6744 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6745 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6746 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6747 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6748 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6749 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6750 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6751 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6752 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6753 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6754 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6755 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6756 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6757 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6758 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6759 |
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
|
6760 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6761 |
box show. |
3160 | 6762 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6763 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6764 |
"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
|
6765 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6766 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6767 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6768 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6769 |
self sensor shiftDown ifTrue:[ |
3855 | 6770 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6771 |
]. |
2724 | 6772 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6773 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6774 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6775 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6776 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6777 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6778 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6779 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6780 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6781 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6782 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6783 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6784 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6785 |
"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
|
6786 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6787 |
|
2676 | 6788 |
googleSpellingSuggestion |
6789 |
"insert the google-spelling suggestion for the selected text. |
|
6790 |
Requires that the SOAP stuff is loaded and working." |
|
6791 |
||
2677 | 6792 |
|text suggestion| |
2676 | 6793 |
|
6794 |
self withWaitCursorDo:[ |
|
3799 | 6795 |
text := self selection asString string withoutSeparators. |
6796 |
text size == 0 ifTrue:[^ self]. |
|
6797 |
||
4742 | 6798 |
"/ the 'Smalltalk at:' code is here to |
6799 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6800 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6801 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6802 |
^ self. |
|
6803 |
] do:[ |
|
4742 | 6804 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6805 |
]. |
6806 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6807 |
self information:('No spelling suggestion from Google for: ' , text). |
6808 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6809 |
^ self. |
6810 |
]. |
|
6811 |
]. |
|
6812 |
self |
|
6813 |
undoablePaste:suggestion |
|
6814 |
info:'Spelling Suggestion'. |
|
3495 | 6815 |
|
6816 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6817 |
! |
6818 |
||
3595 | 6819 |
insertDateAndTime |
6820 |
"insert the curent date and time string" |
|
6821 |
||
6822 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6823 |
self |
3786 | 6824 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6825 |
info:'Paste Date and Time' |
3595 | 6826 |
! |
6827 |
||
2676 | 6828 |
insertFile |
3160 | 6829 |
"insert contents of a file |
2676 | 6830 |
- ask user for filename using a fileSelectionBox." |
6831 |
||
3731 | 6832 |
self insertFileAsStringLiteral:false |
6833 |
! |
|
6834 |
||
6835 |
insertFileAsStringLiteral |
|
6836 |
"insert a file's contents as a string literal. |
|
6837 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6838 |
to make it a legal string literal" |
|
6839 |
||
6840 |
self insertFileAsStringLiteral:true |
|
6841 |
! |
|
6842 |
||
6843 |
insertFileAsStringLiteral:asStringLiteral |
|
6844 |
"insert contents of a file; either as-is or as a string literal. |
|
6845 |
- ask user for filename using a fileSelectionBox." |
|
6846 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6847 |
|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
|
6848 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6849 |
((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
|
6850 |
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
|
6851 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6852 |
ifTrue:[ |
3731 | 6853 |
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
|
6854 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6855 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6856 |
[ |
3731 | 6857 |
|why| |
6858 |
||
6859 |
file := Dialog |
|
6860 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6861 |
default:initial |
|
6862 |
ok:(resources string:'Insert') |
|
6863 |
abort:(resources string:'Cancel') |
|
6864 |
pattern:nil |
|
6865 |
fromDirectory:directoryForFileDialog. |
|
6866 |
file isNil ifTrue:[ |
|
6867 |
"cancel" |
|
6868 |
^ self. |
|
6869 |
]. |
|
6870 |
file := file asFilename. |
|
6871 |
directoryForFileDialog := file. |
|
6872 |
||
6873 |
ok := file isReadable and:[file isDirectory not]. |
|
6874 |
ok ifFalse:[ |
|
6875 |
file isReadable ifFalse:[ |
|
6876 |
why := '%1 is unreadable.\\Please try again.' |
|
6877 |
] ifTrue:[ |
|
6878 |
why := '%1 is a directory.\\Please try again.' |
|
6879 |
]. |
|
6880 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6881 |
]. |
|
2909 | 6882 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6883 |
|
5063 | 6884 |
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
|
6885 |
self |
3786 | 6886 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6887 |
info:'Paste File' |
3495 | 6888 |
|
6889 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6890 |
! |
|
6891 |
||
3811 | 6892 |
insertURL |
6893 |
"insert contents of a URL |
|
6894 |
- ask user for URL using a dialog." |
|
6895 |
||
6896 |
self insertURLAsStringLiteral:false |
|
6897 |
! |
|
6898 |
||
6899 |
insertURLAsStringLiteral:asStringLiteral |
|
6900 |
"insert contents of a file; either as-is or as a string literal. |
|
6901 |
- ask user for filename using a fileSelectionBox." |
|
6902 |
||
6903 |
|sel url text response initial| |
|
6904 |
||
6905 |
(sel := self selectionAsString) notEmptyOrNil |
|
6906 |
ifTrue:[ |
|
6907 |
initial := sel. |
|
6908 |
]. |
|
6909 |
||
6910 |
url := Dialog |
|
6911 |
request:(resources string:'Insert Contents of URL:') |
|
6912 |
initialAnswer:initial |
|
6913 |
okLabel:(resources string:'Insert') |
|
6914 |
title:(resources string:'URL'). |
|
6915 |
url isNil ifTrue:[ |
|
6916 |
"cancel" |
|
6917 |
^ self. |
|
6918 |
]. |
|
6919 |
response := HTTPInterface get:url. |
|
6920 |
response isErrorResponse ifTrue:[ |
|
6921 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6922 |
^ self. |
|
6923 |
]. |
|
6924 |
text := response data asString. |
|
6925 |
||
6926 |
self |
|
6927 |
undoableDo:[ |
|
6928 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6929 |
] |
|
6930 |
info:'Insert Contents of URL' |
|
6931 |
! |
|
6932 |
||
3495 | 6933 |
insertUUID |
6934 |
"insert a new UUID's string" |
|
6935 |
||
6936 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6937 |
self |
3786 | 6938 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6939 |
info:'Paste New UUID' |
3495 | 6940 |
|
6941 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6942 |
! |
6943 |
||
4940 | 6944 |
insertUnicode |
6945 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6946 |
||
6947 |
|unicodePoint unicodeChar unicodeString| |
|
6948 |
||
6949 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6950 |
unicodeString size < 2 ifTrue:[ |
|
6951 |
^ self. |
|
6952 |
]. |
|
6953 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6954 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6955 |
] ifFalse:[ |
|
6956 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6957 |
]. |
|
6958 |
||
6959 |
unicodeChar := Character value:unicodePoint. |
|
6960 |
self keyPress:unicodeChar x:0 y:0. |
|
6961 |
self keyRelease:unicodeChar x:0 y:0. |
|
6962 |
! |
|
6963 |
||
5331 | 6964 |
inspectSelectedString |
6965 |
"inspect the selected text" |
|
6966 |
||
6967 |
self selectionAsString inspect. |
|
6968 |
! |
|
6969 |
||
4742 | 6970 |
internalSpellingSuggestion |
6971 |
"insert the internal-spelling suggestion for the selected text. |
|
6972 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6973 |
||
6974 |
|text suggestions best| |
|
6975 |
||
6976 |
self withWaitCursorDo:[ |
|
6977 |
text := self selection asString string withoutSeparators. |
|
6978 |
text size == 0 ifTrue:[^ self]. |
|
6979 |
||
6980 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6981 |
suggestions size == 0 ifTrue:[ |
|
6982 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6983 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6984 |
^ self. |
|
6985 |
]. |
|
6986 |
Transcript showCR:suggestions. |
|
6987 |
best := suggestions first. |
|
6988 |
]. |
|
6989 |
self |
|
6990 |
undoablePaste:best |
|
6991 |
info:'Spelling Suggestion'. |
|
6992 |
! |
|
6993 |
||
4884 | 6994 |
openFileBrowserOnFileNamed:fileNameString |
6995 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 6996 |
|
4630 | 6997 |
|fn| |
2762 | 6998 |
|
4884 | 6999 |
fn := fileNameString asFilename. |
2762 | 7000 |
fn exists ifFalse:[ |
4884 | 7001 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 7002 |
fn exists ifFalse:[ |
5082 | 7003 |
^ self warn:(resources |
7004 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
7005 |
with:fn baseName allBold |
|
7006 |
with:fn directory baseName allBold). |
|
4042 | 7007 |
]. |
2762 | 7008 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7009 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7010 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7011 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 7012 |
! |
7013 |
||
4884 | 7014 |
openFileBrowserOnIt |
7015 |
"open a fileBrowser on the selected fileName" |
|
7016 |
||
7017 |
|fileNameString| |
|
7018 |
||
7019 |
fileNameString := self selectionAsString. |
|
7020 |
self openFileBrowserOnFileNamed:fileNameString |
|
7021 |
||
7022 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
7023 |
! |
|
7024 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7025 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7026 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7027 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7028 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7029 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7030 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7031 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7032 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7033 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7034 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7035 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7036 |
paste |
1289 | 7037 |
"paste the copybuffer; if there is a selection, unselect first. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7038 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7039 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7040 |
self checkModificationsAllowed ifTrue:[ |
4823 | 7041 |
self withSelfAndTextForPasteDo:[:me :text | |
7042 |
me unselect. |
|
7043 |
me undoablePaste:text |
|
7044 |
] |
|
2952 | 7045 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7046 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7047 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7048 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7049 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7050 |
|
3825 | 7051 |
self paste:someText withCR:false |
7052 |
! |
|
7053 |
||
7054 |
paste:someText withCR:withCR |
|
7055 |
"paste someText at cursor" |
|
7056 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7057 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7058 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7059 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7060 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7061 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7062 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7063 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7064 |
CharacterEncoderError handle:[:ex | |
3825 | 7065 |
|code msg| |
7066 |
||
7067 |
code := ex parameter. |
|
7068 |
codingErrorReported ifFalse:[ |
|
4940 | 7069 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 7070 |
code notNil ifTrue:[ |
7071 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7072 |
]. |
|
7073 |
Dialog warn:(resources stringWithCRs:msg). |
|
7074 |
codingErrorReported := true. |
|
7075 |
]. |
|
7076 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7077 |
] do:[ |
3825 | 7078 |
s isString ifTrue:[ |
4940 | 7079 |
s encoding ~~ gc characterEncoding ifTrue:[ |
7080 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 7081 |
]. |
7082 |
||
7083 |
s := s asStringCollection. |
|
7084 |
(someText endsWith:Character cr) ifTrue:[ |
|
7085 |
"/ s := s copyWith:nil. |
|
7086 |
s := s copyWith:'' "/ an empty line at the end |
|
7087 |
||
7088 |
] |
|
7089 |
] ifFalse:[ |
|
7090 |
s isStringCollection ifTrue:[ |
|
4940 | 7091 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 7092 |
] ifFalse:[ |
7093 |
(self |
|
7094 |
confirm:(resources |
|
7095 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7096 |
with:s class name)) ifFalse:[^ self]. |
|
7097 |
s := StringCollection with:s storeString . |
|
7098 |
"/ ^ self |
|
7099 |
]. |
|
7100 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7101 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7102 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7103 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7104 |
(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
|
7105 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7106 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7107 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7108 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7109 |
startCol := c1 := cursorCol. |
3180 | 7110 |
|
5194 | 7111 |
"do not autoindent here. |
7112 |
It does make things very ugly, in the inspector |
|
7113 |
(try inspecting a multiline string)..." |
|
7114 |
self withAutoIndent:false do:[ |
|
7115 |
"do not expand tabs into spaces here - |
|
7116 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7117 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7118 |
||
7119 |
self insertLines:s withCR:withCR. |
|
7120 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7121 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7122 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7123 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7124 |
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
|
7125 |
"/ 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
|
7126 |
"/ 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
|
7127 |
"/ 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
|
7128 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7129 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7130 |
|
4328 | 7131 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7132 |
"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
|
7133 |
"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
|
7134 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7135 |
|
3731 | 7136 |
pasteAsStringLiteral |
7137 |
"insert clipboard string as a string literal. |
|
7138 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7139 |
to make it a legal string literal" |
|
7140 |
||
7141 |
typeOfSelection := nil. |
|
7142 |
self |
|
5107 | 7143 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 7144 |
info:'Paste as String Literal' |
3731 | 7145 |
! |
7146 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7147 |
pasteOrReplace |
1289 | 7148 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7149 |
otherwise paste at cursor position. |
7150 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7151 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7152 |
|
2724 | 7153 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7154 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7155 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7156 |
pasteOrReplace:someText |
1289 | 7157 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7158 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7159 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7160 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7161 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7162 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7163 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7164 |
self undoableDo:[ |
4823 | 7165 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7166 |
self replace:someText |
|
7167 |
] ifFalse:[ |
|
7168 |
self paste:someText. |
|
7169 |
] |
|
3542 | 7170 |
] info:'Paste/Replace'. |
1289 | 7171 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7172 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7173 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7174 |
|
5387 | 7175 |
pasteOrReplaceByKeyPress |
7176 |
"paste a previous item from the copybuffer history. |
|
7177 |
(i.e. repaste some previously deleted or copied text)" |
|
7178 |
||
7179 |
|text| |
|
7180 |
||
7181 |
self checkModificationsAllowed ifFalse:[ |
|
7182 |
self flashReadOnly. |
|
7183 |
^ self |
|
7184 |
]. |
|
7185 |
text := self getClipboardText:#clipboard. |
|
7186 |
text notNil ifTrue:[ |
|
7187 |
self pasteOrReplace:text |
|
7188 |
] |
|
7189 |
! |
|
7190 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7191 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7192 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7193 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7194 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7195 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7196 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7197 |
self checkModificationsAllowed ifFalse:[ |
4988 | 7198 |
self flashReadOnly. |
4823 | 7199 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7200 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7201 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7202 |
text notNil ifTrue:[ |
4823 | 7203 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7204 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7205 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7206 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7207 |
replace |
1289 | 7208 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7209 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7210 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7211 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7212 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7213 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7214 |
me undoableDo:[ me replace:text ] |
7215 |
info:'Replace' |
|
2952 | 7216 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7217 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7218 |
|
121 | 7219 |
replace:someText |
1289 | 7220 |
"replace the selection by someText" |
121 | 7221 |
|
3160 | 7222 |
|selected selectedString |
7223 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7224 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7225 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7226 |
|
3130 | 7227 |
self undoableDo:[ |
4010 | 7228 |
selected := self selection. |
7229 |
selected isNil ifTrue:[ |
|
7230 |
^ self paste:someText |
|
7231 |
]. |
|
7232 |
||
7233 |
self deleteSelection. |
|
7234 |
||
7235 |
"take care, if we replace a selection without space by a word selected |
|
7236 |
with one - in this case we usually do not want the space. |
|
7237 |
But, if we replace a word-selected selection by something without a |
|
7238 |
space, we DO want the space added." |
|
7239 |
||
7240 |
selected size == 1 ifTrue:[ |
|
7241 |
selectedString := selected at:1. |
|
7242 |
]. |
|
7243 |
||
7244 |
someText size == 1 ifTrue:[ |
|
7245 |
|cutOffSpace addSpace replacement replacementString| |
|
7246 |
||
7247 |
cutOffSpace := false. |
|
7248 |
addSpace := false. |
|
7249 |
replacement := someText copyFrom:1. |
|
7250 |
||
7251 |
selectedString notNil ifTrue:[ |
|
7252 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7253 |
"selection has no space" |
|
7254 |
||
7255 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7256 |
cutOffSpace := true |
|
7257 |
] |
|
7258 |
] ifTrue:[ |
|
7259 |
addSpace := true |
|
7260 |
] |
|
7261 |
]. |
|
7262 |
replacementString := replacement at:1. |
|
7263 |
cutOffSpace ifTrue:[ |
|
7264 |
(replacementString startsWith:' ') ifTrue:[ |
|
7265 |
replacementString := replacementString withoutSpaces |
|
7266 |
]. |
|
7267 |
] ifFalse:[ |
|
7268 |
selectStyle == #wordLeft ifTrue:[ |
|
7269 |
"want a space at left" |
|
7270 |
(replacementString startsWith:' ') ifFalse:[ |
|
7271 |
replacementString := replacementString withoutSpaces. |
|
7272 |
replacementString := ' ' , replacementString |
|
7273 |
] |
|
7274 |
]. |
|
7275 |
selectStyle == #wordRight ifTrue:[ |
|
7276 |
"want a space at right" |
|
7277 |
||
7278 |
(replacementString endsWith:' ') ifFalse:[ |
|
7279 |
replacementString := replacementString withoutSpaces. |
|
7280 |
replacementString := replacementString , ' ' |
|
7281 |
] |
|
7282 |
]. |
|
7283 |
]. |
|
7284 |
replacement at:1 put: replacementString. |
|
7285 |
self paste:replacement. |
|
7286 |
] ifFalse:[ |
|
7287 |
self paste:someText |
|
7288 |
]. |
|
4053 | 7289 |
self setLastStringToReplace: selectedString. |
7290 |
||
4048 | 7291 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7292 |
|
7293 |
selStartLine := selectionStartLine. |
|
7294 |
selStartCol := self selectionStartCol. |
|
7295 |
selEndLine := selectionEndLine. |
|
7296 |
selEndCol := self selectionEndCol. |
|
3130 | 7297 |
] |
3542 | 7298 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7299 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7300 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7301 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7302 |
! |
7303 |
||
3430 | 7304 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7305 |
"search for a string - show a box to enter searchpattern |
3430 | 7306 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7307 |
- 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
|
7308 |
|
3430 | 7309 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7310 |
||
7311 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7312 |
lastSearchDirection := #forward. |
|
7313 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7314 |
caseHolder := ValueHolder with:ign. |
7315 |
patternHolder := ValueHolder with:''. |
|
7316 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7317 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7318 |
initialString := lastSearchPattern |
3430 | 7319 |
]. |
7320 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7321 |
initialString := self selectionAsString |
3430 | 7322 |
]. |
7323 |
initialString isNil ifTrue:[ |
|
4823 | 7324 |
LastSearchPatterns size > 0 ifTrue:[ |
7325 |
initialString := LastSearchPatterns first |
|
7326 |
] |
|
3430 | 7327 |
]. |
7328 |
initialString notNil ifTrue:[ |
|
4823 | 7329 |
patternHolder value:initialString. |
7330 |
replacePatternHolder value:initialString. |
|
3430 | 7331 |
]. |
7332 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7333 |
search := [:fwd | |
4823 | 7334 |
self |
7335 |
search:patternHolder value |
|
7336 |
ignoreCase:caseHolder value |
|
7337 |
forward:fwd. |
|
7338 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7339 |
replace := [:all | |
4823 | 7340 |
self |
7341 |
replace:patternHolder value |
|
7342 |
by:replacePatternHolder value |
|
7343 |
all:all |
|
7344 |
ignoreCase:caseHolder value |
|
7345 |
]. |
|
3430 | 7346 |
bindings := IdentityDictionary new. |
7347 |
bindings at:#searchPattern put:patternHolder. |
|
7348 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7349 |
modal ifTrue:[ |
|
4823 | 7350 |
bindings at:#nextAction |
7351 |
put:[ |
|
7352 |
flag := true. |
|
7353 |
action := search. |
|
7354 |
searchBox doAccept. |
|
7355 |
]. |
|
7356 |
bindings at:#prevAction |
|
7357 |
put:[ |
|
7358 |
flag := false. |
|
7359 |
action := search. |
|
7360 |
searchBox doAccept. |
|
7361 |
]. |
|
7362 |
bindings at:#replaceAction |
|
7363 |
put:[ |
|
7364 |
flag := false. |
|
7365 |
action := replace. |
|
7366 |
searchBox doAccept. |
|
7367 |
]. |
|
7368 |
bindings at:#replaceAllAction |
|
7369 |
put:[ |
|
7370 |
flag := true. |
|
7371 |
action := replace. |
|
7372 |
searchBox doAccept. |
|
7373 |
]. |
|
3430 | 7374 |
] ifFalse:[ |
4823 | 7375 |
bindings at:#nextAction put:[ search value:true. ]. |
7376 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7377 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7378 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7379 |
]. |
7380 |
bindings at:#ignoreCase put:caseHolder. |
|
7381 |
bindings at:#patternList put:LastSearchPatterns. |
|
7382 |
modal ifTrue:[ |
|
4823 | 7383 |
searchBox := SimpleDialog new. |
3430 | 7384 |
] ifFalse:[ |
4823 | 7385 |
searchBox := ApplicationModel new. |
7386 |
searchBox createBuilder. |
|
3430 | 7387 |
]. |
7388 |
searchBox resources:(self resources). |
|
7389 |
bldr := searchBox builder. |
|
7390 |
bldr addBindings:bindings. |
|
7391 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7392 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7393 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7394 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7395 |
modal ifTrue:[ |
|
4823 | 7396 |
searchBox openDialog. |
7397 |
searchBox accepted ifTrue:[ |
|
7398 |
action value:flag |
|
7399 |
]. |
|
3430 | 7400 |
] ifFalse:[ |
4823 | 7401 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7402 |
(bldr componentAt:#cancelButton) |
|
7403 |
label:(resources string:'Close'); |
|
7404 |
action:[ searchBox closeRequest ]. |
|
7405 |
||
7406 |
"/ searchBox masterApplication:self application. |
|
7407 |
||
7408 |
self topView beMaster. |
|
7409 |
(searchBox window) |
|
7410 |
beSlave; |
|
7411 |
openInGroup:(self windowGroup). |
|
7412 |
||
7413 |
"/ searchBox window open. |
|
7414 |
||
5283 | 7415 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7416 |
] |
7417 |
||
7418 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7419 |
! |
|
7420 |
||
121 | 7421 |
showDeleted |
7422 |
"open a readonly editor on all deleted text" |
|
7423 |
||
7424 |
|v| |
|
7425 |
||
7426 |
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
|
7427 |
v readOnly:true. |
121 | 7428 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7429 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7430 |
|
3221 | 7431 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7432 |
"sort/reorder the selected lines. |
7433 |
how: |
|
7434 |
#lines |
|
7435 |
#linesByFirstWord |
|
7436 |
#linesByNthWord |
|
7437 |
#linesByNthNumber |
|
7438 |
#linesByNthHexNumber |
|
7439 |
#words |
|
7440 |
#linesByLength |
|
7441 |
#reverse |
|
7442 |
" |
|
7443 |
||
7444 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7445 |
|
7446 |
lineWise := true. |
|
7447 |
||
4763 | 7448 |
how == #reverse ifTrue:[ |
7449 |
operation := [:lines | lines reverse]. |
|
7450 |
] ifFalse:[ |
|
7451 |
operation := [:linesOrWords | |
|
7452 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7453 |
]. |
|
7454 |
||
7455 |
how == #linesByLength ifTrue:[ |
|
7456 |
fetcher := [:l | l size]. |
|
7457 |
] ifFalse:[ |
|
7458 |
how == #lines ifTrue:[ |
|
7459 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7460 |
] ifFalse:[ |
|
7461 |
how == #linesByFirstWord ifTrue:[ |
|
7462 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7463 |
] ifFalse:[ |
|
7464 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7465 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7466 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7467 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7468 |
LastColumnNumberForSort := n. |
|
7469 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7470 |
how == #linesByNthNumber ifTrue:[ |
|
7471 |
innerExtractor := extractor. |
|
7472 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7473 |
] ifFalse:[ |
|
7474 |
how == #linesByNthHexNumber ifTrue:[ |
|
7475 |
innerExtractor := extractor. |
|
7476 |
extractor := [:l | |
|
7477 |
|s| |
|
7478 |
s := innerExtractor value:l. |
|
7479 |
(s startsWith:'16r') ifTrue:[ |
|
7480 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7481 |
] ifFalse:[ |
|
7482 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7483 |
] |
|
7484 |
] |
|
4753 | 7485 |
] |
4763 | 7486 |
]. |
7487 |
] ifFalse:[ |
|
7488 |
how == #words ifTrue:[ |
|
7489 |
lineWise := false. |
|
7490 |
extractor := [:w | w]. |
|
7491 |
] ifFalse:[ |
|
7492 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7493 |
] |
4373 | 7494 |
] |
7495 |
] |
|
4763 | 7496 |
]. |
7497 |
ignoreCase ifTrue:[ |
|
7498 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7499 |
] ifFalse:[ |
|
7500 |
fetcher := extractor. |
|
7501 |
]. |
|
7502 |
]. |
|
3221 | 7503 |
]. |
7504 |
||
7505 |
lineWise ifTrue:[ |
|
4763 | 7506 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7507 |
start == end ifTrue:[^ self ]. |
7508 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7509 |
lines := operation value:lines. |
4373 | 7510 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7511 |
] ifFalse:[ |
7512 |
"process the whole selection as a string" |
|
7513 |
s := self selectionAsString. |
|
7514 |
words := s asCollectionOfWords. |
|
7515 |
words := operation value:words. |
|
7516 |
s := words asStringCollection asStringWith:Character space. |
|
7517 |
self replace:s. |
|
7518 |
]. |
|
3221 | 7519 |
self textChanged. |
4373 | 7520 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7521 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7522 |
! |
7523 |
||
7524 |
sortSelection:how ignoreCase:ignoreCase |
|
7525 |
"sort the selected lines" |
|
7526 |
||
7527 |
|start end| |
|
7528 |
||
7529 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7530 |
||
7531 |
start := selectionStartLine. |
|
7532 |
end := selectionEndLine. |
|
7533 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7534 |
end := end - 1 |
3221 | 7535 |
]. |
7536 |
||
7537 |
self |
|
4373 | 7538 |
undoableDo:[ |
7539 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7540 |
] |
|
3786 | 7541 |
info:'Sort' |
4373 | 7542 |
|
7543 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7544 |
! |
7545 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7546 |
specialCharacters |
2915 | 7547 |
CharacterSetView |
4823 | 7548 |
openAsInputFor:self |
7549 |
label:'Special Character Input' |
|
7550 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7551 |
! |
7552 |
||
5370 | 7553 |
splitLinesAtCharacterOrString |
7554 |
"ask user for the character and split after it" |
|
7555 |
||
7556 |
|sel in out separator record| |
|
7557 |
||
7558 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7559 |
||
7560 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7561 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7562 |
||
7563 |
sel := self selectionAsString. |
|
7564 |
in := sel readStream. |
|
7565 |
out := CharacterWriteStream on:(String new). |
|
7566 |
[in atEnd] whileFalse:[ |
|
7567 |
record := in throughAll:separator. |
|
7568 |
out nextPutLine:record. |
|
7569 |
]. |
|
7570 |
self |
|
7571 |
undoableDo:[ |
|
7572 |
self replaceSelectionBy:(out contents). |
|
7573 |
] |
|
7574 |
info:'Split Selection' |
|
7575 |
! |
|
7576 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7577 |
undoablePaste:someText |
3495 | 7578 |
self undoablePaste:someText info:nil. |
7579 |
||
7580 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7581 |
! |
|
7582 |
||
7583 |
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
|
7584 |
self |
4823 | 7585 |
undoableDo:[ |
7586 |
self paste:someText. |
|
7587 |
] |
|
7588 |
info:infoOrNil |
|
3495 | 7589 |
|
7590 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7591 |
! |
|
7592 |
||
7593 |
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
|
7594 |
self |
4823 | 7595 |
undoableDo:[ |
7596 |
self pasteOrReplace:someText. |
|
7597 |
] |
|
7598 |
info:infoOrNil |
|
3495 | 7599 |
|
7600 |
"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
|
7601 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7602 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7603 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7604 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7605 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7606 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7607 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7608 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7609 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7610 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7611 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7612 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7613 |
|
2724 | 7614 |
withSelfAndTextForPasteDo:aBlock |
7615 |
"common code for paste/replace of the copybuffer" |
|
7616 |
||
7617 |
|sel| |
|
7618 |
||
7619 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7620 |
self flashReadOnly. |
4823 | 7621 |
^ self |
2724 | 7622 |
]. |
7623 |
||
7624 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7625 |
sel notNil ifTrue:[ |
|
4823 | 7626 |
aBlock value:self value:sel. |
2724 | 7627 |
] |
105 | 7628 |
! ! |
7629 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7630 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7631 |
|
3880 | 7632 |
beep |
5244 | 7633 |
"output an audible beep or bell on my screen device" |
7634 |
||
3880 | 7635 |
UserPreferences current beepInEditor ifTrue:[ |
7636 |
super beep |
|
7637 |
] |
|
7638 |
! |
|
7639 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7640 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7641 |
"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
|
7642 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7643 |
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
|
7644 |
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
|
7645 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7646 |
self isReadOnly ifTrue: [ |
4823 | 7647 |
exceptionBlock isNil ifTrue:[ |
7648 |
^ false |
|
7649 |
]. |
|
7650 |
||
7651 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7652 |
^ false |
|
7653 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7654 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7655 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7656 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7657 |
"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
|
7658 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7659 |
|
2596 | 7660 |
currentSelectionBgColor |
7661 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7662 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7663 |
]. |
5216 | 7664 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7665 |
^ super currentSelectionBgColor |
7666 |
||
7667 |
" |
|
7668 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7669 |
" |
|
7670 |
! |
|
7671 |
||
7672 |
currentSelectionFgColor |
|
7673 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7674 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7675 |
]. |
7676 |
^ super currentSelectionFgColor |
|
7677 |
! |
|
7678 |
||
3996 | 7679 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7680 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7681 |
|
7682 |
super resetVariablesBeforeNewSearch. |
|
7683 |
||
7684 |
"/ new search invalidates remembered string |
|
4048 | 7685 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7686 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7687 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7688 |
! |
7689 |
||
4053 | 7690 |
setLastStringToReplace: aString |
7691 |
||
7692 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7693 |
||
7694 |
|lastReplaceIgnoredCase| |
|
7695 |
||
4064 | 7696 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7697 |
self clearSearchAction. |
|
7698 |
||
4053 | 7699 |
lastReplacementInfo lastStringToReplace: aString. |
7700 |
lastStringFromReplaceForNextSearch := aString. |
|
7701 |
||
7702 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7703 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7704 |
ifTrue: [lastSearchIgnoredCase] |
|
7705 |
ifFalse: [nil]. |
|
4053 | 7706 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7707 |
! |
|
7708 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7709 |
st80EditMode |
5255 | 7710 |
"If on, the cursor wraps at the line end (like in vi or st80); |
7711 |
if off, we have the Rand-editor behavior (random access)" |
|
7712 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7713 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7714 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7715 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7716 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7717 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7718 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7719 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7720 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7721 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7722 |
textChanged |
522 | 7723 |
"my text was modified (internally). |
7724 |
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
|
7725 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7726 |
is used to notify scrollers, other views etc.). |
7727 |
||
7728 |
As some authors of this code have been very sloppy in tha past |
|
7729 |
(not sending contentsChanged, but textChanged), |
|
7730 |
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
|
7731 |
|
641 | 7732 |
self contentsChanged. |
1015 | 7733 |
self modified:true. |
5774 | 7734 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7735 |
contentsWasSaved := false |
641 | 7736 |
|
1015 | 7737 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7738 |
! |
7739 |
||
2617 | 7740 |
textChangedButNoSizeChange |
2207 | 7741 |
"my text was modified (internally). |
7742 |
Sent whenever text has been edited (not to confuse with |
|
7743 |
contentsChanged, which is triggered when the size has changed, and |
|
7744 |
is used to notify scrollers, other views etc.)" |
|
7745 |
||
7746 |
self modified:true. |
|
7747 |
contentsWasSaved := false |
|
7748 |
||
7749 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7750 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7751 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7752 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7753 |
|
5216 | 7754 |
canAccept |
7755 |
"true if text can be accepts. |
|
7756 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7757 |
||
7758 |
^ acceptEnabled ~~ false |
|
7759 |
! |
|
7760 |
||
7761 |
canCut |
|
7762 |
"true if there is a selection possibly to be cut. |
|
7763 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7764 |
||
7765 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7766 |
^ self hasSelection |
|
7767 |
! |
|
7768 |
||
7769 |
canDoAgain |
|
7770 |
"true if there is a possible repeat last edit operation. |
|
7771 |
Used to disable the menu if there is nothing" |
|
7772 |
||
7773 |
|lastStringToReplace| |
|
7774 |
||
7775 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7776 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7777 |
^ lastStringToReplace notNil |
|
7778 |
! |
|
7779 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7780 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7781 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7782 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7783 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7784 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7785 |
"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
|
7786 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7787 |
|
4064 | 7788 |
hasSearchActionSelection |
7789 |
||
7790 |
^ typeOfSelection == #searchAction |
|
7791 |
! |
|
7792 |
||
1878 | 7793 |
isKeyboardConsumer |
7794 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7795 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7796 |
|
3476 | 7797 |
^ self isReadOnly not |
1878 | 7798 |
! |
7799 |
||
997 | 7800 |
specClass |
1390 | 7801 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7802 |
||
997 | 7803 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7804 |
^ super specClass |
7805 |
||
1390 | 7806 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7807 |
! |
7808 |
||
324 | 7809 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7810 |
"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
|
7811 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7812 |
"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
|
7813 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7814 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7815 |
|
7816 |
"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
|
7817 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7818 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7819 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7820 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7821 |
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
|
7822 |
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
|
7823 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7824 |
|
697 | 7825 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7826 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7827 |
w := super widthOfContents. |
5643 | 7828 |
(dev := device ) isNil ifTrue:[ |
4889 | 7829 |
"/ really don't know ... |
4823 | 7830 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7831 |
]. |
4889 | 7832 |
^ w + (gc font widthOn:dev) |
697 | 7833 |
|
7834 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7835 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7836 |
|
1588 | 7837 |
!EditTextView methodsFor:'realization'! |
7838 |
||
7839 |
realize |
|
7840 |
"make the view visible - scroll to make the cursor visible." |
|
7841 |
||
7842 |
super realize. |
|
7843 |
||
7844 |
self makeCursorVisible. |
|
5643 | 7845 |
cursorFgColor := cursorFgColor onDevice:device. |
7846 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7847 |
|
7848 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7849 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7850 |
! ! |
|
7851 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7852 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7853 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7854 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7855 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7857 |
cursorShown ifTrue:[ |
4823 | 7858 |
cursorVisibleLine notNil ifTrue:[ |
7859 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7860 |
self drawCursorCharacter |
|
7861 |
] |
|
7862 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7863 |
] |
105 | 7864 |
! |
7865 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7866 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7867 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7868 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7869 |
cursorShown ifTrue:[ |
4823 | 7870 |
(visLine == cursorVisibleLine) ifTrue:[ |
7871 |
self drawCursorCharacter |
|
7872 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7873 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7874 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7875 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7876 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7877 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7878 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7879 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7880 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7881 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7882 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7883 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7884 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7886 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7887 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7888 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7889 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7890 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7891 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7892 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7893 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7894 |
cursorShown ifTrue:[ |
4823 | 7895 |
(visLine == cursorVisibleLine) ifTrue:[ |
7896 |
(colNr == cursorCol) ifTrue:[ |
|
7897 |
self drawCursorCharacter. |
|
7898 |
^ self |
|
7899 |
] |
|
7900 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7901 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7902 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7903 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7904 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7905 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7906 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7907 |
"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
|
7908 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7909 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7910 |
cursorShown ifTrue:[ |
7911 |
self redrawCursorIfInVisibleLine:visLine |
|
7912 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7913 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7914 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7915 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7916 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7917 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7918 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7919 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7920 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7921 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7922 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7923 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7924 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7925 |
"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
|
7926 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7927 |
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
|
7928 |
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
|
7929 |
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
|
7930 |
|
4889 | 7931 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7932 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7933 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7934 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7935 |
"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
|
7936 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7937 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7938 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7939 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7940 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7941 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7942 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7943 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7944 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7945 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7946 |
"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
|
7947 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7948 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7949 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7950 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7951 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7952 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7953 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7954 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7955 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7956 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7957 |
"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
|
7958 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7959 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7960 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7961 |
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
|
7962 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7963 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7964 |
prevCursorState ifTrue:[ |
4823 | 7965 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7966 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7967 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7968 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7969 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7970 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7971 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7972 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7973 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7974 |
prevCursorState := cursorShown. |
1601 | 7975 |
"/ cursorShown := false. |
1591 | 7976 |
cursorShown ifTrue:[ |
4823 | 7977 |
self hideCursor |
1591 | 7978 |
] |
7979 |
||
1601 | 7980 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7981 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7982 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7983 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7984 |
"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
|
7985 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7986 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7987 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7988 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7989 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7990 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7991 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7992 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7993 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7994 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7995 |
"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
|
7996 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7997 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7998 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7999 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8000 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8002 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8003 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8004 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8005 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8007 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8008 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8009 |
|
2822 | 8010 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8011 |
! |
8012 |
||
8013 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8014 |
"do a backward search" |
|
8015 |
||
8016 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8017 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8018 |
! |
8019 |
||
8020 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8021 |
"do a backward search" |
|
8022 |
||
8023 |
cursorLine isNil ifTrue:[^ self]. |
|
8024 |
||
3160 | 8025 |
self |
4119 | 8026 |
searchBackwardFor:pattern |
8027 |
ignoreCase:ign |
|
8028 |
startingAtLine:startLine col:startCol |
|
5717 | 8029 |
ifFound:[:line :col :endColOrNil | |
4119 | 8030 |
self cursorMovementAllowed ifTrue:[ |
8031 |
self cursorLine:line col:col. |
|
8032 |
]. |
|
5717 | 8033 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
1339 | 8034 |
"/ self makeLineVisible:cursorLine |
4119 | 8035 |
typeOfSelection := #search] |
8036 |
ifAbsent:aBlock |
|
1339 | 8037 |
|
8038 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8039 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8040 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8041 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8042 |
"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
|
8043 |
|
2554 | 8044 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8045 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8046 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8047 |
searchForMatchingParenthesis |
3160 | 8048 |
"search for a matching parenthesis starting at cursor position. |
8049 |
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
|
8050 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8051 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8052 |
|
2822 | 8053 |
self cursorMovementAllowed ifFalse:[^ self]. |
8054 |
||
3160 | 8055 |
self |
4823 | 8056 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8057 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8058 |
ifNotFound:[self showNotFound] |
|
8059 |
onError:[self beep] |
|
1339 | 8060 |
|
8061 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8062 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8063 |
|
3967 | 8064 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8065 |
"do a forward search" |
8066 |
||
8067 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 8068 |
self |
8069 |
searchForwardFor:pattern |
|
8070 |
ignoreCase:ign |
|
8071 |
match: match |
|
8072 |
startingAtLine:startLine col:startCol |
|
5717 | 8073 |
ifFound:[:line :col :endColOrNil| |
3967 | 8074 |
self cursorMovementAllowed ifTrue:[ |
8075 |
self cursorLine:line col:col. |
|
8076 |
]. |
|
5717 | 8077 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
1339 | 8078 |
"/ self makeLineVisible:cursorLine |
3967 | 8079 |
typeOfSelection := #search |
8080 |
] |
|
8081 |
ifAbsent:aBlock |
|
1339 | 8082 |
|
8083 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8084 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8085 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8086 |
|
3967 | 8087 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8088 |
"do a forward search" |
|
8089 |
||
8090 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8091 |
! |
|
8092 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8093 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8094 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8095 |
|
2822 | 8096 |
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
|
8097 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8098 |
|
3982 | 8099 |
searchPatternForSearchBar |
8100 |
||
8101 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8102 |
||
8103 |
|searchPattern| |
|
8104 |
||
4138 | 8105 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 8106 |
searchPattern isNil |
8107 |
ifTrue: [searchPattern := lastSearchPattern] |
|
8108 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
8109 |
^ searchPattern |
|
8110 |
! |
|
8111 |
||
3578 | 8112 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8113 |
"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
|
8114 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8116 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8117 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8118 |
"/ |
3967 | 8119 |
"/ 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
|
8120 |
"/ original string (for search after again) |
4121 | 8121 |
"/ 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
|
8122 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8123 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8124 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8125 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8126 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8127 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8128 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8129 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8130 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8131 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8132 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8133 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8134 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8135 |
"/ 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
|
8136 |
"/ if there was a previous search, only take the selection if |
3967 | 8137 |
"/ 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
|
8138 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8139 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8140 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8141 |
sel notNil ifTrue:[ |
3967 | 8142 |
(lastSearchPattern isNil |
4484 | 8143 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
8144 |
) ifTrue:[ |
|
3967 | 8145 |
self cursorLine:selectionStartLine col:selectionStartCol. |
8146 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8147 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8148 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8149 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8150 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8151 |
"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
|
8152 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8153 |
|
5717 | 8154 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8155 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8156 |
typeOfSelection := #search. |
8157 |
! |
|
8158 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8159 |
startPositionForSearchBackward |
2822 | 8160 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8161 |
! |
|
8162 |
||
8163 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8164 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8165 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8166 |
selectionStartLine notNil ifTrue:[ |
4823 | 8167 |
startLine := selectionStartLine. |
8168 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8169 |
] ifFalse:[ |
4823 | 8170 |
cursorLine isNil ifTrue:[ |
8171 |
startLine := list size. |
|
8172 |
startCol := self listAt:startLine size. |
|
8173 |
] ifFalse:[ |
|
8174 |
startLine := cursorLine min:list size. |
|
8175 |
startCol := cursorCol |
|
8176 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8177 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8178 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8179 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8180 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8181 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8182 |
startPositionForSearchForward |
2822 | 8183 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8184 |
! |
|
8185 |
||
8186 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8187 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8188 |
|
3160 | 8189 |
"/ 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
|
8190 |
"/ 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
|
8191 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8192 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8193 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8194 |
] ifFalse:[ |
4064 | 8195 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8196 |
startCol := 0 |
|
8197 |
]. |
|
8198 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8199 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8200 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8201 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8202 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8203 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8204 |
! ! |
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 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8207 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8208 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8209 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8210 |
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
|
8211 |
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
|
8212 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8213 |
"/ Following comment is in czech and thus now very useful. |
4970 | 8214 |
"/ 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
|
8215 |
"/ 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
|
8216 |
"/ 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
|
8217 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8218 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8219 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8220 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8221 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8222 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8223 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8224 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8225 |
| 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
|
8226 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8227 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8228 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8229 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8230 |
self hasSelection ifTrue: [ |
4970 | 8231 |
startLine := selectionStartLine. |
8232 |
startCol := selectionStartCol. |
|
8233 |
endLine := selectionEndLine. |
|
8234 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8235 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8236 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8237 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8238 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8239 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8240 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8241 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8242 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8243 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8244 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8245 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8246 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8247 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8248 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8249 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8250 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8251 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8252 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8253 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8254 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8255 |
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
|
8256 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8257 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8258 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8259 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8260 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8261 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8262 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8263 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8264 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8265 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8266 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8267 |
startLine := cursorLine. |
4823 | 8268 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8269 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8270 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8271 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8272 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8273 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8274 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8275 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8276 |
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
|
8277 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8278 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8279 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8280 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8281 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8282 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8283 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8284 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8285 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8286 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8287 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8288 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8289 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8290 |
] |
4823 | 8291 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8292 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8293 |
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
|
8294 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8295 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8296 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8297 |
"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
|
8298 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8299 |
|
1850 | 8300 |
autoMoveCursorToEndOfSelection |
8301 |
"return true, if the cursor should be automatically moved to the |
|
8302 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8303 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8304 |
not be affected by selecting" |
8305 |
||
8306 |
^ true |
|
8307 |
! |
|
8308 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8309 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8310 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8311 |
typeOfSelection := newType. |
8312 |
selectionStartLine notNil ifTrue:[ |
|
8313 |
self |
|
8314 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8315 |
toLine:selectionEndLine col:selectionEndCol |
|
8316 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8317 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8318 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8319 |
|
4707 | 8320 |
findNextWordAfterSelectionAndAddToSelection |
8321 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8322 |
||
8323 |
selectionStartCol isNil ifTrue:[ |
|
8324 |
self selectWordUnderCursor. |
|
8325 |
^ self |
|
8326 |
]. |
|
8327 |
||
8328 |
selStartCol := selectionStartCol. |
|
8329 |
selEndCol := selectionEndCol. |
|
8330 |
selStartLine := selectionStartLine. |
|
8331 |
selEndLine := selectionEndLine. |
|
8332 |
||
8333 |
self cursorToNextWord. |
|
8334 |
self selectWordUnderCursor. |
|
8335 |
||
8336 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8337 |
! |
|
8338 |
||
4138 | 8339 |
searchPatternFromUserSelectionOrReplace |
8340 |
||
8341 |
|sel searchPattern| |
|
8342 |
||
8343 |
"/ |
|
8344 |
"/ if the last operation was a replace, set pattern to last |
|
8345 |
"/ original string (for search after again) |
|
8346 |
"/ |
|
8347 |
(lastStringFromReplaceForNextSearch notNil |
|
8348 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8349 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8350 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8351 |
] ifFalse:[ |
|
8352 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8353 |
]. |
|
8354 |
^ searchPattern |
|
8355 |
]. |
|
8356 |
||
8357 |
"/ |
|
8358 |
"/ if there is a selection: |
|
8359 |
"/ if there was no previous search, take it as search pattern. |
|
8360 |
"/ if there was a previous search, only take the selection if |
|
8361 |
"/ it did not result from a paste. |
|
8362 |
"/ (to allow search-paste to be repeated) |
|
8363 |
"/ |
|
8364 |
sel := self selection. |
|
8365 |
sel notNil ifTrue:[ |
|
8366 |
typeOfSelection ~~ #search ifTrue:[ |
|
8367 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8368 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8369 |
searchPattern := sel asStringWithoutFinalCR. |
|
8370 |
] |
|
8371 |
]. |
|
8372 |
]. |
|
8373 |
||
8374 |
^ searchPattern |
|
8375 |
! |
|
8376 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8377 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8378 |
"select the whole text. |
5593 | 8379 |
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
|
8380 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8381 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8382 |
list isNil ifTrue:[ |
4823 | 8383 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8384 |
] ifFalse:[ |
4823 | 8385 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8386 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8387 |
] |
1082 | 8388 |
|
8389 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8390 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8391 |
|
4117 | 8392 |
selectAllInitially |
8393 |
"select the whole text. This is called only once during the initialization |
|
8394 |
for editFields which are shown in a table or tree. |
|
8395 |
The selectAll is called via this method to allow for easier redefinition and |
|
8396 |
to distinguish auto-select from user-initiated selects." |
|
8397 |
||
8398 |
self selectAll |
|
8399 |
! |
|
8400 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8401 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8402 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8403 |
|
3160 | 8404 |
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
|
8405 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8406 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8407 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8408 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8409 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8410 |
cursorCol > 1 ifTrue:[ |
4823 | 8411 |
self selectFromLine:cursorLine col:1 |
8412 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8413 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8414 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8415 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8416 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8417 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8418 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8419 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8420 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8421 |
selectionStartLine isNil ifTrue:[ |
4823 | 8422 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8423 |
] ifFalse:[ |
4823 | 8424 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8425 |
toLine:cursorLine+1 col:0. |
|
8426 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8427 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8428 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8429 |
|
4257 | 8430 |
selectFromBeginOfLine |
8431 |
"select the text from the beginning of the current line to the current cursor position." |
|
8432 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8433 |
| newCursorCol ln | |
4271 | 8434 |
|
4257 | 8435 |
list isNil ifTrue:[ |
8436 |
self unselect |
|
8437 |
] ifFalse:[ |
|
8438 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8439 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8440 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8441 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8442 |
cursorCol := newCursorCol. |
|
4257 | 8443 |
typeOfSelection := nil |
8444 |
] |
|
8445 |
] |
|
8446 |
||
8447 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8448 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8449 |
! |
8450 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8451 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8452 |
"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
|
8453 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8454 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8455 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8456 |
list isNil ifTrue:[ |
4823 | 8457 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8458 |
] ifFalse:[ |
4823 | 8459 |
cursorCol == 0 ifTrue:[ |
8460 |
col := 0 |
|
8461 |
] ifFalse:[ |
|
8462 |
col := cursorCol - 1 |
|
8463 |
]. |
|
8464 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8465 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8466 |
] |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8469 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8470 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8471 |
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
|
8472 |
"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
|
8473 |
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
|
8474 |
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
|
8475 |
"/ (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
|
8476 |
"/ 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
|
8477 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8478 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8479 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8480 |
"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
|
8481 |
"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
|
8482 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8483 |
|
4257 | 8484 |
selectToEndOfLine |
8485 |
"select the text from the current cursor position to the end of the current line" |
|
8486 |
||
4271 | 8487 |
| newCursorCol line | |
8488 |
||
4257 | 8489 |
list isNil ifTrue:[ |
8490 |
self unselect |
|
8491 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8492 |
cursorCol >= 1 ifTrue:[ |
4271 | 8493 |
line := list at: cursorLine. |
8494 |
newCursorCol := line size. |
|
8495 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8496 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8497 |
||
8498 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8499 |
cursorCol := newCursorCol. |
|
4257 | 8500 |
typeOfSelection := nil |
8501 |
] |
|
8502 |
] |
|
8503 |
||
8504 |
"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
|
8505 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8506 |
! |
8507 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8508 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8509 |
"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
|
8510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8511 |
list isNil ifTrue:[ |
4823 | 8512 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8513 |
] ifFalse:[ |
4823 | 8514 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8515 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8516 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8517 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8518 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8519 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8520 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8521 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8522 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8523 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8524 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8525 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8526 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8527 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8528 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8529 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8530 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8531 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8532 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8533 |
wasOn ifTrue:[self showCursor] |
105 | 8534 |
! ! |
8535 |
||
8536 |
!EditTextView methodsFor:'undo & again'! |
|
8537 |
||
2952 | 8538 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8539 |
^ undoSupport addUndo:action. |
2952 | 8540 |
! |
8541 |
||
105 | 8542 |
again |
8543 |
"repeat the last action (which was a cut or replace). |
|
8544 |
If current selection is not last string, search forward to |
|
3160 | 8545 |
next occurrence of it before repeating the last operation." |
105 | 8546 |
|
4048 | 8547 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8548 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8549 |
|
8550 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8551 |
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
|
8552 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8553 |
]. |
4048 | 8554 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8555 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8556 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8557 |
self undoableDo:[ |
4010 | 8558 |
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
|
8559 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8560 |
(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
|
8561 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8562 |
|
4053 | 8563 |
"set lastStringToReplace as the next search string |
8564 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8565 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8566 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8567 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8568 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8569 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8570 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8571 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8572 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8573 |
"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
|
8574 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8575 |
(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
|
8576 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8577 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8578 |
self deleteSelection. |
4051 | 8579 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8580 |
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
|
8581 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8582 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8583 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8584 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8585 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8586 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8587 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8588 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8589 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8590 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8591 |
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
|
8592 |
]. |
4048 | 8593 |
self |
8594 |
searchForwardFor:s |
|
8595 |
ignoreCase: lastReplaceIgnoredCase |
|
8596 |
match: lastReplaceWasMatch |
|
8597 |
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
|
8598 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8599 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8600 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8601 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8602 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8603 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8604 |
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
|
8605 |
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
|
8606 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8607 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8608 |
self deleteSelection. |
4051 | 8609 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8610 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8611 |
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
|
8612 |
] ifTrue:[ |
4051 | 8613 |
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
|
8614 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8615 |
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
|
8616 |
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
|
8617 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8618 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8619 |
selectStyle := savedSelectStyle. |
4484 | 8620 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8621 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8622 |
] |
4048 | 8623 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8624 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8625 |
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
|
8626 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8627 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8628 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8629 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8630 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8631 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8632 |
^ true. |
501 | 8633 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8634 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8635 |
! |
8636 |
||
2952 | 8637 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8638 |
^ undoSupport hasRedoAction. |
2952 | 8639 |
! |
8640 |
||
8641 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8642 |
^ undoSupport hasUndoAction. |
2952 | 8643 |
! |
8644 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8645 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8646 |
"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
|
8647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8648 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8649 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8650 |
|
2952 | 8651 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8652 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8653 |
! |
8654 |
||
8655 |
redo |
|
3780 | 8656 |
"undo the last undo" |
8657 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8658 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8659 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8660 |
] ifTrue:[ |
3780 | 8661 |
undoSupport redo. |
2952 | 8662 |
] |
8663 |
! |
|
8664 |
||
121 | 8665 |
undo |
3780 | 8666 |
"undo the last edit operation" |
8667 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8668 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8669 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8670 |
] ifTrue:[ |
3780 | 8671 |
undoSupport undo. |
121 | 8672 |
] |
2952 | 8673 |
! |
8674 |
||
8675 |
undoableDo:aBlock |
|
3495 | 8676 |
self undoableDo:aBlock info:nil. |
8677 |
||
8678 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8679 |
! |
8680 |
||
8681 |
undoableDo:aBlock info:aString |
|
5689 | 8682 |
|selectionRestore| |
8683 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8684 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8685 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8686 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8687 |
] ifTrue:[ |
5689 | 8688 |
undoSupport isInTransaction ifFalse:[ |
8689 |
selectionRestore := RestoreSelectionAndCursor new |
|
8690 |
cursorLine:cursorLine cursorCol:cursorCol |
|
8691 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
8692 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
8693 |
info:nil. |
|
8694 |
]. |
|
8695 |
undoSupport |
|
8696 |
undoableDo:[ |
|
8697 |
aBlock value. |
|
8698 |
selectionRestore notNil ifTrue:[ |
|
8699 |
undoSupport transactionNotEmpty ifTrue:[ |
|
8700 |
undoSupport addUndoFirst:selectionRestore |
|
8701 |
]. |
|
8702 |
]. |
|
8703 |
] |
|
8704 |
info:aString. |
|
8705 |
]. |
|
8706 |
||
8707 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 8708 |
! ! |
8709 |
||
8710 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8711 |
||
8712 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8713 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8714 |
! |
|
8715 |
||
3115 | 8716 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8717 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8718 |
! |
8719 |
||
2952 | 8720 |
line:arg1 col:arg2 character:arg3 |
8721 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8722 |
! |
|
8723 |
||
3115 | 8724 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8725 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8726 |
! |
8727 |
||
3235 | 8728 |
line:arg1 col:arg2 characters:arg3 info:info |
8729 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8730 |
! |
|
8731 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8732 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8733 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8734 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8735 |
|
2952 | 8736 |
line:arg1 col:arg2 string:arg3 |
8737 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8738 |
! |
8739 |
||
8740 |
line:arg1 col:arg2 string:arg3 info:info |
|
8741 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8742 |
! |
8743 |
||
8744 |
line:arg1 string:arg3 info:info |
|
8745 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8746 |
! |
8747 |
||
8748 |
text:arg info:info |
|
8749 |
^ (self new text:arg) info:info |
|
3115 | 8750 |
! ! |
8751 |
||
8752 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8753 |
||
8754 |
info |
|
8755 |
^ userFriendlyInfo |
|
8756 |
! |
|
8757 |
||
8758 |
info:aString |
|
8759 |
userFriendlyInfo := aString |
|
2952 | 8760 |
! ! |
8761 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8762 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8763 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8764 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8765 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8766 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8767 |
"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
|
8768 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8769 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8770 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8771 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8772 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8773 |
^ false |
5710 | 8774 |
! |
8775 |
||
8776 |
isRestoreSelectionAndCursor |
|
8777 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8778 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8779 |
|
2952 | 8780 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8781 |
||
3160 | 8782 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8783 |
"set instance variables (automatically generated)" |
8784 |
||
8785 |
self assert:(line1Arg notNil). |
|
8786 |
self assert:(col1Arg notNil). |
|
8787 |
self assert:(line2Arg notNil). |
|
8788 |
self assert:(col2Arg notNil). |
|
8789 |
||
8790 |
line1 := line1Arg. |
|
8791 |
col1 := col1Arg. |
|
8792 |
line2 := line2Arg. |
|
8793 |
col2 := col2Arg. |
|
8794 |
! ! |
|
8795 |
||
8796 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8797 |
||
3160 | 8798 |
executeIn:editor |
2952 | 8799 |
editor unselect. |
3160 | 8800 |
editor |
4823 | 8801 |
deleteFromLine:line1 |
8802 |
col:col1 |
|
8803 |
toLine:line2 |
|
8804 |
col:col2. |
|
2952 | 8805 |
editor cursorLine:line1 col:col1. |
8806 |
! ! |
|
8807 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8808 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8809 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8810 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8811 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8812 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8813 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8814 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8815 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8816 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8817 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8818 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8819 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8820 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8821 |
|
3160 | 8822 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8823 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8824 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8825 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8826 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8827 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8828 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8829 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8830 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8831 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8832 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8833 |
|
3160 | 8834 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8835 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8836 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8837 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8838 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8839 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8840 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8841 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8842 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8843 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8844 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8845 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8846 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8847 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8848 |
|
3160 | 8849 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8850 |
"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
|
8851 |
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
|
8852 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8853 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8854 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8855 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8856 |
^ true |
|
8857 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8858 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8859 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8860 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8861 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8862 |
|
3160 | 8863 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8864 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8865 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8866 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8867 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8868 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8869 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8870 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8871 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8872 |
|
3160 | 8873 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8874 |
editor unselect. |
3160 | 8875 |
editor |
4823 | 8876 |
deleteFromLine:line |
8877 |
col:col1 |
|
8878 |
toLine:line |
|
8879 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8880 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8881 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8882 |
|
3235 | 8883 |
!EditTextView::EditMode class methodsFor:'constants'! |
8884 |
||
8885 |
insertAndSelectMode |
|
8886 |
^ InsertAndSelectMode |
|
8887 |
! |
|
8888 |
||
8889 |
insertMode |
|
8890 |
^ InsertMode |
|
8891 |
! |
|
8892 |
||
8893 |
overwriteMode |
|
8894 |
^ OverwriteMode |
|
8895 |
! ! |
|
8896 |
||
8897 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8898 |
||
8899 |
isInsertAndSelectMode |
|
8900 |
^ false |
|
8901 |
! |
|
8902 |
||
8903 |
isInsertMode |
|
8904 |
^ false |
|
8905 |
! |
|
8906 |
||
8907 |
symbolicName |
|
8908 |
self subclassResponsibility |
|
8909 |
! ! |
|
8910 |
||
8911 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8912 |
||
8913 |
infoPrintString |
|
8914 |
^ 'IS' |
|
8915 |
! ! |
|
8916 |
||
8917 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8918 |
||
8919 |
isInsertAndSelectMode |
|
8920 |
^ true |
|
8921 |
! |
|
8922 |
||
8923 |
isInsertMode |
|
8924 |
^ true |
|
8925 |
! ! |
|
8926 |
||
8927 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8928 |
||
8929 |
infoPrintString |
|
8930 |
^ 'I' |
|
8931 |
! ! |
|
8932 |
||
8933 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8934 |
||
8935 |
isInsertMode |
|
8936 |
^ true |
|
8937 |
! ! |
|
8938 |
||
8939 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8940 |
||
8941 |
infoPrintString |
|
8942 |
^ 'O' |
|
8943 |
! ! |
|
8944 |
||
4048 | 8945 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8946 |
||
8947 |
lastReplaceIgnoredCase |
|
8948 |
^ lastReplaceIgnoredCase ? false |
|
8949 |
! |
|
8950 |
||
8951 |
lastReplaceIgnoredCase:something |
|
8952 |
lastReplaceIgnoredCase := something. |
|
8953 |
! |
|
8954 |
||
8955 |
lastReplaceWasMatch |
|
8956 |
^ lastReplaceWasMatch ? false |
|
8957 |
! |
|
8958 |
||
8959 |
lastReplaceWasMatch:something |
|
8960 |
lastReplaceWasMatch := something. |
|
8961 |
! |
|
8962 |
||
8963 |
lastReplacement |
|
8964 |
^ lastReplacement |
|
8965 |
! |
|
8966 |
||
8967 |
lastReplacement:something |
|
4053 | 8968 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8969 |
lastReplacement := something. |
8970 |
! |
|
8971 |
||
8972 |
lastStringToReplace |
|
8973 |
^ lastStringToReplace |
|
8974 |
! |
|
8975 |
||
8976 |
lastStringToReplace:something |
|
8977 |
lastStringToReplace := something. |
|
4818 | 8978 |
! |
8979 |
||
8980 |
previousReplacements |
|
8981 |
^ previousReplacements ? #() |
|
8982 |
! |
|
8983 |
||
8984 |
stillCollectingInput |
|
8985 |
^ stillCollectingInput |
|
8986 |
! |
|
8987 |
||
8988 |
stillCollectingInput:aBoolean |
|
8989 |
stillCollectingInput := aBoolean. |
|
8990 |
! ! |
|
8991 |
||
8992 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8993 |
||
8994 |
rememberReplacement |
|
8995 |
"remember the previous replacement (called when a new one appears). |
|
8996 |
Mostly for the benefit of the code completion..." |
|
8997 |
||
8998 |
|oldString newString| |
|
8999 |
||
9000 |
oldString := lastStringToReplace. |
|
9001 |
newString := lastReplacement. |
|
9002 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
9003 |
previousReplacements isNil ifTrue:[ |
|
9004 |
previousReplacements := OrderedCollection new. |
|
9005 |
]. |
|
9006 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9007 |
previousReplacements addFirst:(oldString -> newString). |
|
9008 |
previousReplacements size > 20 ifTrue:[ |
|
9009 |
previousReplacements removeLast. |
|
9010 |
] |
|
9011 |
]. |
|
4048 | 9012 |
! ! |
9013 |
||
2952 | 9014 |
!EditTextView::PasteString methodsFor:'accessing'! |
9015 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9016 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9017 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9018 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9019 |
"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
|
9020 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9021 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9022 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9023 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9024 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9025 |
"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
|
9026 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9027 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9028 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9029 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9030 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9031 |
"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
|
9032 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9033 |
|
3160 | 9034 |
line:lineArg col:colArg string:stringArg |
2952 | 9035 |
self assert:(lineArg notNil). |
9036 |
self assert:(colArg notNil). |
|
9037 |
self assert:(stringArg notNil). |
|
9038 |
||
9039 |
line := lineArg. |
|
9040 |
col := colArg. |
|
9041 |
string := stringArg. |
|
9042 |
! |
|
9043 |
||
9044 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9045 |
self assert:(lineArg notNil). |
|
9046 |
self assert:(colArg notNil). |
|
9047 |
self assert:(stringArg notNil). |
|
9048 |
||
9049 |
line := lineArg. |
|
9050 |
col := colArg. |
|
9051 |
string := stringArg. |
|
9052 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9053 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9054 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9055 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9056 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9057 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9058 |
"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
|
9059 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9060 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9061 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9062 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9063 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9064 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9065 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9066 |
"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
|
9067 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9068 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9069 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9070 |
"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
|
9071 |
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
|
9072 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9073 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9074 |
previousPasteAction line == line ifTrue:[ |
4823 | 9075 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9076 |
^ true |
|
9077 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9078 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9079 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9080 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9081 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9082 |
"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
|
9083 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9084 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9085 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9086 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9087 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9088 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9089 |
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
|
9090 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9091 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9092 |
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
|
9093 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9094 |
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
|
9095 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9096 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9097 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9098 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9099 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9100 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9101 |
! ! |
9102 |
||
9103 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9104 |
||
3160 | 9105 |
executeIn:editor |
2952 | 9106 |
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
|
9107 |
editor paste:string. |
2952 | 9108 |
selected ~~ true ifTrue:[ |
4823 | 9109 |
editor unselect |
2952 | 9110 |
]. |
9111 |
! ! |
|
9112 |
||
9113 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9114 |
||
3235 | 9115 |
col |
9116 |
^ col |
|
9117 |
! |
|
9118 |
||
9119 |
col1 |
|
9120 |
^ col |
|
9121 |
! |
|
9122 |
||
9123 |
col2 |
|
9124 |
^ col |
|
9125 |
! |
|
9126 |
||
9127 |
line |
|
9128 |
^ line |
|
9129 |
! |
|
9130 |
||
3160 | 9131 |
line:lineArg col:colArg character:characterArg |
2952 | 9132 |
line := lineArg. |
9133 |
col := colArg. |
|
9134 |
character := characterArg. |
|
9135 |
! ! |
|
9136 |
||
9137 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9138 |
||
3160 | 9139 |
executeIn:editor |
9140 |
editor |
|
4823 | 9141 |
replace:character |
9142 |
atLine:line |
|
9143 |
col:col. |
|
2952 | 9144 |
editor cursorLine:line col:col. |
105 | 9145 |
! ! |
9146 |
||
3235 | 9147 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9148 |
||
9149 |
characters |
|
9150 |
^ characters |
|
9151 |
! |
|
9152 |
||
9153 |
col1 |
|
9154 |
^ col1 |
|
9155 |
! |
|
9156 |
||
9157 |
col2 |
|
9158 |
^ col2 |
|
9159 |
! |
|
9160 |
||
9161 |
line |
|
9162 |
^ line |
|
9163 |
! |
|
9164 |
||
9165 |
line:lineArg col:colArg character:characterArg |
|
9166 |
line := lineArg. |
|
9167 |
col1 := col2 := colArg. |
|
9168 |
characters := characterArg asString. |
|
9169 |
! |
|
9170 |
||
9171 |
line:lineArg col:colArg characters:charactersArg |
|
9172 |
line := lineArg. |
|
9173 |
col1 := colArg. |
|
9174 |
characters := charactersArg asString. |
|
9175 |
col2 := col1 + charactersArg size - 1 |
|
9176 |
! ! |
|
9177 |
||
9178 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9179 |
||
9180 |
canCombineWithNext:anotherAction |
|
9181 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9182 |
! |
|
9183 |
||
9184 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9185 |
"I will combine only if we both are single character deletes, |
|
9186 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9187 |
(i.e. single-character typing)" |
|
9188 |
||
9189 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 9190 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9191 |
^ true |
|
9192 |
]. |
|
3235 | 9193 |
]. |
9194 |
||
9195 |
^ false |
|
9196 |
! |
|
9197 |
||
9198 |
combineWithNext:nextReplaceAction |
|
9199 |
self assert:(line == nextReplaceAction line). |
|
9200 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9201 |
||
9202 |
col2 := nextReplaceAction col2. |
|
9203 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9204 |
characters := characters , nextReplaceAction characters. |
|
9205 |
! ! |
|
9206 |
||
9207 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9208 |
||
9209 |
executeIn:editor |
|
9210 |
editor |
|
4823 | 9211 |
replaceString:characters |
9212 |
atLine:line |
|
9213 |
col:col1. |
|
3235 | 9214 |
editor cursorLine:line col:col1. |
9215 |
! ! |
|
9216 |
||
3131 | 9217 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9218 |
||
9219 |
text:something |
|
9220 |
text := something. |
|
9221 |
! ! |
|
9222 |
||
9223 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9224 |
||
3160 | 9225 |
executeIn:editor |
3131 | 9226 |
editor contents:text |
9227 |
! ! |
|
9228 |
||
3130 | 9229 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9230 |
||
3160 | 9231 |
line:lineArg string:stringArg |
3130 | 9232 |
line := lineArg. |
9233 |
text := stringArg. |
|
9234 |
! ! |
|
9235 |
||
9236 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9237 |
||
3160 | 9238 |
executeIn:editor |
3130 | 9239 |
editor list at:line put:text. |
9240 |
editor invalidateLine:line |
|
9241 |
! ! |
|
9242 |
||
3402 | 9243 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9244 |
||
9245 |
line:lineArg lines:lineCollectionArg |
|
9246 |
line := lineArg. |
|
9247 |
text := lineCollectionArg. |
|
9248 |
||
9249 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9250 |
! ! |
|
9251 |
||
9252 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9253 |
||
9254 |
executeIn:editor |
|
9255 |
|lnr| |
|
9256 |
||
9257 |
lnr := line. |
|
9258 |
text do:[:eachLine | |
|
4823 | 9259 |
editor list at:lnr put:eachLine. |
9260 |
editor invalidateLine:lnr. |
|
9261 |
lnr := lnr + 1. |
|
3402 | 9262 |
]. |
9263 |
||
9264 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9265 |
! ! |
|
9266 |
||
5689 | 9267 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9268 |
||
9269 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9270 |
cursorLine := cursorLineArg. |
|
9271 |
cursorCol := cursorColArg. |
|
9272 |
selectionStartLine := selectionStartLineArg. |
|
9273 |
selectionStartCol := selectionStartColArg. |
|
9274 |
selectionEndLine := selectionEndLineArg. |
|
9275 |
selectionEndCol := selectionEndColArg. |
|
9276 |
! |
|
9277 |
||
9278 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
9279 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
9280 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9281 |
info:info |
|
9282 |
||
9283 |
cursorLine := cursorLineArg. |
|
9284 |
cursorCol := cursorColArg. |
|
9285 |
selectionStartLine := selectionStartLineArg. |
|
9286 |
selectionStartCol := selectionStartColArg. |
|
9287 |
selectionEndLine := selectionEndLineArg. |
|
9288 |
selectionEndCol := selectionEndColArg. |
|
9289 |
userFriendlyInfo := info. |
|
9290 |
||
9291 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9292 |
! ! |
|
9293 |
||
9294 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9295 |
||
9296 |
executeIn:editor |
|
9297 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9298 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
9299 |
editor setCursorLine:cursorLine col:cursorCol. |
|
9300 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
9301 |
] ifFalse:[ |
|
9302 |
editor cursorLine:cursorLine col:cursorCol. |
|
9303 |
]. |
|
9304 |
||
9305 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9306 |
! ! |
|
9307 |
||
5710 | 9308 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9309 |
||
9310 |
isRestoreSelectionAndCursor |
|
9311 |
^ true |
|
9312 |
! ! |
|
9313 |
||
865 | 9314 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9315 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9316 |
version |
5361 | 9317 |
^ '$Header$' |
3945 | 9318 |
! |
9319 |
||
9320 |
version_CVS |
|
5361 | 9321 |
^ '$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
|
9322 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9323 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9324 |
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
|
9325 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9326 |
^ '$Changeset: <not expanded> $' |
0 | 9327 |
! ! |
4481 | 9328 |