author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 30 Aug 2013 00:22:34 +0100 | |
branch | text-view-selection-refactoring |
changeset 4844 | 269a12794578 |
parent 4843 | 7cd827899263 |
child 4845 | 23ab15b7f4e0 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
3160 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
0 | 14 |
TextView subclass:#EditTextView |
2724 | 15 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
16 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
17 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
4048 | 18 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
4010 | 19 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
20 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
21 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
22 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
23 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
4048 | 24 |
undoSupport lastStringFromReplaceForNextSearch |
4609 | 25 |
lastReplacementInfo completionView' |
2724 | 26 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
27 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
4673 | 28 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
2724 | 29 |
poolDictionaries:'' |
30 |
category:'Views-Text' |
|
0 | 31 |
! |
32 |
||
2952 | 33 |
Object subclass:#EditAction |
3115 | 34 |
instanceVariableNames:'userFriendlyInfo' |
2952 | 35 |
classVariableNames:'' |
36 |
poolDictionaries:'' |
|
37 |
privateIn:EditTextView |
|
38 |
! |
|
39 |
||
40 |
EditTextView::EditAction subclass:#DeleteRange |
|
41 |
instanceVariableNames:'line1 col1 line2 col2' |
|
42 |
classVariableNames:'' |
|
43 |
poolDictionaries:'' |
|
44 |
privateIn:EditTextView |
|
45 |
! |
|
46 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
47 |
EditTextView::EditAction subclass:#DeleteCharacters |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
48 |
instanceVariableNames:'line col1 col2' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
classVariableNames:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
50 |
poolDictionaries:'' |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
51 |
privateIn:EditTextView |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
53 |
|
3235 | 54 |
Object subclass:#EditMode |
55 |
instanceVariableNames:'' |
|
56 |
classVariableNames:'' |
|
57 |
poolDictionaries:'' |
|
58 |
privateIn:EditTextView |
|
59 |
! |
|
60 |
||
61 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
62 |
instanceVariableNames:'' |
|
63 |
classVariableNames:'' |
|
64 |
poolDictionaries:'' |
|
65 |
privateIn:EditTextView::EditMode |
|
66 |
! |
|
67 |
||
68 |
EditTextView::EditMode subclass:#InsertMode |
|
69 |
instanceVariableNames:'' |
|
70 |
classVariableNames:'' |
|
71 |
poolDictionaries:'' |
|
72 |
privateIn:EditTextView::EditMode |
|
73 |
! |
|
74 |
||
75 |
EditTextView::EditMode subclass:#OverwriteMode |
|
76 |
instanceVariableNames:'' |
|
77 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
78 |
poolDictionaries:'' |
|
79 |
privateIn:EditTextView::EditMode |
|
80 |
! |
|
81 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
82 |
Query subclass:#ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
83 |
instanceVariableNames:'' |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
classVariableNames:'' |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
85 |
poolDictionaries:'' |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
86 |
privateIn:EditTextView |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
87 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
88 |
|
4048 | 89 |
Object subclass:#LastReplacementInfo |
90 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
|
91 |
lastReplaceIgnoredCase' |
|
92 |
classVariableNames:'' |
|
93 |
poolDictionaries:'' |
|
94 |
privateIn:EditTextView |
|
95 |
! |
|
96 |
||
2952 | 97 |
EditTextView::EditAction subclass:#PasteString |
98 |
instanceVariableNames:'line col string selected' |
|
99 |
classVariableNames:'' |
|
100 |
poolDictionaries:'' |
|
101 |
privateIn:EditTextView |
|
102 |
! |
|
103 |
||
104 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
105 |
instanceVariableNames:'line col character' |
|
106 |
classVariableNames:'' |
|
107 |
poolDictionaries:'' |
|
108 |
privateIn:EditTextView |
|
109 |
! |
|
110 |
||
3235 | 111 |
EditTextView::EditAction subclass:#ReplaceCharacters |
112 |
instanceVariableNames:'line col1 col2 characters' |
|
113 |
classVariableNames:'' |
|
114 |
poolDictionaries:'' |
|
115 |
privateIn:EditTextView |
|
116 |
! |
|
117 |
||
3131 | 118 |
EditTextView::EditAction subclass:#ReplaceContents |
119 |
instanceVariableNames:'text' |
|
120 |
classVariableNames:'' |
|
121 |
poolDictionaries:'' |
|
122 |
privateIn:EditTextView |
|
123 |
! |
|
124 |
||
3130 | 125 |
EditTextView::EditAction subclass:#ReplaceLine |
126 |
instanceVariableNames:'line text' |
|
127 |
classVariableNames:'' |
|
128 |
poolDictionaries:'' |
|
129 |
privateIn:EditTextView |
|
130 |
! |
|
131 |
||
3402 | 132 |
EditTextView::EditAction subclass:#ReplaceLines |
133 |
instanceVariableNames:'line text' |
|
134 |
classVariableNames:'' |
|
135 |
poolDictionaries:'' |
|
136 |
privateIn:EditTextView |
|
137 |
! |
|
138 |
||
865 | 139 |
!EditTextView class methodsFor:'documentation'! |
0 | 140 |
|
33 | 141 |
copyright |
142 |
" |
|
143 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3160 | 144 |
All Rights Reserved |
33 | 145 |
|
146 |
This software is furnished under a license and may be used |
|
147 |
only in accordance with the terms of that license and with the |
|
148 |
inclusion of the above copyright notice. This software may not |
|
149 |
be provided or otherwise made available to, or used by, any |
|
150 |
other person. No title to or ownership of the software is |
|
151 |
hereby transferred. |
|
152 |
" |
|
153 |
! |
|
154 |
||
0 | 155 |
documentation |
156 |
" |
|
157 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 158 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
159 |
acceptAction to be performed for accept |
125 | 160 |
|
161 |
If used with a model, this is informed by sending it a changeMsg with |
|
162 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
163 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 164 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
165 |
Please read the historic notice in the ListView class. |
0 | 166 |
|
586 | 167 |
[Instance variables:] |
0 | 168 |
|
4010 | 169 |
cursorLine <Number> line where cursor sits (1..) |
170 |
||
171 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
172 |
||
173 |
cursorCol <Number> col where cursor sits (1..) |
|
174 |
||
175 |
cursorShown <Boolean> true, if cursor is currently shown |
|
176 |
||
177 |
readOnly <Boolean> true, if text may not be edited |
|
178 |
||
179 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
180 |
cleared on accept. |
|
181 |
||
182 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
183 |
||
184 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
185 |
||
186 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
187 |
if it returns true, the modification will be done anyway. |
|
188 |
if it returns anything else, the modification is not done. |
|
189 |
||
190 |
cursorFgColor <Color> color used for cursor drawing |
|
191 |
cursorBgColor <Color> color used for cursor drawing |
|
192 |
||
193 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
194 |
are #block (solid-block cursor), #ibeam |
|
195 |
(vertical bar at insertion point) |
|
196 |
and #caret (caret below insertion-point) |
|
197 |
||
198 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
199 |
nil means: hide the cursor. |
|
200 |
||
201 |
undoAction <Block> block which undoes last cut, paste or replace |
|
202 |
(not yet fully implemented) |
|
203 |
||
204 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
205 |
this affects the next keyPress: if #paste it does not |
|
206 |
replace; otherwise it replaces the selection. |
|
207 |
||
208 |
lastCut <String> last cut or replaced string |
|
209 |
||
4053 | 210 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
211 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
212 |
lastReplacement is the string to replace lastStringToReplace |
|
213 |
||
214 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
215 |
(cleared after a new selection) |
|
4010 | 216 |
|
217 |
replacing <Boolean> true if entered characters replace last selection |
|
218 |
||
219 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
220 |
when entering one; this is the default. |
|
221 |
||
222 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
223 |
||
224 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
225 |
argument |
|
226 |
||
227 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
228 |
focus to the next field. For editTextViews, this is false |
|
229 |
by default (i.e. tabs can be entered into the text). |
|
230 |
For some subclasses (inputFields), this may be true. |
|
231 |
||
232 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
233 |
removed when editing. |
|
234 |
Default is true. |
|
235 |
||
236 |
wordWrap <Boolean> Currently not used. |
|
237 |
||
238 |
lockUpdates <Boolean> internal, private |
|
239 |
||
240 |
prevCursorState <Boolean> temporary, private |
|
241 |
||
242 |
cursorMovementWhenUpdating |
|
243 |
<Symbol> defines where the cursor is to be positioned if the |
|
244 |
model changes its value by some outside activity |
|
245 |
(i.e. not by user input into the field). |
|
246 |
Can be one of: |
|
247 |
#keep / nil -> stay where it was |
|
248 |
#endOfText -> cursor to the end |
|
249 |
#endOfLine -> stay in the line, but move to end |
|
250 |
#beginOfText -> cursor to the beginning |
|
251 |
#beginOfLine -> stay in the line, but move to begin |
|
252 |
The default is #beginOfText |
|
253 |
||
254 |
||
255 |
||
256 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 257 |
|
258 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
259 |
userPreference values: |
4010 | 260 |
userPreferences.st80EditMode |
261 |
<Boolean> if true, cursor positioning is |
|
262 |
done as in vi or ST80; i.e. |
|
263 |
wysiwyg mode is somewhat relaxed, |
|
264 |
in that the cursor cannot be |
|
265 |
positioned behind a lines end. |
|
266 |
This is not yet completely implemented. |
|
33 | 267 |
used globals: |
268 |
||
4010 | 269 |
DeleteHistory <Text> last 1000 lines of deleted text |
270 |
(but only if this variable exists already) |
|
586 | 271 |
|
272 |
[styleSheet parameters:] |
|
121 | 273 |
|
4010 | 274 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
275 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
276 |
textCursorNoFocusForegroundColor |
|
277 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
278 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 279 |
|
280 |
[author:] |
|
4010 | 281 |
Claus Gittinger |
586 | 282 |
|
283 |
[see also:] |
|
4010 | 284 |
CodeView Workspace TextView ListView |
285 |
EditField |
|
0 | 286 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
287 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
288 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
289 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
basic setup: |
3160 | 294 |
[exBegin] |
295 |
|top textView| |
|
296 |
||
297 |
top := StandardSystemView new. |
|
298 |
top extent:300@200. |
|
299 |
||
300 |
textView := EditTextView new. |
|
301 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
302 |
top addSubView:textView. |
|
303 |
||
304 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
305 |
||
306 |
top open. |
|
307 |
[exEnd] |
|
594 | 308 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
309 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
310 |
with vertical scrollbar: |
3160 | 311 |
[exBegin] |
312 |
|top scrollView textView| |
|
313 |
||
314 |
top := StandardSystemView new. |
|
315 |
top extent:300@200. |
|
316 |
||
317 |
scrollView := ScrollableView for:EditTextView. |
|
318 |
textView := scrollView scrolledView. |
|
319 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
320 |
top addSubView:scrollView. |
|
321 |
||
322 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
323 |
||
324 |
top open. |
|
325 |
[exEnd] |
|
594 | 326 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
327 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
328 |
with horizontal & vertical scrollbars: |
3160 | 329 |
[exBegin] |
330 |
|top scrollView textView| |
|
331 |
||
332 |
top := StandardSystemView new. |
|
333 |
top extent:300@200. |
|
334 |
||
335 |
scrollView := HVScrollableView for:EditTextView. |
|
336 |
textView := scrollView scrolledView. |
|
337 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
338 |
top addSubView:scrollView. |
|
339 |
||
340 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
341 |
||
342 |
top open. |
|
343 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
344 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
346 |
set the action for accept: |
3160 | 347 |
[exBegin] |
348 |
|top textView| |
|
349 |
||
350 |
top := StandardSystemView new. |
|
351 |
top extent:300@200. |
|
352 |
||
353 |
textView := EditTextView new. |
|
354 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
355 |
top addSubView:textView. |
|
356 |
||
357 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
358 |
textView acceptAction:[:contents | |
|
359 |
Transcript showCR:'will not overwrite the file with:'. |
|
360 |
Transcript showCR:contents asString |
|
361 |
]. |
|
362 |
top open. |
|
363 |
[exEnd] |
|
594 | 364 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
365 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
366 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
367 |
non-string (text) items: |
3160 | 368 |
[exBegin] |
369 |
|top textView list| |
|
370 |
||
371 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
372 |
1 to:list size by:2 do:[:nr | |
|
373 |
list at:nr put:(Text string:(list at:nr) |
|
374 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
375 |
]. |
|
376 |
||
377 |
top := StandardSystemView new. |
|
378 |
top extent:300@200. |
|
379 |
||
380 |
textView := EditTextView new. |
|
381 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
382 |
top addSubView:textView. |
|
383 |
||
384 |
textView contents:list. |
|
385 |
top open. |
|
386 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
387 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
388 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
389 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
390 |
MVC operation: |
594 | 391 |
(the examples model here is a plug simulating a real model; |
392 |
real world applications would not use a plug ..) |
|
3160 | 393 |
[exBegin] |
394 |
|top textView model| |
|
395 |
||
396 |
model := Plug new. |
|
397 |
model respondTo:#accepted: |
|
398 |
with:[:newContents | |
|
399 |
Transcript showCR:'will not overwrite the file with:'. |
|
400 |
Transcript showCR:newContents asString |
|
401 |
]. |
|
402 |
model respondTo:#getList |
|
403 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
404 |
||
405 |
||
406 |
top := StandardSystemView new. |
|
407 |
top extent:300@200. |
|
408 |
||
409 |
textView := EditTextView new. |
|
410 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
411 |
top addSubView:textView. |
|
412 |
||
413 |
textView listMessage:#getList; |
|
414 |
model:model; |
|
415 |
changeMessage:#accepted:; |
|
416 |
aspect:#list. |
|
417 |
top open. |
|
418 |
[exEnd] |
|
594 | 419 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
420 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
421 |
two textViews on the same model: |
3160 | 422 |
[exBegin] |
423 |
|top1 textView1 top2 textView2 model currentContents| |
|
424 |
||
425 |
model := Plug new. |
|
426 |
model respondTo:#accepted: |
|
427 |
with:[:newContents | |
|
428 |
Transcript showCR:'accepted:'. |
|
429 |
Transcript showCR:newContents asString. |
|
430 |
currentContents := newContents. |
|
431 |
model changed:#contents |
|
432 |
]. |
|
433 |
model respondTo:#getList |
|
434 |
with:[Transcript showCR:'query'. |
|
435 |
currentContents]. |
|
436 |
||
437 |
||
438 |
top1 := StandardSystemView new. |
|
439 |
top1 extent:300@200. |
|
440 |
||
441 |
textView1 := EditTextView new. |
|
442 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
443 |
top1 addSubView:textView1. |
|
444 |
||
445 |
textView1 listMessage:#getList; |
|
446 |
model:model; |
|
447 |
aspect:#contents; |
|
448 |
changeMessage:#accepted:. |
|
449 |
top1 open. |
|
450 |
||
451 |
top2 := StandardSystemView new. |
|
452 |
top2 extent:300@200. |
|
453 |
||
454 |
textView2 := EditTextView new. |
|
455 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
456 |
top2 addSubView:textView2. |
|
457 |
||
458 |
textView2 listMessage:#getList; |
|
459 |
model:model; |
|
460 |
aspect:#contents; |
|
461 |
changeMessage:#accepted:. |
|
462 |
top2 open. |
|
463 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
464 |
" |
0 | 465 |
! ! |
466 |
||
865 | 467 |
!EditTextView class methodsFor:'defaults'! |
59 | 468 |
|
1419 | 469 |
st80Mode |
470 |
"return true, if the st80 editing mode is turned on. |
|
471 |
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
|
472 |
beyond the end of a line or the end of the text." |
1419 | 473 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
474 |
^ UserPreferences current st80EditMode |
1419 | 475 |
|
476 |
" |
|
477 |
EditTextView st80Mode:true |
|
478 |
EditTextView st80Mode:false |
|
479 |
" |
|
480 |
||
481 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
482 |
! |
|
483 |
||
484 |
st80Mode:aBoolean |
|
485 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 486 |
beyond the end of a line or the last line" |
1419 | 487 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
488 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 489 |
|
490 |
" |
|
491 |
EditTextView st80Mode:true |
|
492 |
EditTextView st80Mode:false |
|
493 |
" |
|
494 |
||
495 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
496 |
! |
|
497 |
||
59 | 498 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
499 |
"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
|
500 |
|
1390 | 501 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
3160 | 502 |
#'textCursor.noFocusForegroundColor' |
503 |
#'textCursor.type' |
|
504 |
#'textCursor.typeNoFocus' |
|
505 |
#'editText.st80Mode')> |
|
1355 | 506 |
|
507 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
508 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
509 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
510 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
511 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
512 |
|
1419 | 513 |
" |
514 |
self updateStyleCache |
|
515 |
" |
|
516 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
517 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 518 |
! ! |
519 |
||
3431 | 520 |
!EditTextView class methodsFor:'specs'! |
521 |
||
522 |
searchReplaceDialogSpec |
|
523 |
"This resource specification was automatically generated |
|
524 |
by the UIPainter of ST/X." |
|
525 |
||
526 |
"Do not manually edit this!! If it is corrupted, |
|
527 |
the UIPainter may not be able to read the specification." |
|
528 |
||
529 |
" |
|
530 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
531 |
" |
|
532 |
||
533 |
<resource: #canvas> |
|
534 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
535 |
^ |
3431 | 536 |
#(FullSpec |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
537 |
name: searchReplaceDialogSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
538 |
window: |
3431 | 539 |
(WindowSpec |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
540 |
label: 'String Search and Replace' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
541 |
name: 'String Search and Replace' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
542 |
min: (Point 283 196) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
543 |
max: (Point 283 196) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
544 |
bounds: (Rectangle 0 0 279 192) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
545 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
546 |
component: |
3431 | 547 |
(SpecCollection |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
548 |
collection: ( |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
549 |
(LabelSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
550 |
label: 'Search Pattern:' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
551 |
name: 'label' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
552 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
553 |
level: 0 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
554 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
555 |
adjust: left |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
556 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
557 |
(ComboBoxSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
558 |
name: 'patternComboBox' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
559 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
560 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
561 |
model: searchPattern |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
562 |
immediateAccept: false |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
563 |
acceptOnLeave: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
564 |
acceptOnReturn: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
565 |
acceptOnTab: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
566 |
acceptOnLostFocus: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
567 |
acceptOnPointerLeave: false |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
568 |
autoSelectInitialText: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
569 |
comboList: patternList |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
570 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
571 |
(ComboBoxSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
572 |
name: 'replaceComboBox' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
573 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
574 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
575 |
model: replacePattern |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
576 |
immediateAccept: false |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
577 |
acceptOnLeave: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
578 |
acceptOnReturn: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
579 |
acceptOnTab: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
580 |
acceptOnLostFocus: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
581 |
acceptOnPointerLeave: false |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
582 |
autoSelectInitialText: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
583 |
comboList: patternList |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
584 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
585 |
(CheckBoxSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
586 |
label: 'Ignore Case' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
587 |
name: 'ignoreCaseCheckBox' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
588 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
589 |
level: 0 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
590 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
591 |
model: ignoreCase |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
592 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
593 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
594 |
(VariableVerticalPanelSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
595 |
name: 'VariableVerticalPanel1' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
596 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
597 |
component: |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
598 |
(SpecCollection |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
599 |
collection: ( |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
600 |
(HorizontalPanelViewSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
601 |
name: 'HorizontalPanel1' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
602 |
level: 0 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
603 |
horizontalLayout: fitSpace |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
604 |
verticalLayout: center |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
605 |
horizontalSpace: 3 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
606 |
verticalSpace: 3 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
607 |
ignoreInvisibleComponents: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
608 |
reverseOrderIfOKAtLeft: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
609 |
component: |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
610 |
(SpecCollection |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
611 |
collection: ( |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
612 |
(ActionButtonSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
613 |
label: 'Replace' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
614 |
name: 'replaceButton' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
615 |
level: 2 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
616 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
617 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
618 |
model: replaceAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
619 |
extent: (Point 134 21) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
620 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
621 |
(ActionButtonSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
622 |
label: 'Replace All' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
623 |
name: 'replaceAllButton' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
624 |
level: 2 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
625 |
borderWidth: 1 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
626 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
627 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
628 |
model: replaceAllAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
629 |
extent: (Point 134 21) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
630 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
631 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
632 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
633 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
634 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
635 |
(HorizontalPanelViewSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
636 |
name: 'horizontalPanelView' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
637 |
level: 0 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
638 |
horizontalLayout: fitSpace |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
639 |
verticalLayout: center |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
640 |
horizontalSpace: 3 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
641 |
verticalSpace: 3 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
642 |
ignoreInvisibleComponents: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
643 |
reverseOrderIfOKAtLeft: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
644 |
component: |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
645 |
(SpecCollection |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
646 |
collection: ( |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
647 |
(ActionButtonSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
648 |
label: 'Cancel' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
649 |
name: 'cancelButton' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
650 |
level: 2 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
651 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
652 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
653 |
model: cancel |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
654 |
extent: (Point 88 21) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
655 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
656 |
(ActionButtonSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
657 |
label: 'Prev' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
658 |
name: 'prevButton' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
659 |
level: 2 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
660 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
661 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
662 |
model: prevAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
663 |
extent: (Point 89 21) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
664 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
665 |
(ActionButtonSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
666 |
label: 'Next' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
667 |
name: 'nextButton' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
668 |
level: 2 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
669 |
borderWidth: 1 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
670 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
671 |
tabable: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
672 |
model: nextAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
673 |
isDefault: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
674 |
extent: (Point 88 21) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
675 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
676 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
677 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
678 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
679 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
680 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
681 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
682 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
683 |
handles: (Any 0.5 1.0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
684 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
685 |
(LabelSpec |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
686 |
label: 'Replace By:' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
687 |
name: 'ReplaceLabel' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
688 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
689 |
level: 0 |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
690 |
translateLabel: true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
691 |
adjust: left |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
692 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
693 |
) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
694 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
695 |
) |
3431 | 696 |
) |
697 |
||
698 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
699 |
! ! |
|
700 |
||
2744 | 701 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
702 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
703 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
704 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
705 |
|
2019 | 706 |
"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
|
707 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
708 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
709 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
710 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
711 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
712 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
713 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
714 |
|
1390 | 715 |
cutSelection |
716 |
self cut |
|
717 |
||
718 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
719 |
! |
|
720 |
||
1590 | 721 |
deselect |
722 |
"remove the selection" |
|
723 |
||
724 |
^ self unselect |
|
725 |
||
726 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
727 |
! |
|
728 |
||
2101 | 729 |
enabled:aBoolean |
730 |
||
731 |
self readOnly:aBoolean not |
|
732 |
||
733 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
734 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
735 |
! |
|
736 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
737 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
738 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
739 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
740 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
741 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
742 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
743 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
744 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
745 |
"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
|
746 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
747 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
748 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
749 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
750 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
751 |
col < 1 ifTrue:[ |
3160 | 752 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
753 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
754 |
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
|
755 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
756 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
757 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
758 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
759 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
760 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
761 |
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
|
762 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
763 |
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
|
764 |
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
|
765 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
766 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
767 |
"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
|
768 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
769 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
770 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
771 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
772 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
773 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
774 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
775 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 776 |
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
|
777 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
778 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 779 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
780 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
781 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
782 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
783 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
784 |
v insertAndSelect:'<- hello there' at:5. |
125 | 785 |
" |
1390 | 786 |
! |
787 |
||
788 |
pasteSelection |
|
789 |
self paste |
|
790 |
||
791 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 792 |
! |
793 |
||
794 |
replaceSelectionWith:aString |
|
795 |
^ self replaceSelectionBy:aString |
|
796 |
||
797 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
798 |
! |
|
799 |
||
800 |
selectAt:pos |
|
801 |
"move the cursor before cursorPosition." |
|
802 |
||
803 |
self cursorToCharacterPosition:pos |
|
804 |
||
805 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
806 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
807 |
! |
|
808 |
||
2101 | 809 |
textHasChanged |
810 |
^ self modified |
|
811 |
||
812 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
813 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
814 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
815 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
816 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
817 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
818 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
819 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
820 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
821 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
822 |
|
4585 | 823 |
!EditTextView methodsFor:'accessing'! |
824 |
||
4609 | 825 |
editedClass |
826 |
|cm| |
|
827 |
||
828 |
cm := self editedMethodOrClass. |
|
829 |
cm isBehavior ifTrue:[^ cm]. |
|
830 |
cm isMethod ifTrue:[^ cm mclass]. |
|
831 |
^ nil |
|
832 |
! |
|
833 |
||
834 |
editedMethod |
|
835 |
|cm| |
|
836 |
||
837 |
cm := self editedMethodOrClass. |
|
838 |
cm isMethod ifTrue:[^ cm]. |
|
839 |
cm isBehavior ifTrue:[^ nil]. |
|
840 |
^ nil |
|
841 |
! |
|
842 |
||
843 |
editedMethodOrClass |
|
844 |
^ nil |
|
845 |
! |
|
846 |
||
4585 | 847 |
hasSelectionOrTextInCursorLine |
848 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
849 |
! |
|
850 |
||
4589 | 851 |
selectionOrTextOfCursorLine |
852 |
^ self selectionOrTextOfCursorLine:true |
|
853 |
! |
|
854 |
||
4585 | 855 |
selectionOrTextOfCursorLine:doSelect |
856 |
|sel lNr line| |
|
857 |
||
858 |
sel := self selectionAsString. |
|
859 |
sel notNil ifTrue:[^ sel]. |
|
860 |
||
861 |
lNr := self cursorLine. |
|
862 |
line := self listAt:lNr. |
|
863 |
line notEmptyOrNil ifTrue:[ |
|
864 |
doSelect ifTrue:[ |
|
865 |
self selectLine:lNr. |
|
866 |
]. |
|
867 |
^ line |
|
868 |
]. |
|
869 |
||
870 |
^ nil |
|
871 |
! ! |
|
872 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
873 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
874 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
875 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
876 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
877 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
878 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
879 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
880 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
881 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
882 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
883 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
884 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
885 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
886 |
|
2792 | 887 |
acceptChannel |
888 |
"return the valueHolder holding true if text was accepted. |
|
889 |
By placing a true into this channel, an accept can also be forced." |
|
890 |
||
891 |
^ acceptChannel |
|
892 |
||
893 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
894 |
! |
|
895 |
||
896 |
acceptChannel:aValueHolder |
|
897 |
"set the valueHolder holding true if text was accepted. |
|
898 |
By placing a true into this channel, an accept can also be forced." |
|
899 |
||
900 |
|prev| |
|
901 |
||
902 |
prev := acceptChannel. |
|
903 |
acceptChannel := aValueHolder. |
|
904 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
905 |
||
906 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
907 |
! |
|
908 |
||
1108 | 909 |
acceptEnabled:aBoolean |
910 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
911 |
||
912 |
acceptEnabled := aBoolean |
|
913 |
||
914 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
915 |
! |
|
916 |
||
2792 | 917 |
accepted |
918 |
"return true if text was accepted" |
|
919 |
||
920 |
^ acceptChannel value |
|
921 |
||
922 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
923 |
! |
|
924 |
||
925 |
accepted:aBoolean |
|
926 |
"set/clear the accepted flag. |
|
927 |
This may force my current contents to be placed into my model." |
|
928 |
||
929 |
acceptChannel value:aBoolean. |
|
930 |
||
931 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
932 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
933 |
! |
|
934 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
935 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
936 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
937 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
938 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
939 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
940 |
|
2774 | 941 |
cursorMovementWhenUpdating |
3160 | 942 |
"return what is be done with the cursor, |
2774 | 943 |
when I get a new text (via the model or the #contents/#list) |
944 |
Allowed arguments are: |
|
3160 | 945 |
#keep / nil -> stay where it was |
946 |
#endOfText -> position cursor to the end |
|
947 |
#beginOfText -> position cursor to the beginning |
|
948 |
#endOfLine -> position cursor to the current lines end |
|
949 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 950 |
The default is #beginOfText. |
951 |
This may be useful for fields which get new values assigned from |
|
952 |
the program (i.e. not from the user)" |
|
953 |
||
954 |
^ cursorMovementWhenUpdating |
|
955 |
||
956 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
957 |
! |
|
958 |
||
2133 | 959 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 960 |
"define what should be done with the cursor, |
2133 | 961 |
when I get a new text (via the model or the #contents/#list) |
962 |
Allowed arguments are: |
|
3160 | 963 |
#keep / nil -> stay where it was |
964 |
#endOfText -> position cursor to the end |
|
965 |
#beginOfText -> position cursor to the beginning |
|
966 |
#endOfLine -> position cursor to the current lines end |
|
967 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 968 |
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
|
969 |
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
|
970 |
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
|
971 |
|
2133 | 972 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
973 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
974 |
"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
|
975 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
976 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
977 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
978 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
979 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
980 |
|
2438 | 981 |
dontReplaceSelectionOnInput |
982 |
typeOfSelection := #paste |
|
983 |
! |
|
984 |
||
3235 | 985 |
editModeHolder |
986 |
^ editMode. |
|
987 |
! |
|
988 |
||
989 |
editModeInsert |
|
990 |
editMode value:EditMode insertMode |
|
991 |
! |
|
992 |
||
993 |
editModeInsertAndSelect |
|
994 |
editMode value:EditMode insertAndSelectMode |
|
995 |
! |
|
996 |
||
997 |
editModeOverwrite |
|
998 |
editMode value:EditMode overwriteMode |
|
999 |
! |
|
1000 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1001 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1002 |
"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
|
1003 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1004 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1005 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1006 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1007 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1008 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1009 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1010 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1011 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1012 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1013 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1014 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1015 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1016 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1017 |
readOnly == true ifFalse:[ |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1018 |
readOnly := true. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1019 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1020 |
menu disableAll:#(cut paste replace indent) |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1021 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1022 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1023 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1024 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1025 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1026 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1027 |
insertMode:aBoolean |
3235 | 1028 |
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
|
1029 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1030 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1031 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1032 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1033 |
insertModeHolder |
3235 | 1034 |
^ BlockValue |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1035 |
with:[:m | m isInsertMode] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1036 |
argument:(editMode). |
3465 | 1037 |
|
1038 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1039 |
! |
1040 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1041 |
isInInsertMode |
3235 | 1042 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1043 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1044 |
|
2792 | 1045 |
isReadOnly |
1046 |
"return true, if the text is readonly." |
|
1047 |
||
1048 |
^ readOnly value |
|
1049 |
||
1050 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1051 |
! |
|
1052 |
||
2796 | 1053 |
modeLabelHolder |
1054 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1055 |
||
3160 | 1056 |
^ BlockValue |
4041 | 1057 |
with:[:e :l | |
1058 |
self isReadOnly ifTrue:[ |
|
1059 |
'' |
|
1060 |
] ifFalse:[ |
|
1061 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1062 |
ifFalse:[ e infoPrintString]]] |
|
1063 |
argument:(self editModeHolder) |
|
1064 |
argument:(self learnModeHolder). |
|
3465 | 1065 |
|
1066 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1067 |
! |
1068 |
||
2792 | 1069 |
modified |
1070 |
"return true if text was modified" |
|
1071 |
||
1072 |
^ modifiedChannel value |
|
1073 |
! |
|
1074 |
||
1075 |
modified:aBoolean |
|
1076 |
"set/clear the modified flag" |
|
1077 |
||
1078 |
modifiedChannel value:aBoolean |
|
1079 |
||
1080 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1081 |
! |
|
1082 |
||
1083 |
modifiedChannel |
|
1084 |
"return the valueHolder holding true if text was modified" |
|
1085 |
||
1086 |
^ modifiedChannel |
|
1087 |
! |
|
1088 |
||
1089 |
modifiedChannel:aValueHolder |
|
1090 |
"set the valueHolder holding true if text was modified" |
|
1091 |
||
1092 |
|prev| |
|
1093 |
||
1094 |
prev := modifiedChannel. |
|
1095 |
modifiedChannel := aValueHolder. |
|
1096 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1097 |
||
1098 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1099 |
! |
|
1100 |
||
1101 |
readOnly |
|
1102 |
"make the text readonly. |
|
4664 | 1103 |
Obsolete because it is obfuscating (looks like a getter) |
1104 |
- use #readOnly:" |
|
2792 | 1105 |
|
1106 |
<resource:#obsolete> |
|
1107 |
||
1108 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1109 |
self readOnly:true. |
2792 | 1110 |
|
4664 | 1111 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1112 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1113 |
! |
1114 |
||
1115 |
readOnly:aBoolean |
|
1116 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1117 |
The argument may also be a valueHolder." |
|
1118 |
||
1119 |
readOnly := aBoolean |
|
1120 |
||
1121 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1122 |
! |
|
1123 |
||
4192 | 1124 |
st80Mode:aBoolean |
1125 |
"set/clear the st80Mode flag. |
|
1126 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
1127 |
if off, we have the Rand-editor behavior (random access)" |
|
1128 |
||
1129 |
st80Mode := aBoolean |
|
1130 |
||
1131 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1132 |
! |
|
1133 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1134 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1135 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1136 |
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
|
1137 |
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
|
1138 |
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
|
1139 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1140 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1141 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1142 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1143 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1144 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1145 |
"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
|
1146 |
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
|
1147 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1148 |
|
3160 | 1149 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1150 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1151 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1152 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1153 |
"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
|
1154 |
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
|
1155 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1156 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1157 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1158 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1159 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1160 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1161 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1162 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1163 |
"change a line without change notification" |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1164 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1165 |
(self at:lineNr) = aLine ifFalse:[ |
3160 | 1166 |
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
|
1167 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1168 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1169 |
|
522 | 1170 |
at:lineNr put:aLine |
1171 |
(self at:lineNr) = aLine ifFalse:[ |
|
3160 | 1172 |
super at:lineNr put:aLine. |
1173 |
self textChanged |
|
522 | 1174 |
]. |
1175 |
! |
|
1176 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1177 |
characterBeforeCursor |
2707 | 1178 |
"return the character under the cursor - space if beyond line. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1179 |
For non-block cursors, this is the character immediately to the right |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1180 |
of the insertion-bar or caret." |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1181 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1182 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1183 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1184 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1185 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1186 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1187 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1188 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1189 |
characterUnderCursor |
2707 | 1190 |
"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
|
1191 |
For non-block cursors, this is the character immediately to the right |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1192 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1194 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1195 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1196 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1197 |
contents |
2213 | 1198 |
"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
|
1199 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1200 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1201 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1202 |
^ super contents. |
3313 | 1203 |
|
1204 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1205 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1206 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1207 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1208 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1209 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1210 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1211 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1212 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1213 |
keepUndoHistory ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1214 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1215 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1216 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1217 |
|
2213 | 1218 |
contentsAsString |
1219 |
"return the contents as a String (i.e. without emphasis)" |
|
1220 |
||
1221 |
list isNil ifTrue:[^ '']. |
|
1222 |
self removeTrailingBlankLines. |
|
1223 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
3160 | 1224 |
ifFalse:[each string] |
1225 |
]) asStringWithCRs |
|
2213 | 1226 |
! |
1227 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1228 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1229 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1230 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1231 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1232 |
^ cursorCol |
125 | 1233 |
! |
1234 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1235 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1236 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1237 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1238 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1239 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1240 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1241 |
cursorLine |
3160 | 1242 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1243 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1245 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1246 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1247 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1248 |
cursorLineHolder |
3160 | 1249 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1250 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1251 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1252 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1253 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1254 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1255 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1256 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1257 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1258 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1259 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1260 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1261 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1262 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1263 |
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
|
1264 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1265 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1266 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1267 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1268 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1269 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1270 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1271 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1272 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1273 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1274 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1275 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1276 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1277 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1278 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1279 |
^ 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
|
1280 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1281 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1282 |
"/ 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
|
1283 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1284 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1285 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1286 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1287 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1288 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1289 |
undoSupport resetHistories. |
2955 | 1290 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1291 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1292 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1293 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1294 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1295 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1296 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1297 |
|
4609 | 1298 |
!EditTextView methodsFor:'accessing-dimensions'! |
1299 |
||
1300 |
xOfCursor |
|
1301 |
||
1302 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
|
1303 |
||
1304 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1305 |
! ! |
|
4590 | 1306 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1307 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1308 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1309 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1310 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1311 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1312 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1313 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1314 |
wasOn := self hideCursor. |
1993 | 1315 |
cursorFgColor := color1 onDevice:device. |
1316 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1317 |
wasOn ifTrue:[self showCursor] |
1333 | 1318 |
! |
1319 |
||
1899 | 1320 |
cursorType |
1321 |
"return the style of the text cursor. |
|
1322 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1323 |
#bigCaret and #bigSolidCaret" |
1899 | 1324 |
|
1325 |
^ cursorType |
|
1326 |
||
1327 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1328 |
! |
|
1329 |
||
1333 | 1330 |
cursorType:aCursorTypeSymbol |
1331 |
"set the style of the text cursor. |
|
1332 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
|
3160 | 1333 |
#bigCaret and #bigSolidCaret" |
1333 | 1334 |
|
1334 | 1335 |
cursorType := aCursorTypeSymbol. |
1333 | 1336 |
|
1337 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1338 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1339 |
! |
1340 |
||
1899 | 1341 |
cursorTypeNoFocus |
1342 |
"return the style of the text cursor when the view has no focus. |
|
1343 |
If left unspecified, this is the same as the regular cursorType." |
|
1344 |
||
1345 |
^ cursorTypeNoFocus |
|
1346 |
||
1347 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1348 |
! |
|
1349 |
||
1334 | 1350 |
cursorTypeNoFocus:aCursorTypeSymbol |
1351 |
"set the style of the text cursor when the view has no focus. |
|
1352 |
If left unspecified, this is the same as the regular cursorType." |
|
1353 |
||
1354 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1355 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1356 |
|
4048 | 1357 |
!EditTextView methodsFor:'accessing-replace'! |
1358 |
||
1359 |
lastStringToReplace: aString |
|
1360 |
! ! |
|
1361 |
||
2119 | 1362 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1363 |
|
125 | 1364 |
accept |
1365 |
"accept the current contents by executing the accept-action and/or |
|
1366 |
changeMessage." |
|
1367 |
||
1108 | 1368 |
acceptEnabled == false ifTrue:[ |
3945 | 1369 |
self beep. |
1370 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1371 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1372 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1373 |
^ self |
1108 | 1374 |
]. |
1375 |
||
125 | 1376 |
lockUpdates := true. |
1013 | 1377 |
|
1378 |
"/ |
|
1379 |
"/ ST-80 way of doing it |
|
1380 |
"/ |
|
1381 |
model notNil ifTrue:[ |
|
4142 | 1382 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
3945 | 1383 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1384 |
]. |
1385 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1386 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1387 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1388 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1389 |
"/ 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
|
1390 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1391 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1392 |
acceptAction notNil ifTrue:[ |
3945 | 1393 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1394 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1395 |
|
125 | 1396 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1397 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1398 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1399 |
! |
1400 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1401 |
argForChangeMessage |
597 | 1402 |
"return the argument to be passed with the change notification. |
1403 |
Defined as separate method for easier subclassability." |
|
1404 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1405 |
^ self contents |
597 | 1406 |
|
1407 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1408 |
! |
1409 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1410 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1411 |
"get my contents from the model. |
597 | 1412 |
Redefined to ignore updates resulting from my own changes |
1413 |
(i.e. if lockUpdates is true)." |
|
121 | 1414 |
|
1415 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1416 |
ignore updates from my own change |
121 | 1417 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1418 |
lockUpdates ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1419 |
lockUpdates := false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1420 |
^ self |
121 | 1421 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1422 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1423 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1424 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1425 |
"/ validate the cursorLine |
3160 | 1426 |
(cursorLine notNil |
2310 | 1427 |
and:[ cursorLine > list size ]) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1428 |
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
|
1429 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1430 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1431 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1432 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1433 |
changedObject == acceptChannel ifTrue:[ |
3160 | 1434 |
acceptChannel value == true ifTrue:[ |
1435 |
self accept. |
|
1436 |
]. |
|
1437 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1438 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1439 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1440 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1441 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1442 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1443 |
! ! |
1444 |
||
1445 |
!EditTextView methodsFor:'cursor handling'! |
|
1446 |
||
2406 | 1447 |
characterPositionOfCursor |
1448 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1449 |
! |
|
1450 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1451 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1452 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1453 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1454 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1455 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1456 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1457 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1458 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1459 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1460 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1461 |
|
2822 | 1462 |
(cursorCol == newCol) ifTrue:[^ self]. |
1463 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1464 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1465 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1466 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1467 |
|
1468 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1469 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1470 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1471 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1472 |
"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
|
1473 |
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
|
1474 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1475 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1476 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1477 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1478 |
|
2707 | 1479 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1480 |
cursorLine > list size ifTrue:[ |
4595 | 1481 |
wasOn := self hideCursor. |
1482 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1483 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1484 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1485 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1486 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1487 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1488 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1489 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1490 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1491 |
"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
|
1492 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1493 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1494 |
|
4595 | 1495 |
(nL := cursorLine) isNil ifTrue:[ |
1496 |
nL := firstLineShown |
|
1497 |
]. |
|
1498 |
||
1499 |
self st80EditMode ifTrue:[ |
|
1500 |
nL == list size ifTrue:[ |
|
1501 |
wasOn := self hideCursor. |
|
1502 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1503 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1504 |
self beep. |
|
1505 |
^ self. |
|
1506 |
] |
|
1507 |
]. |
|
1508 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1509 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1510 |
wasOn := self hideCursor. |
1511 |
nv := cursorVisibleLine + n - 1. |
|
1512 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1513 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1514 |
]. |
|
1515 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1516 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1517 |
] ifFalse:[ |
4595 | 1518 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1519 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1520 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1521 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1522 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1523 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1524 |
|
121 | 1525 |
cursorHome |
597 | 1526 |
"scroll to top AND move cursor to first line of text." |
121 | 1527 |
|
674 | 1528 |
self cursorLine:1 col:1 |
1529 |
||
1530 |
"/ |wasOn| |
|
1531 |
"/ |
|
1532 |
"/ wasOn := self hideCursor. |
|
1533 |
"/ self scrollToTop. |
|
1534 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1535 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1536 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1537 |
||
1538 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1539 |
! |
1540 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1541 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1542 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1543 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1544 |
(cursorCol ~~ 1) ifTrue:[ |
3160 | 1545 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1546 |
] ifFalse:[ |
3160 | 1547 |
cursorLine ~~ 1 ifTrue:[ |
1548 |
self st80EditMode ifTrue:[ |
|
1549 |
self cursorUp. |
|
1550 |
self cursorToEndOfLine. |
|
1551 |
] |
|
1552 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1553 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1554 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1555 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1556 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1557 |
|
4126 | 1558 |
cursorLeft:n |
1559 |
"move cursor to left" |
|
1560 |
||
1561 |
n timesRepeat:[ |
|
1562 |
self cursorLeft |
|
1563 |
]. |
|
1564 |
! |
|
1565 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1566 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1567 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1568 |
|
676 | 1569 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1570 |
|
2822 | 1571 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1572 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1573 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1574 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1575 |
|
672 | 1576 |
(col < 1) ifTrue:[ |
3160 | 1577 |
newCol := 1 |
672 | 1578 |
] ifFalse:[ |
3160 | 1579 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1580 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1581 |
self st80EditMode ifTrue:[ |
3160 | 1582 |
(cursorLine == list size |
1583 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1584 |
newCol := (self listAt:(list size)) size + 1. |
|
1585 |
] |
|
1419 | 1586 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1587 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1588 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1589 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1590 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1591 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1592 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1593 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1594 |
"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
|
1595 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1596 |
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
|
1597 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1598 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1599 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1600 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1601 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1602 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1603 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1604 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1605 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1606 |
"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
|
1607 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1608 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1610 |
self checkForExistingLine:(cursorLine + 1). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1611 |
cursorVisibleLine notNil ifTrue:[ |
3160 | 1612 |
nFullLinesShown notNil ifTrue:[ |
1613 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1614 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1615 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1616 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1617 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1618 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1620 |
|
674 | 1621 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1622 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1624 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1625 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1626 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1627 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1628 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1629 |
self st80EditMode ifTrue:[ |
3160 | 1630 |
l := (self listAt:cursorLine). |
1631 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1632 |
cursorLine < list size ifTrue:[ |
|
1633 |
self cursorReturn. |
|
1634 |
]. |
|
1635 |
^ self |
|
1636 |
] |
|
1637 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1638 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1639 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1640 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1641 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1642 |
|
4126 | 1643 |
cursorRight:n |
1644 |
"move cursor to right" |
|
1645 |
||
1646 |
n timesRepeat:[ |
|
1647 |
self cursorRight |
|
1648 |
]. |
|
1649 |
! |
|
1650 |
||
1833 | 1651 |
cursorShown:aBoolean |
1652 |
"change cursor visibility |
|
1653 |
return true if cursor was visible before." |
|
1654 |
||
1655 |
|oldState| |
|
1656 |
||
4494 | 1657 |
aBoolean == cursorShown ifTrue:[ |
1658 |
^ cursorShown |
|
1659 |
]. |
|
1660 |
||
1833 | 1661 |
oldState := cursorShown. |
1662 |
||
1663 |
aBoolean ifTrue:[ |
|
4494 | 1664 |
self drawCursor. |
1833 | 1665 |
] ifFalse:[ |
4494 | 1666 |
(cursorShown and:[shown]) ifTrue: [ |
1667 |
self undrawCursor. |
|
1668 |
]. |
|
1833 | 1669 |
]. |
1670 |
cursorShown := aBoolean. |
|
1671 |
||
1672 |
^ oldState |
|
1673 |
||
1674 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1675 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1676 |
! |
|
1677 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1678 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1679 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1680 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1681 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1682 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1683 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1684 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1685 |
"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
|
1686 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1687 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1688 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1689 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1690 |
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
|
1691 |
cursorCol > textStart ifTrue:[ |
3160 | 1692 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1693 |
] ifFalse:[ |
3160 | 1694 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1695 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1696 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1697 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1698 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1699 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1700 |
cursorToBeginOfSelection |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1701 |
"Move cursor to the beginning of current selection. noop if |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1702 |
there's no selection." |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1703 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1704 |
self hasSelection ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1705 |
self cursorLine: selectionStartLine col: selectionStartCol |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1706 |
] |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1707 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1708 |
"Created: / 29-08-2013 / 23:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1709 |
! |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1710 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1711 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1712 |
"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
|
1713 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1714 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1715 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1716 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1717 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1718 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1719 |
(newTop < 1) ifTrue:[ |
3160 | 1720 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1721 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1722 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1723 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1724 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1725 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1726 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1727 |
|
674 | 1728 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1729 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1730 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1731 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1732 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1733 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1734 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1735 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1736 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1737 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1738 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1739 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1740 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1741 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1742 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1743 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1744 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1745 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1746 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1747 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1748 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1749 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1750 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1751 |
cursorLine >= lineNr ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1752 |
line := self listAt:cursorLine. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1753 |
(line isEmptyOrNil) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1754 |
^ self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1755 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1756 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1757 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1758 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1759 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1760 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1761 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1762 |
(newTop < 1) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1763 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1764 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1765 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1766 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1767 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1768 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1770 |
|
674 | 1771 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1772 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1773 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1774 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1775 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1776 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1777 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1778 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1779 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1780 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1781 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1782 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1783 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1784 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1785 |
cursorToEndOfSelection |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1786 |
"Move cursor to the end of current selection. noop if |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1787 |
there's no selection." |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1788 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1789 |
self hasSelection ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1790 |
self cursorLine: selectionEndLine col: selectionEndCol + 1 |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1791 |
] |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1792 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1793 |
"Created: / 29-08-2013 / 23:16:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1794 |
! |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
1795 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1796 |
cursorToEndOfText |
4288 | 1797 |
"move cursor to the end of the text (behind the last character in last line)" |
1798 |
||
1799 |
|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
|
1800 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1801 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1802 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1803 |
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
|
1804 |
(newTop < 1) ifTrue:[ |
4288 | 1805 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1806 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1807 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1808 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1809 |
self setValidatedCursorLine:list size. |
4288 | 1810 |
lastLineLength := (self listAt:cursorLine) size. |
1811 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
1812 |
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
|
1813 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1814 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 1815 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
1816 |
"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
|
1817 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1818 |
|
3310 | 1819 |
cursorToEndOfWord |
1820 |
"move the cursor to the end of the word" |
|
1821 |
||
1822 |
(cursorLine > list size) ifTrue:[^ self]. |
|
1823 |
||
1824 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1825 |
:beginLine :beginCol :endLine :endCol :style | |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1826 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1827 |
self cursorLine:endLine col:endCol+1 |
3310 | 1828 |
] |
1829 |
||
1830 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
1831 |
! |
|
1832 |
||
131 | 1833 |
cursorToFirstVisibleLine |
1834 |
"place cursor into the first visible line; do not scroll." |
|
1835 |
||
1836 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1837 |
! |
|
1838 |
||
1839 |
cursorToLastVisibleLine |
|
1840 |
"place cursor into the first visible line; do not scroll." |
|
1841 |
||
1842 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1843 |
! |
|
1844 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1846 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1847 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1848 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1849 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1850 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1851 |
|
3890 | 1852 |
self |
1853 |
wordAtLine:cursorLine col:cursorCol do:[ |
|
1854 |
:beginLine :beginCol :endLine :endCol :style | |
|
1855 |
||
1856 |
line := endLine. |
|
1857 |
col := endCol + 1. |
|
1858 |
searching := true. |
|
1859 |
[searching |
|
1860 |
and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
1861 |
self wordAtLine:line col:col do:[ |
|
1862 |
:beginLine :beginCol :endLine :endCol :style | |
|
1863 |
||
1864 |
(line > list size) ifTrue:[ |
|
1865 |
"break out" |
|
1866 |
searching := false |
|
1867 |
] ifFalse:[ |
|
1868 |
line := endLine. |
|
1869 |
col := endCol + 1. |
|
1870 |
] |
|
1871 |
] |
|
1872 |
]. |
|
1873 |
self cursorLine:line col:col |
|
1874 |
] |
|
121 | 1875 |
! |
1876 |
||
499 | 1877 |
cursorToPreviousWord |
1878 |
"move the cursor to the beginning of this or the previous word" |
|
1879 |
||
1880 |
|col line searching l| |
|
1881 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1882 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 1883 |
|
1884 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
3160 | 1885 |
:beginLine :beginCol :endLine :endCol :style | |
1886 |
||
1887 |
line := beginLine. |
|
1888 |
col := beginCol. |
|
1889 |
style == #wordLeft ifTrue:[ |
|
1890 |
col := col + 1 |
|
1891 |
]. |
|
1892 |
||
1893 |
(cursorLine == line |
|
1894 |
and:[cursorCol == col]) ifTrue:[ |
|
1895 |
searching := true. |
|
1896 |
||
1897 |
col > 1 ifTrue:[ |
|
1898 |
col := col - 1. |
|
1899 |
]. |
|
1900 |
||
1901 |
[searching] whileTrue:[ |
|
1902 |
(col == 1) ifTrue:[ |
|
1903 |
line == 1 ifTrue:[ |
|
1904 |
searching := false |
|
1905 |
] ifFalse:[ |
|
1906 |
line := line - 1. |
|
1907 |
l := list at:line. |
|
1908 |
col := l size + 1. |
|
1909 |
] |
|
1910 |
] ifFalse:[ |
|
1911 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
1912 |
self wordAtLine:line col:col do:[ |
|
1913 |
:beginLine :beginCol :endLine :endCol :style | |
|
1914 |
||
1915 |
line := beginLine. |
|
1916 |
col := beginCol. |
|
1917 |
style == #wordLeft ifTrue:[ |
|
1918 |
col := col + 1 |
|
1919 |
]. |
|
1920 |
searching := false. |
|
1921 |
] |
|
1922 |
] ifTrue:[ |
|
1923 |
col := col - 1 |
|
1924 |
] |
|
1925 |
] |
|
1926 |
] |
|
1927 |
]. |
|
1928 |
self cursorLine:line col:col |
|
499 | 1929 |
] |
1930 |
||
1931 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
1932 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
1933 |
! |
|
1934 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1935 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1936 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1937 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1938 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1939 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1940 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1941 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1942 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1944 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1945 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1946 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1947 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1948 |
"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
|
1949 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1950 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1952 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1953 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1954 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1955 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1956 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1957 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1958 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1959 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1960 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1961 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1962 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1963 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1964 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1965 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1966 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1967 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
1968 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1969 |
] |
672 | 1970 |
|
674 | 1971 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1972 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1973 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1974 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1975 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1976 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1977 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1979 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1980 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1981 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1982 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1984 |
|
676 | 1985 |
newCol := colNr. |
1986 |
(newCol < 1) ifTrue:[ |
|
3160 | 1987 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1988 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1989 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1990 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1992 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
1993 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1996 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1997 |
"put cursor to position next to x/y coordinate in view" |
121 | 1998 |
|
1999 |
|line col| |
|
2000 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2001 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2002 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2003 |
self cursorVisibleLine:line col:col. |
121 | 2004 |
! |
2005 |
||
2006 |
drawCursor |
|
2007 |
"draw the cursor if shown and cursor is visible. |
|
2008 |
(but not, if there is a selection - to avoid confusion)" |
|
2009 |
||
2010 |
shown ifTrue:[ |
|
3160 | 2011 |
cursorVisibleLine notNil ifTrue:[ |
2012 |
self hasSelection ifFalse:[ |
|
2013 |
self drawCursorCharacter |
|
2014 |
] |
|
2015 |
] |
|
121 | 2016 |
] |
2017 |
! |
|
2018 |
||
2019 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2020 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2021 |
of cursor should be drawn. |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2022 |
Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret |
4580 | 2023 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2024 |
|
2570 | 2025 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2026 |
|
2027 |
self hasSelection ifTrue:[ |
|
4580 | 2028 |
" |
2029 |
hide cursor, if there is a selection |
|
2030 |
" |
|
2031 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2032 |
]. |
2033 |
||
1334 | 2034 |
cursorType == #none ifTrue:[ |
4580 | 2035 |
^ self |
1334 | 2036 |
]. |
2037 |
||
121 | 2038 |
cursorType == #block ifTrue:[ |
4580 | 2039 |
super drawVisibleLine:cursorVisibleLine |
2040 |
col:cursorCol |
|
2041 |
with:fgColor |
|
2042 |
and:bgColor. |
|
2043 |
^ self |
|
121 | 2044 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2045 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2046 |
y := self yOfVisibleLine:cursorVisibleLine. |
2047 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2048 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2049 |
cursorType == #frame ifTrue:[ |
4580 | 2050 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2051 |
||
2052 |
char := self characterUnderCursor asString. |
|
2053 |
self paint:bgColor. |
|
2054 |
self displayRectangleX:x y:y |
|
2055 |
width:(font widthOf:char) height:fontHeight. |
|
133 | 2056 |
] ifFalse:[ |
4580 | 2057 |
self paint:bgColor. |
2058 |
cursorType == #ibeam ifTrue:[ |
|
2059 |
x1 := x - 1. |
|
2060 |
y2 := y + fontHeight - lineSpacing. |
|
2061 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2062 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2063 |
^ self |
|
2064 |
]. |
|
2065 |
||
2066 |
cursorType == #Ibeam ifTrue:[ |
|
2067 |
x1 := x - 1. |
|
2068 |
y := y + 1. |
|
2069 |
y2 := y + fontHeight - lineSpacing. |
|
2070 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2071 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2072 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2073 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2074 |
^ self |
|
2075 |
]. |
|
2076 |
||
2077 |
y := y + fontHeight - 3. |
|
2078 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2079 |
w := (fontWidth * 2 // 3) max:4. |
|
2080 |
y2 := y + w + (w//2). |
|
2081 |
] ifFalse:[ |
|
2082 |
w := (fontWidth // 2) max:4. |
|
2083 |
y2 := y + w. |
|
2084 |
]. |
|
2085 |
x1 := x - w. |
|
2086 |
x2 := x + w. |
|
2087 |
||
2088 |
oldClip := self clippingRectangleOrNil. |
|
2089 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2090 |
||
2091 |
cursorType == #caret ifTrue:[ |
|
2092 |
self lineWidth:2. |
|
2093 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2094 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2095 |
] ifFalse:[ |
|
2096 |
"anything else: solidCaret" |
|
2097 |
||
2098 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2099 |
with:(x @ y) |
|
2100 |
with:(x2 @ y2)) |
|
2101 |
]. |
|
2102 |
||
2103 |
self clippingRectangle:oldClip |
|
121 | 2104 |
]. |
133 | 2105 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2106 |
|
2088 | 2107 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2108 |
! |
2109 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
drawCursorCharacter |
3160 | 2111 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2112 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
|
3160 | 2115 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2116 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2117 |
and:[self isReadOnly not]]) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
2118 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
] ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
2120 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2121 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2122 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2123 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2124 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2125 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2126 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2127 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2128 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2129 |
self hasSelection ifTrue:[ |
3160 | 2130 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 2131 |
]. |
2132 |
cursorType == #none ifTrue:[ |
|
3160 | 2133 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2134 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2135 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2136 |
|
2137 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
drawNoFocusCursor |
3160 | 2141 |
"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
|
2142 |
|
1334 | 2143 |
|cType| |
2144 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2145 |
self hasSelection ifTrue:[ |
3160 | 2146 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2147 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2148 |
|
1334 | 2149 |
cType := cursorTypeNoFocus ? cursorType. |
2150 |
cType == #none ifTrue:[ |
|
3160 | 2151 |
^ self undrawCursor |
1334 | 2152 |
]. |
2153 |
||
2154 |
cType == #block ifTrue:[ |
|
3160 | 2155 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2156 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2157 |
|
1334 | 2158 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2159 |
||
2160 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2161 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2162 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2163 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2164 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2165 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2166 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2167 |
self makeLineVisible:aLineNumber. |
2951 | 2168 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2169 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2170 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2171 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2172 |
hideCursor |
1833 | 2173 |
"make cursor invisible if currently invisible" |
2174 |
||
2175 |
^ self cursorShown:false |
|
2176 |
||
2177 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2178 |
! |
2179 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2180 |
makeCursorVisible |
3160 | 2181 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2182 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2183 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2184 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2185 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2186 |
cursorLine notNil ifTrue:[ |
3160 | 2187 |
line := cursorLine. |
2188 |
col := cursorCol. |
|
2189 |
" |
|
2190 |
if there is a selection, its better to |
|
2191 |
have its start being visible, instead of the end |
|
2192 |
" |
|
2193 |
(selectionStartLine notNil |
|
2194 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2195 |
expandingTop ~~ false ifTrue:[ |
|
2196 |
line := selectionStartLine. |
|
2197 |
col := selectionStartCol. |
|
2198 |
] ifFalse:[ |
|
2199 |
line := selectionEndLine. |
|
2200 |
col := selectionEndCol |
|
2201 |
] |
|
2202 |
]. |
|
2203 |
self makeLineVisible:line. |
|
2204 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2205 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2206 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2207 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2208 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2209 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2210 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2212 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2213 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2214 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2215 |
flag ifTrue:[self showCursor] |
121 | 2216 |
! |
2217 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2218 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2219 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2220 |
|
2815 | 2221 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2222 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2223 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2224 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2225 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2226 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2227 |
|
3303 | 2228 |
"/ self assert:(lineNr notNil). |
2229 |
||
2230 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2231 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2232 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2233 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2234 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2235 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2236 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2237 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2238 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2239 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2240 |
! |
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 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2243 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2244 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2245 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2246 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2247 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2248 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2249 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2250 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2251 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2252 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2253 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2254 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2255 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2256 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2257 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2258 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2259 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2260 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2263 |
|
1833 | 2264 |
^ self cursorShown:true |
2265 |
||
2266 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2267 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2268 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2269 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2270 |
"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
|
2271 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2272 |
|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
|
2273 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2274 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2275 |
prevCol := cursorCol - 1. |
2276 |
||
2277 |
"/ if there is any italic stuff in the cursor line, |
|
2278 |
"/ redraw it completely (because characters overlap). |
|
2279 |
cursorCol > 1 ifTrue:[ |
|
2280 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2281 |
line hasChangeOfEmphasis ifTrue:[ |
|
2282 |
line size >= (cursorCol-1) ifTrue:[ |
|
2283 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2284 |
line size >= (cursorCol) ifTrue:[ |
|
2285 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2286 |
line size >= (cursorCol+1) ifTrue:[ |
|
2287 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2288 |
]. |
|
2289 |
]. |
|
2290 |
]. |
|
2291 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2292 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2293 |
] |
|
2294 |
] |
|
2295 |
] |
|
2296 |
]. |
|
2297 |
||
2298 |
((cursorType == #caret) |
|
2299 |
or:[cursorType == #solidCaret |
|
2300 |
or:[cursorType == #bigSolidCaret |
|
2301 |
or:[cursorType == #bigCaret |
|
2302 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2303 |
"caret-cursor touches 4 characters" |
|
2304 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2305 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2306 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2307 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2308 |
] ifFalse:[ |
|
2309 |
"care for left margin" |
|
2310 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2311 |
]. |
|
2312 |
^ self |
|
2313 |
]. |
|
2314 |
||
2315 |
cursorType == #ibeam ifTrue:[ |
|
2316 |
"ibeam-cursor touches 2 characters" |
|
2317 |
cursorCol > 1 ifTrue:[ |
|
2318 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2319 |
] ifFalse:[ |
|
2320 |
"care for left margin" |
|
2321 |
super redrawVisibleLine:cursorVisibleLine. |
|
2322 |
]. |
|
2323 |
^ self |
|
2324 |
]. |
|
2325 |
||
2326 |
"block cursor is simple - just one character under cursor" |
|
2327 |
||
2328 |
"/ however, if italic characters are involved, we must care |
|
2329 |
"/ for the chars before/after the cursor. |
|
2330 |
"/ We redraw the part of the previous character which got |
|
2331 |
"/ detroyed by the block cursor. |
|
2332 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2333 |
||
2334 |
line := self visibleAt:cursorVisibleLine. |
|
2335 |
(line notNil and:[line isText]) ifTrue:[ |
|
2336 |
cursorCol > 1 ifTrue:[ |
|
2337 |
oldClip := self clippingRectangleOrNil. |
|
2338 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2339 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2340 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
2341 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2342 |
self clippingRectangle:oldClip. |
|
2343 |
^ self. |
|
2344 |
]. |
|
2345 |
]. |
|
2346 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2347 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2348 |
|
2088 | 2349 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2350 |
! |
2351 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2352 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2353 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2354 |
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
|
2355 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2356 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2357 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2358 |
|
672 | 2359 |
validateCursorCol:col inLine:line |
674 | 2360 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2361 |
Here, no limits are enforced (and col is returned), |
2362 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2363 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2364 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2365 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2366 |
|
1419 | 2367 |
"/ in ST80 mode, |
2707 | 2368 |
"/ the cursor may not be positioned beyond the |
2369 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2370 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2371 |
self st80EditMode ifTrue:[ |
3160 | 2372 |
l := (self listAt:line). |
2373 |
max := l size + 1. |
|
2374 |
col > max ifTrue:[ |
|
2375 |
^ max |
|
2376 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2377 |
]. |
672 | 2378 |
^ col |
2379 |
||
1419 | 2380 |
"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
|
2381 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2382 |
! |
2383 |
||
2384 |
validateCursorLine:line |
|
2385 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2386 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2387 |
redefined in views which dont like the cursor to be positioned |
2388 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2389 |
skip reserved regions" |
|
2390 |
||
1419 | 2391 |
"/ |
2392 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2393 |
"/ beyond the last line |
1419 | 2394 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2395 |
self st80EditMode ifTrue:[ |
3160 | 2396 |
^ (line min:(list size)) max:1 |
1419 | 2397 |
]. |
674 | 2398 |
^ line |
2399 |
||
1419 | 2400 |
"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
|
2401 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2402 |
! |
2403 |
||
121 | 2404 |
withCursorOffDo:aBlock |
2405 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2406 |
||
2407 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
3160 | 2408 |
^ aBlock value |
121 | 2409 |
]. |
2410 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2411 |
aBlock ensure:[ |
3160 | 2412 |
self showCursor |
121 | 2413 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2414 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2415 |
|
2589 | 2416 |
!EditTextView methodsFor:'drag & drop'! |
2417 |
||
2418 |
allowDrop:aBoolean |
|
3236 | 2419 |
"enable/disable drop support" |
2420 |
||
2589 | 2421 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2422 |
dropTarget := nil. |
2589 | 2423 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2424 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2425 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2426 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2427 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2428 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2429 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2430 |
] |
3236 | 2431 |
]. |
2432 |
! |
|
2433 |
||
3412 | 2434 |
canDrop:aDropContext |
2435 |
"public from d&d. |
|
2436 |
I accept textObjects and fileObjects only." |
|
2437 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2438 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2439 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2440 |
^ self canDropObjects:aDropContext dropObjects |
|
2441 |
||
2442 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2443 |
! |
|
2444 |
||
2445 |
canDropObjects:aCollectionOfDropObjects |
|
2446 |
"public from d&d. |
|
2447 |
I accept textObjects and fileObjects only." |
|
2589 | 2448 |
|
2449 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2450 |
||
3412 | 2451 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2452 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2453 |
||
2454 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2455 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2456 |
! |
|
2457 |
||
2458 |
drop:aDropContext |
|
2459 |
"public from d&d. |
|
2460 |
drop objects (new API)" |
|
2461 |
||
2462 |
self dropObjects:(aDropContext dropObjects) |
|
2463 |
||
2464 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2465 |
! |
|
2466 |
||
2467 |
dropFileObject:aDropObject |
|
2589 | 2468 |
"drop objects |
3236 | 2469 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2470 |
||
4136 | 2471 |
|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
|
2472 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2473 |
pasteWhat := #name. |
3412 | 2474 |
|
2475 |
fn := aDropObject asFilename. |
|
2476 |
(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
|
2477 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2478 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2479 |
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
|
2480 |
pasteWhat := enforcedDropMode. |
3886 | 2481 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2482 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2483 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2484 |
pasteWhat := #name. |
3886 | 2485 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2486 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2487 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2488 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2489 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2490 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2491 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2492 |
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
|
2493 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2494 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2495 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2496 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2497 |
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
|
2498 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2499 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2500 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2501 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2502 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2503 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2504 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2505 |
] |
3886 | 2506 |
] |
2507 |
]. |
|
2508 |
]. |
|
2509 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2510 |
pasteWhat == #name ifTrue:[ |
3886 | 2511 |
text := fn pathName |
2512 |
] ifFalse:[ |
|
2513 |
self withWaitCursorDo:[ |
|
3799 | 2514 |
text := fn contentsOfEntireFile |
4136 | 2515 |
]. |
2516 |
(app := self application) notNil ifTrue:[ |
|
2517 |
app droppedFile:fn in:self |
|
2518 |
]. |
|
3886 | 2519 |
]. |
2520 |
||
3799 | 2521 |
self |
2522 |
undoablePaste:text |
|
2523 |
info:'Drop File'. |
|
3412 | 2524 |
|
2525 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2526 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2527 |
! |
2528 |
||
2529 |
dropObject:aDropObject |
|
2530 |
"drop objects |
|
2531 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2532 |
||
3415 | 2533 |
|text| |
2534 |
||
3412 | 2535 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2536 |
self dropFileObject:aDropObject |
3412 | 2537 |
] ifFalse:[ |
3799 | 2538 |
aDropObject isTextObject ifTrue:[ |
2539 |
text := aDropObject theObject. |
|
2540 |
text isStringCollection ifTrue:[ |
|
2541 |
text := text asStringWithoutFinalCR |
|
2542 |
]. |
|
2543 |
] ifFalse:[ |
|
2544 |
text := aDropObject theObject asString |
|
2545 |
]. |
|
2546 |
self |
|
2547 |
undoablePaste:text |
|
2548 |
info:'Drop'. |
|
3412 | 2549 |
]. |
2550 |
||
2551 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2552 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2553 |
! |
2554 |
||
2555 |
dropObjects:aCollectionOfDropObjects |
|
2556 |
"public from d&d. |
|
2557 |
drop objects (old API)" |
|
2558 |
||
3868 | 2559 |
aCollectionOfDropObjects do:[:el | |
2560 |
self dropObject:el |
|
3412 | 2561 |
]. |
2562 |
||
2563 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2564 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2565 |
! ! |
2566 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2567 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2568 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2569 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2570 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2571 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2572 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2573 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2574 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2575 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2576 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2577 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2578 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2579 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2580 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2581 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2582 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2583 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2584 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2585 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2586 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2587 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2588 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2589 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2590 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2591 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2592 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2593 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2594 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2595 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2596 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2597 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2598 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2599 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2600 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2601 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2602 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2603 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2604 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2605 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2606 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2607 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2608 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2609 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2610 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2611 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2612 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2613 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2614 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2615 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2616 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2617 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2618 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2619 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2620 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2621 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2622 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2623 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2624 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2625 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2626 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2627 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2628 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2629 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2630 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2631 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2632 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2633 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2634 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2635 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2636 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2637 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2638 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2639 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2640 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2641 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2642 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2643 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2644 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2645 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2646 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2647 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2648 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2649 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2650 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2651 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2652 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2653 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2654 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2655 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2656 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2657 |
line at:col put:ch. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2658 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2659 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2660 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2661 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2662 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2663 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2664 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2665 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2666 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2667 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2668 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2669 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2670 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2671 |
"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
|
2672 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2673 |
selectionStartLine notNil ifTrue:[ |
3160 | 2674 |
self setClipboardText:(self selection). |
2675 |
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
|
2676 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2677 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2678 |
"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
|
2679 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2680 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2681 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2682 |
"delete single character under cursor; does not merge lines" |
121 | 2683 |
|
2684 |
|wasOn| |
|
2685 |
||
2686 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2687 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2688 |
wasOn ifTrue:[self showCursor] |
2689 |
! |
|
2690 |
||
827 | 2691 |
deleteCharAtLine:lineNr col:colNr |
2692 |
"delete a single character at colNr in line lineNr" |
|
2693 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2694 |
self st80EditMode ifTrue:[ |
3160 | 2695 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2696 |
| wasOn | |
|
2697 |
wasOn := self hideCursor. |
|
2698 |
self |
|
2699 |
cursorReturn; |
|
2700 |
cursorCol:1; |
|
2701 |
deleteCharBeforeCursor. |
|
2702 |
wasOn ifTrue:[ self showCursor]. |
|
2703 |
^ self. |
|
2704 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2705 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2706 |
|
827 | 2707 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2708 |
! |
|
2709 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2710 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2711 |
"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
|
2712 |
|
4592 | 2713 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2714 |
|
2715 |
wasOn := self hideCursor. |
|
4592 | 2716 |
(autoIndent |
2717 |
and:[ (tabPositions includes:cursorCol) |
|
2718 |
]) ifTrue:[ |
|
2719 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
|
2720 |
ln := originalLine := (list at:cursorLine) ? ''. |
|
2721 |
ln size < prevTab ifTrue:[ |
|
2722 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2723 |
]. |
|
2724 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2725 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2726 |
cursorCol > prevTab ifTrue:[ |
|
2727 |
self st80EditMode ifTrue:[ |
|
2728 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2729 |
"/ not allow a cursor position beyond the end of line, |
|
2730 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2731 |
originalLine size < prevTab ifTrue:[ |
|
2732 |
list at:cursorLine put:ln |
|
2733 |
] |
|
2734 |
]. |
|
2735 |
self cursorLine:cursorLine col:prevTab. |
|
2736 |
wasOn ifTrue:[ self showCursor ]. |
|
2737 |
^ self |
|
2738 |
]. |
|
2739 |
] ifFalse:[ |
|
2740 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2741 |
self cursorLine:cursorLine col:prevTab. |
|
2742 |
wasOn ifTrue:[ self showCursor ]. |
|
2743 |
^ self. |
|
2744 |
] |
|
2745 |
]. |
|
827 | 2746 |
]. |
2747 |
||
2491 | 2748 |
"/ (autoIndent |
2749 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2750 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2751 |
"/ ifTrue:[ |
2752 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2753 |
"/ |
|
2754 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2755 |
"/ ln := list at:cursorLine. |
|
2756 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2757 |
"/ soCol := 1 |
|
2758 |
"/ ] |
|
2759 |
"/ ] |
|
2760 |
"/ ] ifFalse:[ |
|
4592 | 2761 |
soCol := 1. |
2491 | 2762 |
"/ ]. |
2763 |
||
1419 | 2764 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2765 |
" |
2766 |
somewhere in the middle of a line |
|
2767 |
" |
|
2768 |
self cursorLeft. |
|
2769 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2770 |
] ifFalse:[ |
4592 | 2771 |
" |
2772 |
at begin of line - merge with previous line; |
|
2773 |
except for the very first line. |
|
2774 |
" |
|
2775 |
(cursorLine == 1) ifFalse:[ |
|
2776 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2777 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2778 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2779 |
"/ we are beyond the end of the text. |
|
2780 |
"/ move the cursor to the previous line. |
|
2781 |
self cursorLine:lineNrAboveCursor col:1. |
|
2782 |
] ifFalse:[ |
|
2783 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2784 |
] |
|
2785 |
] |
|
2786 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2787 |
]. |
827 | 2788 |
wasOn ifTrue:[ self showCursor ] |
2789 |
||
1419 | 2790 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2791 |
! |
2792 |
||
2793 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2794 |
"delete characters from colNr up to the end in line lineNr" |
|
2795 |
||
2796 |
|line| |
|
2797 |
||
2798 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
3160 | 2799 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2800 |
] |
2801 |
||
2802 |
! |
|
2803 |
||
4458 | 2804 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2805 |
"delete characters from startCol to endCol in line lineNr" |
|
2806 |
||
2807 |
|deleted| |
|
2808 |
||
2809 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
2810 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
2811 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
2812 |
! |
|
2813 |
||
827 | 2814 |
deleteCharsAtLine:lineNr toCol:colNr |
2815 |
"delete characters from start up to colNr in line lineNr" |
|
2816 |
||
2817 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2818 |
||
2819 |
||
121 | 2820 |
! |
2821 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2822 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2823 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2824 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2825 |
self deleteLine:cursorLine |
121 | 2826 |
! |
2827 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2828 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2829 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2830 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2831 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2832 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2833 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2834 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2835 |
col1 == 0 ifTrue:[ |
3160 | 2836 |
line1 := line1 - 1. |
2837 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2838 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2839 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2840 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2841 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2842 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2843 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2844 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2845 |
|
2954 | 2846 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2847 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2848 |
joining lines if nescessary" |
|
2849 |
||
2850 |
|line newLine lineSize nMore| |
|
2851 |
||
2852 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2853 |
list isNil ifTrue:[^ self]. |
|
2854 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2855 |
||
2856 |
(startLine == endLine) ifTrue:[ |
|
4225 | 2857 |
"/ delete chars within a line |
2858 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2859 |
^ self |
|
2954 | 2860 |
]. |
2861 |
||
2862 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 2863 |
"/ delete full lines only |
2864 |
endLine > startLine ifTrue:[ |
|
2865 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2866 |
]. |
|
2867 |
^ self |
|
2954 | 2868 |
]. |
2869 |
||
2870 |
"/ delete right rest of 1st line |
|
2871 |
self deleteCharsAtLine:startLine fromCol:startCol. |
|
2872 |
||
2873 |
"/ delete the inner lines ... |
|
2874 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 2875 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 2876 |
]. |
2877 |
||
2878 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 2879 |
"/ delete the left rest of the last line |
2880 |
||
2881 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
2882 |
||
2883 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
2884 |
startLine <= list size ifTrue:[ |
|
2885 |
line := list at:startLine. |
|
2886 |
lineSize := line size. |
|
2887 |
(startCol > lineSize) ifTrue:[ |
|
2888 |
newLine := line. |
|
2889 |
line isNil ifTrue:[ |
|
2890 |
newLine := String new:(startCol - 1) |
|
2891 |
] ifFalse:[ |
|
2892 |
nMore := startCol - 1 - lineSize. |
|
2893 |
nMore > 0 ifTrue:[ |
|
2894 |
newLine := line , (line species new:nMore) |
|
2895 |
] |
|
2896 |
]. |
|
2897 |
newLine ~~ line ifTrue:[ |
|
2898 |
list at:startLine put:newLine. |
|
2899 |
]. |
|
2900 |
"/ TODO: remember old maxwidth of linerange, |
|
2901 |
"/ only clear widthOfWidestLine, if this max |
|
2902 |
"/ length was (one of) the longest. |
|
2903 |
"/ avoids slow delete with huge texts. |
|
2904 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2905 |
self textChanged. |
|
2906 |
] |
|
2907 |
] |
|
2954 | 2908 |
]. |
2909 |
||
2910 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
2911 |
self mergeLine:startLine removeBlanks:false |
|
2912 |
||
4225 | 2913 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
2914 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 2915 |
! |
2916 |
||
4458 | 2917 |
deleteFromLine:startLineNr toLine:endLineNr |
2918 |
"delete some lines" |
|
2919 |
||
2920 |
|deleted| |
|
2921 |
||
2922 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
2923 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
2924 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
2925 |
! |
|
2926 |
||
827 | 2927 |
deleteLine:lineNr |
2928 |
"delete line" |
|
2929 |
||
2930 |
self deleteFromLine:lineNr toLine:lineNr |
|
2931 |
||
2932 |
||
2933 |
! |
|
2934 |
||
4458 | 2935 |
deleteLineWithoutRedraw:lineNr |
2936 |
"delete line - no redraw; |
|
2937 |
return true, if something was really deleted" |
|
2938 |
||
2939 |
|deleted ret| |
|
2940 |
||
2941 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
2942 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
2943 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
2944 |
^ ret. |
|
2945 |
! |
|
2946 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2947 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2948 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2949 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2950 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2951 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2952 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2953 |
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
|
2954 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2955 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2956 |
(endLine > list size) ifTrue:[ |
3160 | 2957 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2958 |
] ifFalse:[ |
3160 | 2959 |
lastLine := endLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2960 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2961 |
list removeFromIndex:startLine toIndex:lastLine. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2962 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2963 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2964 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2965 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2966 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2967 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2968 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2969 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
2970 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2971 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2972 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2973 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2974 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2976 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2977 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
2978 |
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
|
2979 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2980 |
selectionStartLine notNil ifTrue:[ |
3160 | 2981 |
wasOn := self hideCursor. |
2982 |
||
2983 |
startLine := selectionStartLine. |
|
2984 |
startCol := selectionStartCol. |
|
2985 |
endLine := selectionEndLine. |
|
2986 |
endCol := selectionEndCol. |
|
2987 |
self unselectWithoutRedraw. |
|
2988 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
2989 |
self setCursorLine:startLine col:startCol. |
|
2990 |
||
2991 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2992 |
] |
121 | 2993 |
! |
2994 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2995 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2996 |
"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
|
2997 |
|
2952 | 2998 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2999 |
|
3799 | 3000 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3001 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3002 |
wasOn := self hideCursor. |
3799 | 3003 |
self |
3004 |
undoableDo:[ |
|
3005 |
endCol := cursorCol-1. |
|
3006 |
endLine := cursorLine. |
|
3007 |
self cursorToPreviousWord. |
|
3008 |
beginCol := cursorCol. |
|
3009 |
beginLine := cursorLine. |
|
3010 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3011 |
] |
|
3012 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3013 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3014 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3015 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3016 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3017 |
|
4458 | 3018 |
insert:aCharacter atLine:lineNr col:colNr |
3019 |
"insert a single character at lineNr/colNr; |
|
3020 |
set emphasis to character at current position" |
|
3021 |
||
3022 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3023 |
aCharacter ~~ Character cr ifTrue:[ |
|
3024 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
|
3025 |
] |
|
3026 |
! |
|
3027 |
||
121 | 3028 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3029 |
"insert a single character at cursor-position - advance cursor." |
121 | 3030 |
|
3031 |
|wasOn| |
|
3032 |
||
3033 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3034 |
aCharacter == Character tab ifTrue:[ |
3160 | 3035 |
"/ needs special care to advance cursor correctly |
3036 |
self insertTabAtCursor |
|
121 | 3037 |
] ifFalse:[ |
3160 | 3038 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3039 |
aCharacter == (Character cr) ifTrue:[ |
|
3040 |
self cursorReturn |
|
3041 |
] ifFalse:[ |
|
3042 |
self cursorRight. |
|
3043 |
]. |
|
121 | 3044 |
]. |
3045 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3046 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3047 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3048 |
! |
3049 |
||
641 | 3050 |
insertLine:aString before:lineNr |
3051 |
"insert the line aString before line lineNr" |
|
3052 |
||
3053 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3054 |
||
3055 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3056 |
! |
|
3057 |
||
155 | 3058 |
insertLines:aStringCollection before:lineNr |
3059 |
"insert a bunch before line lineNr" |
|
3060 |
||
3061 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3062 |
||
3063 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3064 |
! |
|
3065 |
||
654 | 3066 |
insertLines:lines withCR:withCr |
3160 | 3067 |
"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
|
3068 |
Cursor is moved behind insertion. |
641 | 3069 |
If withCr is true, append cr after last line" |
3070 |
||
3071 |
|start end nLines wasOn| |
|
3072 |
||
3073 |
lines notNil ifTrue:[ |
|
4649 | 3074 |
nLines := lines size. |
3075 |
(nLines == 1) ifTrue:[ |
|
3076 |
self insertStringAtCursor:(lines at:1). |
|
3077 |
withCr ifTrue:[ |
|
3078 |
self insertCharAtCursor:(Character cr) |
|
3079 |
] |
|
3080 |
] ifFalse:[ |
|
3081 |
(cursorCol ~~ 1) ifTrue:[ |
|
3082 |
self insertStringAtCursor:(lines at:1). |
|
3083 |
self insertCharAtCursor:(Character cr). |
|
3084 |
start := 2 |
|
3085 |
] ifFalse:[ |
|
3086 |
start := 1 |
|
3087 |
]. |
|
3088 |
withCr ifTrue:[ |
|
3089 |
end := nLines |
|
3090 |
] ifFalse:[ |
|
3091 |
end := nLines - 1 |
|
3092 |
]. |
|
3093 |
(start <= nLines) ifTrue:[ |
|
3094 |
(end >= start) ifTrue:[ |
|
3095 |
wasOn := self hideCursor. |
|
3096 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3097 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3098 |
wasOn ifTrue:[self showCursor]. |
|
3099 |
] |
|
3100 |
]. |
|
3101 |
withCr ifFalse:[ |
|
3102 |
"last line without cr" |
|
3103 |
self insertStringAtCursor:(lines at:nLines) |
|
3104 |
] |
|
3105 |
] |
|
641 | 3106 |
] |
654 | 3107 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3108 |
"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
|
3109 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3110 |
! |
3111 |
||
3112 |
insertLines:lines withCr:withCr |
|
3113 |
"insert a bunch of lines at cursor position. Cursor |
|
3114 |
is moved behind insertion. |
|
3115 |
If withCr is true, append cr after last line" |
|
3116 |
||
2363 | 3117 |
<resource:#obsolete> |
3118 |
||
1292 | 3119 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3120 |
self insertLines:lines withCR:withCr. |
|
3121 |
||
3122 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3123 |
! |
3124 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3125 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3126 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3127 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3128 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3130 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3131 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3132 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3133 |
self selectFromLine:startLine col:startCol |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3134 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3135 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3136 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3137 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3138 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3139 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3140 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3141 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3142 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3143 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3144 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3145 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3146 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3147 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3148 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3149 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3150 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3151 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3152 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3153 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3154 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3155 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3156 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3157 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3158 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3159 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 3160 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3161 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3162 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3163 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3164 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3165 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3166 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3167 |
[start <= end] whileTrue:[ |
3160 | 3168 |
stop := aString indexOf:(Character cr) startingAt:start. |
3169 |
stop == 0 ifTrue:[ |
|
3170 |
stop := end + 1 |
|
3171 |
]. |
|
3172 |
subString := aString copyFrom:start to:(stop - 1). |
|
3173 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3174 |
(stop <= end) ifTrue:[ |
|
3175 |
c := c + subString size. |
|
3176 |
self insert:(Character cr) atLine:l col:c. |
|
3177 |
l := l + 1. |
|
3178 |
c := 1 |
|
3179 |
]. |
|
3180 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3181 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3182 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3183 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3184 |
! |
3185 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3186 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3187 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3188 |
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
|
3189 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3190 |
aString isNil ifTrue:[ |
3160 | 3191 |
"new:" |
3192 |
self insertCharAtCursor:(Character cr). |
|
3193 |
^ self |
|
105 | 3194 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3195 |
(aString includes:(Character cr)) ifFalse:[ |
3160 | 3196 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3197 |
]. |
3198 |
||
654 | 3199 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3200 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3201 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3202 |
! |
3203 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3204 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3205 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3206 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3207 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3208 |
shown ifTrue:[ |
3209 |
font hasOverlappingCharacters ifTrue:[ |
|
3210 |
self invalidateLine:lineNr. |
|
3211 |
] ifFalse:[ |
|
3212 |
self redrawLine:lineNr from:colNr |
|
3213 |
] |
|
3214 |
] |
|
3215 |
||
4191 | 3216 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3217 |
! |
3218 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3219 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3220 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3221 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3222 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3223 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3224 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3225 |
aString size > 0 ifTrue:[ |
3160 | 3226 |
wasOn := self hideCursor. |
3227 |
(aString includes:Character tab) ifTrue:[ |
|
3228 |
self checkForExistingLine:cursorLine. |
|
3229 |
oldLen := (list at:cursorLine) size. |
|
3230 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3231 |
newLen := (list at:cursorLine) size. |
|
3232 |
deltaLen := newLen - oldLen. |
|
3233 |
] ifFalse:[ |
|
3234 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3235 |
deltaLen := aString size. |
|
3236 |
]. |
|
3237 |
self setCursorCol:(cursorCol + deltaLen). |
|
3238 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3239 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3240 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3241 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3242 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3243 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3244 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3245 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3246 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3247 |
|wasOn nextTab| |
105 | 3248 |
|
121 | 3249 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3250 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3251 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3252 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3253 |
! |
3254 |
||
3542 | 3255 |
joinLines |
3890 | 3256 |
"join lines (remove line-break)" |
3257 |
||
3583 | 3258 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3259 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3260 |
self |
3890 | 3261 |
undoableDo:[ |
3262 |
|line col lineLen| |
|
3263 |
||
3264 |
line := cursorLine. |
|
3265 |
col := cursorCol. |
|
3266 |
lineLen := (list at:line) size. |
|
3267 |
col > lineLen ifTrue:[ |
|
3268 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3269 |
] ifFalse:[ |
|
3270 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3271 |
]. |
|
3272 |
self mergeLine:line removeBlanks:true. |
|
3273 |
self cursorLine:line col:col. |
|
3274 |
] |
|
3275 |
info:'Join' |
|
3542 | 3276 |
! |
3277 |
||
2952 | 3278 |
mergeLine:lineNr |
3279 |
"merge line lineNr with line lineNr+1" |
|
3280 |
||
3281 |
self mergeLine:lineNr removeBlanks:true |
|
3282 |
||
3283 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3284 |
! |
|
3285 |
||
4458 | 3286 |
mergeLine:lineNr removeBlanks:removeBlanks |
3287 |
"merge line lineNr with line lineNr+1" |
|
3288 |
||
3289 |
|len| |
|
3290 |
||
3291 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3292 |
||
3293 |
len := (self listAt:lineNr) size. |
|
3294 |
self nonUndoableDo:[ |
|
3295 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
|
3296 |
]. |
|
3297 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3298 |
! |
|
3299 |
||
2506 | 3300 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3301 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3302 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3303 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3304 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3305 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3306 |
|
2506 | 3307 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
3160 | 3308 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
3309 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
3310 |
newSelectionEnd := newSelectionEnd-1. |
|
3311 |
]. |
|
3312 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
3313 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3314 |
newSelectionEnd := newSelectionEnd-1. |
|
3315 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3316 |
] ifFalse:[ |
3160 | 3317 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
3318 |
newSelectionEnd := newSelectionEnd+1. |
|
3319 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
3320 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3321 |
newSelectionEnd := newSelectionEnd+1. |
|
3322 |
] |
|
3323 |
]. |
|
3324 |
self |
|
3325 |
selectFromLine:selectionStartLine col:selectionStartCol |
|
3326 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3327 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3328 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3329 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3330 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3331 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3332 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3333 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3334 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3335 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3336 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3337 |
[finished] whileFalse:[ |
3160 | 3338 |
(lastLine <= 1) ifTrue:[ |
3339 |
finished := true |
|
3340 |
] ifFalse:[ |
|
3341 |
line := list at:lastLine. |
|
3342 |
line notNil ifTrue:[ |
|
3343 |
line isBlank ifTrue:[ |
|
3344 |
list at:lastLine put:nil. |
|
3345 |
line := nil |
|
3346 |
] |
|
3347 |
]. |
|
3348 |
line notNil ifTrue:[ |
|
3349 |
finished := true |
|
3350 |
] ifFalse:[ |
|
3351 |
lastLine := lastLine - 1 |
|
3352 |
] |
|
3353 |
] |
|
118 | 3354 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3355 |
(lastLine ~~ list size) ifTrue:[ |
3160 | 3356 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3357 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3358 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3359 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3360 |
|
4458 | 3361 |
replace:aCharacter atLine:lineNr col:colNr |
3362 |
"replace a single character at lineNr/colNr" |
|
3363 |
||
3364 |
|originalChar| |
|
3365 |
||
3366 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3367 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3368 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3369 |
! |
|
3370 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3371 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ign |
3430 | 3372 |
|pattern replacePattern| |
3373 |
||
3374 |
pattern := patternArg string. |
|
3375 |
replacePattern := replacePatternArg string. |
|
4630 | 3376 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3377 |
self rememberSearchPattern:pattern. |
|
3378 |
self rememberSearchPattern:replacePattern. |
|
3379 |
LastSearchIgnoredCase := ign. |
|
3380 |
self |
|
3381 |
undoableDo:[ |
|
3382 |
all ifTrue:[ |
|
3383 |
self |
|
3384 |
replaceString:pattern |
|
3385 |
to:replacePattern |
|
3386 |
ignoreCase:ign |
|
3387 |
] ifFalse:[ |
|
3388 |
(self selectionAsString notNil |
|
3389 |
and:[ self selectionAsString sameAs:pattern ignoreCase:ign ]) |
|
3390 |
ifTrue:[ |
|
3391 |
self replaceSelectionWith:replacePattern. |
|
3392 |
self |
|
3393 |
search:pattern |
|
3394 |
ignoreCase:ign |
|
3395 |
forward:(lastSearchDirection = #forward). |
|
3396 |
]. |
|
3397 |
] |
|
3398 |
] |
|
3399 |
info:'Replace' |
|
3430 | 3400 |
] |
3401 |
||
3402 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3403 |
! |
|
3404 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3405 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3406 |
"replace a single character at cursor-position - advance cursor" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3407 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3408 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3409 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3410 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3411 |
aCharacter == (Character cr) ifTrue:[ |
3160 | 3412 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3413 |
] ifFalse:[ |
3160 | 3414 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3415 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3416 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3417 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3418 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3419 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3420 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3421 |
|
4458 | 3422 |
replaceContentsWith:newContents |
3423 |
"replace everything" |
|
3424 |
||
3425 |
|originalContents| |
|
3426 |
||
3427 |
originalContents := self contents. |
|
3428 |
self contents:newContents keepUndoHistory:true. |
|
3429 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3430 |
! |
|
3431 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3432 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3433 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3434 |
|
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3435 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3436 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3437 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3438 |
|
4458 | 3439 |
replaceLine:lineNr with:newText |
3440 |
"replace a line at lineNr" |
|
3441 |
||
3442 |
|originalLine| |
|
3443 |
||
3444 |
originalLine := self listAt:lineNr. |
|
3445 |
originalLine isNil ifTrue:[ |
|
3446 |
self checkForExistingLine:lineNr |
|
3447 |
]. |
|
3448 |
self list at:lineNr put:newText. |
|
3449 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3450 |
self invalidateLine:lineNr. |
|
3451 |
||
3452 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3453 |
! |
|
3454 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3455 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3456 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3457 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3458 |
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
|
3459 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3460 |
|
1809 | 3461 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3462 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3463 |
lines notNil ifTrue:[ |
4661 | 3464 |
wasOn := self hideCursor. |
3465 |
nLines := lines size. |
|
3466 |
line := cursorLine. |
|
3467 |
col := cursorCol. |
|
3468 |
lines keysAndValuesDo:[:i :l | |
|
3469 |
self replaceString:(l ? '') atLine:line col:col. |
|
3470 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3471 |
line := line + 1. |
|
3472 |
col := 1. |
|
3473 |
] ifFalse:[ |
|
3474 |
col := col + (l size). |
|
3475 |
] |
|
3476 |
]. |
|
3477 |
self cursorLine:line col:col. |
|
3478 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3479 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3480 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3481 |
|
4661 | 3482 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3483 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3484 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3485 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3486 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3487 |
"delete the selection (if any) and insert something, a character or string; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3488 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3489 |
|
4666 | 3490 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3491 |
! |
3492 |
||
3493 |
replaceSelectionBy:something keepCursor:keep |
|
3494 |
"delete the selection (if any) and insert something, a character or string; |
|
3495 |
leave cursor after insertion or leave it, depending on keep" |
|
3496 |
||
4666 | 3497 |
self replaceSelectionBy:something keepCursor:keep select:false |
3498 |
||
3499 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3500 |
! |
|
3501 |
||
3502 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
3503 |
"delete the selection (if any) and insert something, a character or string; |
|
3504 |
leave cursor after insertion or leave it, depending on keep. |
|
3505 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3506 |
||
3507 |
|sel l c selStartLine selStartCol| |
|
105 | 3508 |
|
3509 |
l := cursorLine. |
|
3510 |
c := cursorCol. |
|
3511 |
||
3512 |
sel := self selection. |
|
4666 | 3513 |
sel isNil ifTrue:[ |
3514 |
selStartLine := l. |
|
3515 |
selStartCol := c. |
|
3516 |
] ifFalse:[ |
|
3517 |
selStartLine := selectionStartLine. |
|
3518 |
selStartCol := selectionStartCol. |
|
3519 |
||
4053 | 3520 |
self setLastStringToReplace: sel. |
3521 |
||
4010 | 3522 |
self deleteSelection. |
3523 |
replacing := true. |
|
4048 | 3524 |
lastReplacementInfo lastReplacement: ''. |
4010 | 3525 |
undoSupport actionInfo:'replace'. |
3161 | 3526 |
]. |
3527 |
||
3528 |
something isCharacter ifTrue:[ |
|
4051 | 3529 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3530 |
"/ "XXX - replacing text with spaces ..." |
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3531 |
"/ (lastReplacement endsWith:Character space) ifTrue:[ |
4051 | 3532 |
"/ lastReplacement := lastReplacementInfo lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)". |
3533 |
"/ lastReplacement := lastReplacementInfo lastReplacement copyWith:something. |
|
3534 |
"/ lastReplacement := lastReplacementInfo lastReplacement copyWith:Character space |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3535 |
"/ ] ifFalse:[ |
4051 | 3536 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3537 |
"/ ] |
4010 | 3538 |
]. |
3539 |
self isInInsertMode ifTrue:[ |
|
3540 |
self insertCharAtCursor:something |
|
3541 |
] ifFalse:[ |
|
3542 |
self replaceCharAtCursor:something |
|
3543 |
] |
|
105 | 3544 |
] ifFalse:[ |
4010 | 3545 |
something isString ifTrue:[ |
4048 | 3546 |
lastReplacementInfo lastReplacement: something. |
4010 | 3547 |
self isInInsertMode ifTrue:[ |
3548 |
self insertStringAtCursor:something |
|
3549 |
] ifFalse:[ |
|
3550 |
self replaceStringAtCursor:something |
|
3551 |
] |
|
3552 |
] ifFalse:[ |
|
3553 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3554 |
]. |
|
105 | 3555 |
]. |
3556 |
keep ifTrue:[ |
|
4010 | 3557 |
self cursorLine:l col:c |
4666 | 3558 |
]. |
3559 |
selectNewText ifTrue:[ |
|
3560 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3561 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3562 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3563 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3564 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3565 |
|
4458 | 3566 |
replaceString:aString atLine:lineNr col:colNr |
3567 |
"replace multiple characters starting at lineNr/colNr. |
|
3568 |
This is not prepared to encounter special chars (except TAB) in the string." |
|
3569 |
||
3570 |
|originalString| |
|
3571 |
||
3572 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3573 |
||
3574 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3575 |
||
3576 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3577 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3578 |
! |
|
3579 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3580 |
replaceString:aString to:aNewString ignoreCase:ign |
3549 | 3581 |
|continue count| |
3582 |
||
3583 |
self cursorToTop. |
|
3584 |
self selectFromBeginning. |
|
3585 |
count := 0. |
|
3586 |
continue := true. |
|
3587 |
[ continue ] whileTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3588 |
(self selectionAsString notNil |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3589 |
and:[ self selectionAsString sameAs:aString ignoreCase:ign ]) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3590 |
ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3591 |
self replaceSelectionWith:aNewString. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3592 |
count := count + 1. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3593 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3594 |
self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3595 |
searchFwd:aString |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3596 |
ignoreCase:ign |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3597 |
ifAbsent:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3598 |
Dialog |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3599 |
information:aString , ' has been replaced to ' , aNewString , ' ' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3600 |
, count printString , ' times'. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3601 |
continue := false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3602 |
]. |
3549 | 3603 |
]. |
3430 | 3604 |
|
3605 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3606 |
! |
|
3607 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3608 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3609 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3610 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3611 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3612 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3613 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3614 |
(aString includes:Character tab) ifTrue:[ |
3160 | 3615 |
"/ need special care for TAB (to move cursor correctly) |
3616 |
i1 := 1. |
|
3617 |
[i1 ~~ 0] whileTrue:[ |
|
3618 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3619 |
i2 ~~ 0 ifTrue:[ |
|
3620 |
i1 ~~ i2 ifTrue:[ |
|
3621 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3622 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3623 |
]. |
|
3624 |
self replaceTABAtCursor. |
|
3625 |
i2 := i2 + 1. |
|
3626 |
] ifFalse:[ |
|
3627 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3628 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3629 |
]. |
|
3630 |
i1 := i2. |
|
3631 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3632 |
] ifFalse:[ |
3160 | 3633 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3634 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3635 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3636 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3637 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3638 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3639 |
"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
|
3640 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3641 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3642 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3643 |
"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
|
3644 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3645 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3646 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3647 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3648 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3649 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3650 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3651 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3652 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3653 |
! |
3654 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3655 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3656 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3657 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3658 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3659 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3660 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3661 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3662 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3663 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3664 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3665 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3666 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3667 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3668 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3669 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3670 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3671 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3672 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3673 |
|
4458 | 3674 |
splitLine:lineNr before:colNr |
3675 |
"split the line linNr before colNr; the right part (from colNr) |
|
3676 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3677 |
||
3678 |
self basicSplitLine:lineNr before:colNr. |
|
3679 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3680 |
! |
|
3681 |
||
3682 |
withoutRedrawAt:lineNr put:aString |
|
3683 |
"replace a line at lineNr" |
|
3684 |
||
3685 |
|originalLine| |
|
3686 |
||
3687 |
originalLine := self listAt:lineNr. |
|
3688 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3689 |
super withoutRedrawAt:lineNr put:aString. |
|
3690 |
! |
|
3691 |
||
3692 |
withoutRedrawInsertLine:aString before:lineNr |
|
3693 |
"insert the argument, aString before line lineNr; the string |
|
3694 |
becomes line lineNr; everything else is moved down; the view |
|
3695 |
is not redrawn" |
|
3696 |
||
3697 |
self basicWithoutRedrawInsertLine:aString before:lineNr. |
|
3698 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
|
3699 |
! |
|
3700 |
||
3701 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
3702 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3703 |
||
3704 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
3705 |
self isReadOnly ifFalse:[ |
|
3706 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
|
3707 |
]. |
|
3708 |
! |
|
3709 |
||
3710 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3711 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3712 |
||
3713 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
3714 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
3715 |
! |
|
3716 |
||
3890 | 3717 |
wrapLines |
3718 |
"wrap lines (insert line-break)" |
|
3719 |
||
3720 |
|lineLength answerString string| |
|
3721 |
||
3722 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3723 |
||
3724 |
self hasSelection ifFalse:[ |
|
3725 |
self selectLine:cursorLine. |
|
3726 |
]. |
|
3727 |
string := self selectionAsString. |
|
3728 |
string isEmptyOrNil ifTrue:[ |
|
3729 |
Dialog information:(resources string:'Nothing selected.'). |
|
3730 |
^ self. |
|
3731 |
]. |
|
3732 |
||
3733 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
3734 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 3735 |
lineLength isNil ifTrue:[^ self]. |
3890 | 3736 |
lineLength < 1 ifTrue:[ |
3737 |
lineLength := 1. |
|
3738 |
]. |
|
3739 |
||
3740 |
self |
|
3741 |
undoableDo:[ |
|
3742 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
3743 |
||
3744 |
line := selectionStartLine. |
|
3745 |
col := selectionStartCol. |
|
3746 |
||
3747 |
self cutSelection. |
|
3748 |
self cursorLine:line col:col. |
|
3749 |
||
3750 |
lastGoodCol := col. |
|
3751 |
||
3752 |
inStream := string readStream. |
|
3753 |
[ inStream atEnd ] whileFalse:[ |
|
3754 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
3755 |
word := WriteStream on:(String new:10). |
|
3756 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
3757 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
3758 |
self insertCharAtCursor:(Character cr). |
|
3759 |
col := 1. |
|
3760 |
] ifFalse:[ |
|
3761 |
col ~~ 1 ifTrue:[ |
|
3762 |
self insertStringAtCursor:' '. |
|
3763 |
col := col + 1. |
|
3764 |
] |
|
3765 |
]. |
|
3766 |
self insertStringAtCursor:word contents. |
|
3767 |
col := col + word size. |
|
3768 |
]. |
|
3769 |
] |
|
3770 |
info:'Wrap' |
|
4388 | 3771 |
|
3772 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3773 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3774 |
|
2752 | 3775 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3776 |
|
2952 | 3777 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3778 |
"delete characters from startCol to endCol in line lineNr" |
3779 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
3780 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3781 |
|
4673 | 3782 |
self unselect. |
3783 |
||
3784 |
cursorLine == lineNr ifTrue:[ |
|
3785 |
cursorCol >= startCol ifTrue:[ |
|
3786 |
cursorCol >= endCol ifTrue:[ |
|
3787 |
cursorCol := startCol. |
|
3788 |
] ifFalse:[ |
|
3789 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
3790 |
] |
|
3791 |
]. |
|
3792 |
]. |
|
3793 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3794 |
line := self listAt:lineNr. |
827 | 3795 |
|
4673 | 3796 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
3797 |
||
3798 |
lineSize := line size. |
|
3799 |
||
3800 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
3801 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
3802 |
||
3803 |
stop >= start ifTrue:[ |
|
3804 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
3805 |
ifFalse:[ newLine := '' ]. |
|
3806 |
||
3807 |
stop == lineSize ifFalse:[ |
|
3808 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
3809 |
newLine := line string species fromString:newLine. |
|
4190 | 3810 |
]. |
4673 | 3811 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
3812 |
]. |
|
3813 |
||
3814 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
3815 |
newLine := nil |
|
3816 |
]. |
|
3817 |
||
3818 |
prevWidth := self widthOfLine:lineNr. |
|
3819 |
||
3820 |
list at:lineNr put:newLine. |
|
3821 |
||
3822 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
3823 |
"/ remember old width of this line, |
|
3824 |
"/ only clear widthOfWidestLine, if this lines |
|
3825 |
"/ length was (one of) the longest. |
|
3826 |
"/ avoids slow delete with huge texts. |
|
3827 |
widthOfWidestLine := nil. "i.e. unknown" |
|
3828 |
||
3829 |
"/ scroll left if reqiured |
|
3830 |
viewOrigin x > 0 ifTrue:[ |
|
3831 |
newWidth := self widthOfLine:lineNr. |
|
3832 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
3833 |
self scrollHorizontalTo:(newWidth |
|
3834 |
- width |
|
3835 |
+ margin + margin |
|
3836 |
+ (font widthOf:' ')) |
|
3837 |
] |
|
4190 | 3838 |
]. |
4673 | 3839 |
self textChanged. |
3840 |
] ifFalse:[ |
|
3841 |
self textChanged "/ textChangedButNoSizeChange |
|
3842 |
]. |
|
3843 |
font hasOverlappingCharacters ifTrue:[ |
|
3844 |
self invalidateLine:lineNr. |
|
3845 |
] ifFalse:[ |
|
3846 |
self redrawLine:lineNr from:start. |
|
3847 |
]. |
|
3848 |
]. |
|
827 | 3849 |
|
4191 | 3850 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3851 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3852 |
|
2952 | 3853 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3854 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3855 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3856 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3857 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3858 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3859 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3860 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3861 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3862 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3863 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3864 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 3865 |
startLineNr <= list size ifTrue:[ |
3866 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
3867 |
]. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3868 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3869 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3870 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3871 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3872 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3873 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3874 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3875 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3876 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3877 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3878 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 3879 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3880 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3881 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3882 |
|
4226 | 3883 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
3884 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3885 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3886 |
|
2952 | 3887 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3888 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3889 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3890 |
|
2952 | 3891 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3892 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3893 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3894 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3895 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3896 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3897 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3898 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3899 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3900 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3901 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3902 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3903 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3904 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3905 |
|
2952 | 3906 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 3907 |
"insert a single character at lineNr/colNr; |
827 | 3908 |
set emphasis to character at current position" |
3909 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
3910 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3911 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3912 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3913 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3914 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3915 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3916 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3917 |
]. |
827 | 3918 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3919 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3920 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3921 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3922 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3923 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3924 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3925 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3926 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3927 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3928 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3929 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3930 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
3931 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3932 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3933 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3934 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3935 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3936 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3937 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3938 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3939 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3940 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3941 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3942 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3943 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3944 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3945 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3946 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3947 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3948 |
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
|
3949 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3950 |
]. |
827 | 3951 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3952 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3953 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3954 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3955 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3956 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
3957 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3958 |
newLine at:colNr put:aCharacter. |
827 | 3959 |
|
3960 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3961 |
newLine emphasisAt:colNr put:attribute. |
827 | 3962 |
]. |
3963 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3964 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3965 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3966 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3967 |
]. |
827 | 3968 |
|
4458 | 3969 |
list at:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3970 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 3971 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3972 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3973 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3974 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3975 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3976 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3977 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3978 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3979 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3980 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3981 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3982 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3983 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3984 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 3985 |
|
3986 |
font hasOverlappingCharacters ifTrue:[ |
|
3987 |
self invalidateLine:lineNr. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3988 |
] ifFalse:[ |
4190 | 3989 |
drawCharacterOnly ifTrue:[ |
3990 |
self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)). |
|
3991 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
3992 |
] ifFalse:[ |
|
3993 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
3994 |
self redrawLine:lineNr from:colNr-1 |
|
3995 |
]. |
|
3996 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3997 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3998 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
3999 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4000 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4001 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4002 |
font hasOverlappingCharacters ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4003 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4004 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4005 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4006 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4007 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4008 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4009 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4010 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4011 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4012 |
|
4191 | 4013 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4014 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4015 |
|
2952 | 4016 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4017 |
"merge line lineNr with line lineNr+1" |
4018 |
||
827 | 4019 |
|leftPart rightPart bothParts nextLineNr i| |
4020 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4021 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
3160 | 4022 |
"/ empty list or beyond end of text |
4023 |
^ self |
|
827 | 4024 |
]. |
4025 |
leftPart := self listAt:lineNr. |
|
4026 |
||
4027 |
leftPart isNil ifTrue:[ |
|
3160 | 4028 |
leftPart := ''. |
4029 |
autoIndent ifTrue:[ |
|
4030 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4031 |
leftPart := String new:i |
|
4032 |
] |
|
4033 |
] |
|
827 | 4034 |
]. |
4035 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4036 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4037 |
||
4038 |
nextLineNr > (list size) ifFalse:[ |
|
3160 | 4039 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4040 |
rightPart := '' |
|
4041 |
] ifFalse:[ |
|
4042 |
removeBlanks ifTrue:[ |
|
4043 |
rightPart := rightPart withoutLeadingSeparators. |
|
4044 |
] |
|
4045 |
]. |
|
4046 |
||
4047 |
bothParts := leftPart , rightPart. |
|
4048 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4049 |
list at:lineNr put:bothParts. |
|
4050 |
self redrawLine:lineNr. |
|
4051 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4052 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4053 |
|
1319 | 4054 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4055 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4056 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4057 |
|
2952 | 4058 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4059 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4060 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4061 |
|line lineSize newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4062 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4063 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4064 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4065 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4066 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4067 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4068 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4069 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4070 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4071 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4072 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4073 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4074 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4075 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4076 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4077 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4078 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4079 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4080 |
(lineSize == 0) ifTrue:[ |
4190 | 4081 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4082 |
] ifFalse: [ |
4190 | 4083 |
(colNr > lineSize) ifTrue: [ |
4084 |
newLine := line species new:colNr. |
|
4085 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4086 |
] ifFalse: [ |
|
4087 |
newLine := line copy. |
|
4088 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4089 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4090 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4091 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4092 |
newLine := self withTabsExpanded:newLine. |
4093 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4094 |
]. |
4458 | 4095 |
list at:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4096 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4097 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4098 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4099 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4100 |
shown ifTrue:[ |
4190 | 4101 |
font hasOverlappingCharacters ifTrue:[ |
4102 |
self invalidateLine:lineNr. |
|
4103 |
] ifFalse:[ |
|
4104 |
drawCharacterOnly ifTrue:[ |
|
4105 |
self redrawLine:lineNr col:colNr |
|
4106 |
] ifFalse:[ |
|
4107 |
self redrawLine:lineNr from:colNr |
|
4108 |
] |
|
4109 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4110 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4111 |
|
4190 | 4112 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4113 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4114 |
! |
4115 |
||
3235 | 4116 |
basicReplaceString:aString atLine:lineNr col:colNr |
4117 |
"replace multiple characters starting at lineNr/colNr. |
|
4118 |
This is not prepared to encounter special chars (except TAB) |
|
4119 |
in the string." |
|
4120 |
||
4121 |
|line lineSize newLine endCol| |
|
4122 |
||
4123 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4124 |
||
4125 |
self checkForExistingLine:lineNr. |
|
4126 |
line := list at:lineNr. |
|
4127 |
lineSize := line size. |
|
4128 |
||
4129 |
endCol := colNr + aString size - 1. |
|
4130 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4131 |
newLine := aString species new:endCol. |
3235 | 4132 |
] ifFalse: [ |
4190 | 4133 |
(endCol > lineSize) ifTrue: [ |
4134 |
aString isText ifTrue:[ |
|
4135 |
newLine := aString species new:endCol. |
|
4136 |
] ifFalse:[ |
|
4137 |
newLine := line species new:endCol. |
|
4138 |
]. |
|
4139 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4140 |
] ifFalse: [ |
|
4141 |
aString isText ifTrue:[ |
|
4142 |
newLine := aString species new:line size. |
|
4143 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4144 |
] ifFalse:[ |
|
4145 |
newLine := line copy. |
|
4146 |
] |
|
4147 |
] |
|
3235 | 4148 |
]. |
4149 |
newLine replaceFrom:colNr with:aString. |
|
4150 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4151 |
newLine := self withTabsExpanded:newLine. |
3235 | 4152 |
]. |
4458 | 4153 |
list at:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4154 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4155 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4156 |
]. |
4157 |
self textChanged. |
|
4158 |
shown ifTrue:[ |
|
4190 | 4159 |
font hasOverlappingCharacters ifTrue:[ |
4160 |
self invalidateLine:lineNr. |
|
4161 |
] ifFalse:[ |
|
4162 |
self redrawLine:lineNr from:colNr |
|
4163 |
] |
|
3235 | 4164 |
] |
4165 |
||
4190 | 4166 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4167 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4168 |
! |
4169 |
||
2952 | 4170 |
basicSplitLine:lineNr before:colNr |
4171 |
"split the line linNr before colNr; the right part (from colNr) |
|
4172 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4173 |
||
3160 | 4174 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4175 |
srcY "{ Class: SmallInteger }" | |
4176 |
||
3027 | 4177 |
list isNil ifTrue:[ ^ self ]. |
4178 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4179 |
||
4180 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4181 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4182 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4183 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4184 |
^ self |
3027 | 4185 |
]. |
4186 |
||
4187 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4188 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4189 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4190 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4191 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4192 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4193 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4194 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4195 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4196 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4197 |
] |
3027 | 4198 |
]. |
4199 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4200 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4201 |
]. |
4202 |
list at:lineNr put:leftRest. |
|
4203 |
self nonUndoableDo:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4204 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4205 |
]. |
4206 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4207 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4208 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4209 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4210 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4211 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4212 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4213 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4214 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4215 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4216 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4217 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4218 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4219 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4220 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4221 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4222 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4223 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4224 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4225 |
]. |
4226 |
widthOfWidestLine := nil. "/ unknown |
|
4227 |
self textChanged. |
|
2952 | 4228 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4229 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4230 |
! |
4231 |
||
4232 |
basicWithoutRedrawInsertLine:aString before:lineNr |
|
4233 |
"insert the argument, aString before line lineNr; the string |
|
4234 |
becomes line nileNr; everything else is moved down; the view |
|
4235 |
is not redrawn" |
|
4236 |
||
4237 |
|line| |
|
4238 |
||
4239 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4240 |
||
4241 |
line := aString. |
|
4242 |
line notNil ifTrue:[ |
|
4458 | 4243 |
line isString ifTrue:[ |
4244 |
line isBlank ifTrue:[ |
|
4245 |
line := nil |
|
4246 |
] ifFalse:[ |
|
4247 |
(line includes:(Character tab)) ifTrue:[ |
|
4248 |
line := self withTabsExpanded:line |
|
4249 |
] |
|
4250 |
] |
|
4251 |
] |
|
2952 | 4252 |
]. |
4253 |
list isNil ifTrue: [ |
|
4458 | 4254 |
list := StringCollection new:lineNr |
2952 | 4255 |
] ifFalse: [ |
4458 | 4256 |
list grow:((list size + 1) max:lineNr) |
3160 | 4257 |
]. |
4258 |
||
4259 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2952 | 4260 |
overlapping copy - if it didn't, we had to use:" |
4261 |
" |
|
4262 |
index := list size. |
|
4263 |
[index > lineNr] whileTrue: [ |
|
4458 | 4264 |
pIndex := index - 1. |
4265 |
list at:index put:(list at:pIndex). |
|
4266 |
index := pIndex |
|
2952 | 4267 |
]. |
4268 |
" |
|
4269 |
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr. |
|
4649 | 4270 |
list at:lineNr put:(line isNil ifTrue:[nil] ifFalse:[line asSingleByteStringIfPossible]). |
2952 | 4271 |
self contentsChanged |
4272 |
||
4273 |
"Modified: / 10.6.1998 / 19:00:56 / cg" |
|
4274 |
! |
|
4275 |
||
2954 | 4276 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4277 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4278 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4279 |
because the text might have been pasted from an alien view." |
|
2954 | 4280 |
|
4281 |
|newLine newLines nLines| |
|
4282 |
||
4283 |
nLines := end - start + 1. |
|
4284 |
newLines := Array new:(lines size). |
|
4285 |
start to:end do:[:index | |
|
4328 | 4286 |
newLine := lines at:index. |
4287 |
newLine notNil ifTrue:[ |
|
4288 |
newLine isString ifTrue:[ |
|
4289 |
newLine isBlank ifTrue:[ |
|
4290 |
newLine := nil |
|
4291 |
] ifFalse:[ |
|
4292 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4293 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4294 |
] |
|
4295 |
] |
|
4296 |
] |
|
4297 |
]. |
|
4298 |
newLines at:index put:newLine |
|
2954 | 4299 |
]. |
4300 |
list isNil ifTrue: [ |
|
4328 | 4301 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4302 |
] ifFalse: [ |
4328 | 4303 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4304 |
]. |
4305 |
||
4306 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4307 |
overlapping copy - if it didn't, we had to use:" |
4308 |
" |
|
4309 |
index := list size. |
|
4310 |
[index > lineNr] whileTrue: [ |
|
4328 | 4311 |
pIndex := index - 1. |
4312 |
list at:index put:(list at:pIndex). |
|
4313 |
index := pIndex |
|
2954 | 4314 |
]. |
4315 |
" |
|
4316 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4317 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4318 |
self contentsChanged |
|
4319 |
||
4328 | 4320 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4321 |
! |
4322 |
||
4323 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4324 |
"insert aString (which has no crs) at lineNr/colNr. |
4325 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4326 |
because the text might have been pasted from an alien view." |
|
2954 | 4327 |
|
4360 | 4328 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4329 |
|
4623 | 4330 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4331 |
|
4332 |
strLen := aString size. |
|
4333 |
self checkForExistingLine:lineNr. |
|
4334 |
||
4335 |
stringType := aString string species. |
|
4336 |
isText := aString isText. |
|
4337 |
line := list at:lineNr. |
|
4338 |
||
4339 |
line notNil ifTrue:[ |
|
4328 | 4340 |
lineSize := line size. |
4341 |
line isString ifFalse:[ |
|
4342 |
stringType := line species |
|
4343 |
] ifTrue:[ |
|
4360 | 4344 |
lineCharWidth := line bitsPerCharacter. |
4345 |
stringCharWidth := aString bitsPerCharacter. |
|
4346 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4347 |
stringType := line string species |
4360 | 4348 |
] ifFalse:[ |
4349 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4350 |
stringType := aString string species |
|
4351 |
] |
|
4328 | 4352 |
]. |
4353 |
line isText ifTrue:[ isText := true ] |
|
4354 |
]. |
|
2954 | 4355 |
] ifFalse:[ |
4328 | 4356 |
lineSize := 0 |
2954 | 4357 |
]. |
4358 |
||
4359 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4360 |
newLine := aString |
2954 | 4361 |
] ifFalse:[ |
4328 | 4362 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4363 |
sz := colNr + strLen - 1 |
|
4364 |
] ifFalse:[ |
|
4365 |
sz := lineSize + strLen |
|
4366 |
]. |
|
4367 |
||
4360 | 4368 |
newLine := stringType new:sz. |
4369 |
isText ifTrue:[ |
|
4370 |
newLine := Text string:newLine |
|
4328 | 4371 |
]. |
4372 |
||
4373 |
(lineSize ~~ 0) ifTrue: [ |
|
4374 |
(colNr > lineSize) ifTrue: [ |
|
4375 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4376 |
] ifFalse: [ |
|
4377 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4378 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4379 |
] |
|
4380 |
]. |
|
4381 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4382 |
]. |
4383 |
||
4384 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4385 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4386 |
]. |
4387 |
||
4458 | 4388 |
list at:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4389 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4390 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4391 |
]. |
4392 |
self textChanged. |
|
4393 |
||
4360 | 4394 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
2954 | 4395 |
! |
4396 |
||
2952 | 4397 |
insertLines:someText from:start to:end before:lineNr |
4649 | 4398 |
"insert a bunch of lines before line lineNr. |
4399 |
The cursor position is left unchanged." |
|
2952 | 4400 |
|
2954 | 4401 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
4402 |
srcY "{ Class: SmallInteger }" |
|
4403 |
dstY "{ Class: SmallInteger }" | |
|
4404 |
||
4405 |
autoIndent ifTrue:[ |
|
4649 | 4406 |
indent := self leftIndentForLine:lineNr. |
4407 |
||
4408 |
text := someText collect:[:ln||line| |
|
4409 |
ln notNil ifTrue:[ |
|
4410 |
line := ln withoutLeadingSeparators. |
|
4411 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
4412 |
line := (String new:indent), line |
|
4413 |
]. |
|
4414 |
line |
|
4415 |
] ifFalse:[ |
|
4416 |
nil |
|
4417 |
] |
|
4418 |
]. |
|
2954 | 4419 |
] ifFalse:[ |
4649 | 4420 |
text := someText |
2954 | 4421 |
]. |
4422 |
||
4423 |
visLine := self listLineToVisibleLine:lineNr. |
|
4424 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
4649 | 4425 |
self withoutRedrawInsertLines:text |
4426 |
from:start to:end |
|
4427 |
before:lineNr. |
|
2954 | 4428 |
] ifFalse:[ |
4649 | 4429 |
nLines := end - start + 1. |
4430 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
4431 |
self withoutRedrawInsertLines:text |
|
4432 |
from:start to:end |
|
4433 |
before:lineNr. |
|
4434 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
4435 |
] ifFalse:[ |
|
4436 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
4437 |
and:(firstLineShown + nLines + nLinesShown). |
|
4438 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
4439 |
dstY := srcY + (nLines * fontHeight). |
|
4440 |
||
4441 |
"/ |
|
4442 |
"/ scroll ... |
|
4443 |
"/ |
|
4444 |
" |
|
4445 |
stupid: must catchExpose before inserting new |
|
4446 |
stuff - since catchExpose may perform redraws |
|
4447 |
" |
|
4448 |
self catchExpose. |
|
4449 |
self withoutRedrawInsertLines:text |
|
4450 |
from:start to:end |
|
4451 |
before:lineNr. |
|
4452 |
self |
|
4453 |
copyFrom:self |
|
4454 |
x:textStartLeft y:srcY |
|
4455 |
toX:textStartLeft y:dstY |
|
4456 |
width:w |
|
4457 |
height:(height - dstY) |
|
4458 |
async:true. |
|
4459 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
4460 |
self waitForExpose |
|
4461 |
]. |
|
2954 | 4462 |
]. |
4463 |
widthOfWidestLine notNil ifTrue:[ |
|
4649 | 4464 |
text do:[:line | |
4465 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
4466 |
] |
|
2954 | 4467 |
]. |
4468 |
self textChanged. |
|
4469 |
||
4470 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4471 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4472 |
|
2752 | 4473 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4474 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4475 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4476 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4477 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4478 |
hasKeyboardFocus := true. |
2589 | 4479 |
dragIsActive := false. |
4480 |
||
4609 | 4481 |
self closeCompletionView. |
4482 |
||
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4483 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4484 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4485 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4486 |
|
4420 | 4487 |
"On X11, be nice and paste PRIMARY when middle click. |
4488 |
Note, that middle button on X11 is translated to button |
|
4489 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
4421
06727bd6c8e8
Make paste button symbolic
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4420
diff
changeset
|
4490 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4491 |
self undoableDo:[ |
4492 |
self paste: (self getClipboardText:#selection). |
|
4493 |
]. |
|
4494 |
^self. |
|
4495 |
]. |
|
4496 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4497 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4498 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4499 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4500 |
"/ 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
|
4501 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4502 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4503 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4504 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4505 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4506 |
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
|
4507 |
|
4420 | 4508 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4509 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4510 |
! |
4511 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4512 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4513 |
"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
|
4514 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4515 |
|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
|
4516 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4517 |
(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
|
4518 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4519 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4520 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4521 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4522 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4523 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4524 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4525 |
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
|
4526 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4527 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4528 |
cursorType ~~ #block ifTrue:[ |
3790 | 4529 |
clickPos notNil ifTrue:[ |
4530 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4531 |
"/ (i.e. if its an ibeam). |
|
4532 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4533 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4534 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4535 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4536 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4537 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4538 |
]. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4539 |
self cursorLine:clickLine col:newCursorCol. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4540 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4541 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4542 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4543 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4544 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4545 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4546 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4547 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4548 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4549 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4550 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4551 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4552 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4553 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4554 |
] ifFalse:[ |
4048 | 4555 |
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
|
4556 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4557 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4558 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4559 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4560 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4561 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4562 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4563 |
|
4609 | 4564 |
closeCompletionView |
4565 |
|v| |
|
4566 |
||
4567 |
(v := completionView) notNil ifTrue:[ |
|
4568 |
completionView := nil. |
|
4569 |
v topView destroy. |
|
4570 |
]. |
|
4571 |
! |
|
4572 |
||
2580 | 4573 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4574 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4575 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4576 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4577 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4578 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4579 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4580 |
self changeTypeOfSelectionTo:nil. |
2580 | 4581 |
|
4582 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4583 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4584 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4585 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4586 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4587 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4588 |
self validateNewSelection. |
4420 | 4589 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4590 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4591 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4592 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4593 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4594 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4595 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4596 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4597 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4598 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4599 |
"/ 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
|
4600 |
"/ 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
|
4601 |
"/ 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
|
4602 |
"/ (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
|
4603 |
"/ 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
|
4604 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4605 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4606 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4607 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4608 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4609 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4610 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4611 |
^ self |
2580 | 4612 |
]. |
4613 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4614 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4615 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4616 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4617 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4618 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4619 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4620 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4621 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4622 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4623 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4624 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4625 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4626 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4627 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4628 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4629 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4630 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4631 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4632 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4633 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4634 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4635 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4636 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4637 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4638 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4639 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4640 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4641 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4642 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4643 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4644 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4645 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4646 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4647 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4648 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4649 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4650 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4651 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4652 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4653 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4654 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4655 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4656 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4657 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4658 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4659 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4660 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4661 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4662 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4663 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4664 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4665 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4666 |
^ self |
2580 | 4667 |
]. |
4668 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4669 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4670 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4671 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4672 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4673 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4674 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4675 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4676 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4677 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4678 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4679 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4680 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4681 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4682 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4683 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4684 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4685 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4686 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4687 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4688 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4689 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4690 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4691 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4692 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4693 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4694 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4695 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4696 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4697 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4698 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4699 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4700 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4701 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4702 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4703 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4704 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4705 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4706 |
"/ self setCursorCol:selectionStartCol. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4707 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4708 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4709 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4710 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4711 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4712 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4713 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4714 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4715 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4716 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4717 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4718 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4719 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4720 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4721 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4722 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4723 |
(key == #CursorUp) ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4724 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4725 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4726 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4727 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4728 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4729 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4730 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4731 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4732 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4733 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4734 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4735 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4736 |
]. |
2580 | 4737 |
]. |
4420 | 4738 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4739 |
"Modified: / 30-08-2013 / 00:16:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 4740 |
! |
4741 |
||
2952 | 4742 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4743 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4744 |
|
4521 | 4745 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4746 |
#Replace #Undo #Redo #Accept |
3780 | 4747 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4748 |
#SelectWord #DeleteSpaces #Join |
|
4749 |
#SearchMatchingParent #SelectMatchingParents |
|
4750 |
#SelectToEnd #SelectFromBeginning |
|
4751 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
4752 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4753 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
4754 |
#GotoLine #BeginOfText #EndOfText |
|
4755 |
#SelectLine #ExpandSelectionByLine |
|
4756 |
#InsertLine #DeleteLine |
|
4757 |
#SelectLineFromBeginning |
|
4758 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
4162 | 4759 |
#OpenSpecialCharacterWindow |
3780 | 4760 |
#'F*' #'f*')> |
2017 | 4761 |
|
4238 | 4762 |
|fKeyMacros shiftPressed ctrlPressed i event macroName| |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4763 |
|
4609 | 4764 |
key isCharacter ifFalse:[ |
4765 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
|
4766 |
"/ keep open |
|
4767 |
] ifFalse:[ |
|
4768 |
self closeCompletionView. |
|
4769 |
]. |
|
4770 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4771 |
(key == #LearnKeyboardMacro) ifTrue:[ |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4772 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4773 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4774 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4775 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4776 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4777 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4778 |
]. |
3799 | 4779 |
(key == #Undo) ifTrue:[self undo. ^self]. |
4780 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
4781 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4782 |
self learnMode ifTrue:[ |
4482 | 4783 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4784 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4785 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4786 |
|
4238 | 4787 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
4788 |
"the macro named key exists" |
|
3780 | 4789 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4790 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4791 |
|
4482 | 4792 |
key isSymbol ifFalse:[ |
4793 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
4794 |
self handleNonCommandKey:key. |
|
4795 |
^ self |
|
4796 |
]. |
|
4797 |
||
4798 |
event isNil ifTrue:[ |
|
4799 |
event := WindowGroup lastEventQuerySignal query. |
|
4800 |
]. |
|
4801 |
shiftPressed := event hasShift. |
|
4802 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
4803 |
||
4253 | 4804 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
4805 |
self deleteWordBeforeCursor. |
|
4806 |
^ self. |
|
4807 |
]. |
|
4808 |
||
3257 | 4809 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 4810 |
selectionStartLine notNil ifTrue:[ |
4811 |
((key == #BasicBackspace) |
|
4812 |
or:[ UserPreferences current deleteSetsClipboardText not ]) |
|
4813 |
ifTrue:[ |
|
4814 |
self deleteSelection. |
|
4815 |
] ifFalse: [ |
|
4816 |
self copyAndDeleteSelection. |
|
4817 |
]. |
|
4609 | 4818 |
] ifFalse:[ |
4819 |
self makeCursorVisible. |
|
4820 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
4821 |
"/ self deleteWordBeforeCursor. |
|
4822 |
"/ ] ifFalse:[ |
|
4823 |
self deleteCharBeforeCursor. |
|
4824 |
"/ ]. |
|
3780 | 4825 |
]. |
4609 | 4826 |
self handleCompletionService. |
3780 | 4827 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4828 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4829 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4830 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4831 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4832 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4833 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4834 |
|
3235 | 4835 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4836 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 4837 |
^ self. |
3160 | 4838 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4839 |
|
4162 | 4840 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
4841 |
CharacterSetView notNil ifTrue:[ |
|
4842 |
self specialCharacters. |
|
4843 |
^ self. |
|
4844 |
] |
|
4845 |
]. |
|
4846 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4847 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4848 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4849 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4850 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 4851 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4852 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4853 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4854 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4855 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 4856 |
(('[fF][0-9]' match:key) |
4857 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4858 |
shiftPressed ifFalse:[ |
|
4859 |
fKeyMacros := UserPreferences current functionKeySequences. |
|
4860 |
fKeyMacros notNil ifTrue:[ |
|
4861 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4862 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4863 |
^ self |
|
4864 |
] |
|
4865 |
] |
|
4866 |
] |
|
4867 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4868 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4869 |
|
2506 | 4870 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 4871 |
self parenthizeSelectionWith:$( and:$). |
4872 |
^ self. |
|
2506 | 4873 |
]. |
4874 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 4875 |
self parenthizeSelectionWith:$" and:$". |
4876 |
^ self. |
|
2506 | 4877 |
]. |
4878 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 4879 |
self parenthizeSelectionWith:$' and:$'. |
4880 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4881 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4882 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4883 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4884 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
4885 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4886 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4887 |
(key == #Accept) ifTrue:[^ self accept]. |
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
4888 |
|
4521 | 4889 |
((key == #Paste) or:[key == #Insert or:[key == #PasteFromHistory]]) ifTrue:[self pasteOrReplace. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4890 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4891 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 4892 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4893 |
|
3542 | 4894 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4895 |
(key == #Replace) ifTrue:[self replace. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4896 |
(key == #SelectWord) ifTrue:[ |
3780 | 4897 |
self makeCursorVisible. |
4898 |
self selectWordUnderCursor. |
|
4899 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4900 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4901 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4902 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4903 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4904 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4905 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4906 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4907 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4908 |
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
|
4909 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
4910 |
(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
|
4911 |
(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
|
4912 |
(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
|
4913 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4914 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4915 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4916 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 4917 |
shiftPressed ifTrue: [ |
4918 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4919 |
"/ self unselect. |
|
4920 |
"/ self cursorHome. |
|
4921 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4922 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 4923 |
"/ 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
|
4924 |
"/ 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
|
4925 |
"/ self selectFromBeginOfLine. |
3780 | 4926 |
] ifFalse: [ |
4927 |
self unselect. |
|
4928 |
ctrlPressed ifTrue:[ |
|
4929 |
self cursorHome. |
|
4930 |
] ifFalse:[ |
|
4931 |
self cursorToBeginOfLine. |
|
4932 |
] |
|
4933 |
]. |
|
4934 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4935 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4936 |
(key == #EndOfLine) ifTrue:[ |
3780 | 4937 |
shiftPressed ifTrue:[ |
4938 |
"/ "Original St/X code - now use Ctrl modifier" |
|
4939 |
"/ self unselect. |
|
4940 |
"/ self cursorToBottom |
|
4257 | 4941 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4942 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 4943 |
"/ 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
|
4944 |
"/ 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
|
4945 |
"/ self selectToEndOfLine. |
3780 | 4946 |
] ifFalse:[ |
4947 |
self unselect. |
|
4948 |
ctrlPressed ifTrue:[ |
|
4949 |
self cursorToBottom |
|
4950 |
] ifFalse:[ |
|
4951 |
self cursorToEndOfLine. |
|
4952 |
] |
|
4953 |
]. |
|
4954 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4955 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4956 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 4957 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 4958 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4959 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4960 |
|
2580 | 4961 |
(key == #CursorRight |
4962 |
or:[key == #CursorDown |
|
4963 |
or:[key == #CursorLeft |
|
4964 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
4609 | 4965 |
completionView notNil ifTrue:[ |
4966 |
completionView keyPress:key x:x y:y. |
|
4967 |
^ self |
|
4968 |
]. |
|
3780 | 4969 |
self cursorKeyPress:key shifted:shiftPressed. |
4970 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4971 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4972 |
|
3257 | 4973 |
(key == #NonInsertingReturn) ifTrue:[ |
3780 | 4974 |
self unselect. self cursorReturn. |
4975 |
^ self |
|
3257 | 4976 |
]. |
4977 |
||
4978 |
(key == #Return) ifTrue:[ |
|
3780 | 4979 |
shiftPressed ifTrue:[ |
4980 |
self unselect. self cursorReturn. |
|
4981 |
^ self |
|
4982 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4983 |
|
3780 | 4984 |
self isReadOnly ifTrue:[ |
4985 |
self unselect; makeCursorVisible. |
|
4986 |
self cursorReturn |
|
4987 |
] ifFalse:[ |
|
4988 |
self isInInsertMode ifFalse:[ |
|
4989 |
self cursorReturn. |
|
4990 |
autoIndent == true ifTrue:[ |
|
4991 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4992 |
self cursorCol:(i+1 max:1) |
|
4993 |
] |
|
4994 |
] ifTrue:[ |
|
4995 |
"/ old version just unselected ... |
|
4996 |
"/ self unselect; makeCursorVisible. |
|
4997 |
||
4998 |
"/ new version deletes ... |
|
4999 |
typeOfSelection == #paste ifTrue:[ |
|
5000 |
self unselect; makeCursorVisible. |
|
5001 |
] ifFalse:[ |
|
5002 |
self copyAndDeleteSelection. |
|
5003 |
]. |
|
5004 |
self insertCharAtCursor:(Character cr). |
|
5005 |
autoIndent == true ifTrue:[ |
|
5006 |
i := self leftIndentForLine:cursorLine. |
|
5007 |
self indentFromLine:cursorLine toLine:cursorLine. |
|
5008 |
self cursorCol:(i+1 max:1) |
|
5009 |
]. |
|
5010 |
]. |
|
5011 |
]. |
|
5012 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5013 |
]. |
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
|
5014 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5015 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5016 |
self unselect. self cursorTab. |
5017 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5018 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5019 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5020 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5021 |
||
5022 |
self hasSelection ifTrue:[ |
|
5023 |
selectStyle == #line ifTrue:[ |
|
4238 | 5024 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5025 |
macroName := #IndentBy4. |
|
5026 |
] ifFalse:[ |
|
5027 |
macroName := #UndentBy4. |
|
5028 |
]. |
|
5029 |
macroName notNil ifTrue:[ |
|
5030 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5031 |
]. |
5032 |
] |
|
5033 |
]. |
|
5034 |
||
5035 |
self unselect. |
|
5036 |
(key == #Tab) ifTrue:[ |
|
5037 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5038 |
self cursorTab. |
|
5039 |
^ self |
|
5040 |
]. |
|
5041 |
self insertTabAtCursor. |
|
5042 |
^ self |
|
5043 |
]. |
|
5044 |
self cursorBacktab. |
|
5045 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5046 |
]. |
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
|
5047 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5048 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5049 |
(key == #Delete) ifTrue:[ |
3780 | 5050 |
shiftPressed ifTrue:[ |
5051 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5052 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5053 |
self makeCursorVisible. |
|
5054 |
self deleteCharAtCursor. |
|
5055 |
]. |
|
5056 |
^ self |
|
5057 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5058 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5059 |
|
870 | 5060 |
(key == #Delete |
5061 |
or:[key == #BasicDelete]) ifTrue:[ |
|
4129 | 5062 |
selectionStartLine notNil ifTrue:[ |
4130 | 5063 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5064 |
"/ To remove text repetetively, use Cut instead. |
|
5065 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5066 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5067 |
((key == #BasicDelete) |
5068 |
or:[UserPreferences current deleteSetsClipboardText not]) ifTrue:[ |
|
5069 |
self deleteSelection. |
|
5070 |
] ifFalse:[ |
|
5071 |
self copyAndDeleteSelection. |
|
5072 |
]. |
|
5073 |
^ self |
|
5074 |
]. |
|
5075 |
self makeCursorVisible. |
|
5076 |
self deleteCharAtCursor. |
|
5077 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5078 |
]. |
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
|
5079 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5080 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5081 |
self unselect. |
5082 |
cursorVisibleLine == 1 ifTrue:[ |
|
5083 |
self cursorHome. |
|
5084 |
] ifFalse:[ |
|
5085 |
self cursorToFirstVisibleLine |
|
5086 |
]. |
|
5087 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5088 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5089 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5090 |
self unselect. |
5091 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5092 |
self cursorToBottom. |
|
5093 |
] ifFalse:[ |
|
5094 |
self cursorToLastVisibleLine |
|
5095 |
]. |
|
5096 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5097 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5098 |
((key == #Escape) |
3257 | 5099 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5100 |
self makeCursorVisible. |
5101 |
self unselect. self selectCursorLineFromBeginning. |
|
5102 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5103 |
]. |
3257 | 5104 |
(key == #SelectLine) ifTrue:[ |
3780 | 5105 |
self makeCursorVisible. |
5106 |
self unselect. self selectCursorLine. |
|
5107 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5108 |
]. |
3257 | 5109 |
(key == #ExpandSelectionByLine) ifTrue:[ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5110 |
"/ self makeCursorVisible. |
3780 | 5111 |
self selectExpandCursorLine. |
5112 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5113 |
]. |
3257 | 5114 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5115 |
self makeCursorVisible. |
5116 |
self unselect. self deleteCursorLine. |
|
5117 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5118 |
]. |
3257 | 5119 |
(key == #InsertLine) ifTrue:[ |
3780 | 5120 |
self makeCursorVisible. |
5121 |
self unselect. self insertLine:nil before:cursorLine. |
|
5122 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5123 |
]. |
3781 | 5124 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5125 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5126 |
|
3310 | 5127 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5128 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5129 |
"Modified: / 26-08-2013 / 17:50:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5130 |
! |
5131 |
||
2952 | 5132 |
executeKeyboardMacro:cmdMacro |
5133 |
Error handle:[:ex | |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5134 |
self warn:'Error in keyboard macro: ' , ex description. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5135 |
ex return. |
2952 | 5136 |
] do:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5137 |
AbortOperationRequest handle:[:ex | |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5138 |
self warn:'Keyboard macro aborted'. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5139 |
ex return. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5140 |
] do:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5141 |
Parser |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5142 |
evaluate:cmdMacro asString |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5143 |
receiver:self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5144 |
notifying:nil |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5145 |
compile:false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5146 |
]. |
2952 | 5147 |
]. |
5148 |
! |
|
5149 |
||
4843
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5150 |
extendSelectionToX:x y:y |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5151 |
"mouse-move while button was pressed - handle selection changes" |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5152 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5153 |
" Overwritten here to move cursor position to start/end of the |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5154 |
selection, whichever changes" |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5155 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5156 |
| oldClickLine oldClickCol newCursorLine newCursorCol | |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5157 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5158 |
oldClickLine := clickStartLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5159 |
oldClickCol := clickStartCol. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5160 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5161 |
super extendSelectionToX:x y:y. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5162 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5163 |
self hasSelection ifFalse: [ ^ self ]. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5164 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5165 |
clickLine < oldClickLine ifTrue:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5166 |
newCursorCol := selectionStartCol. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5167 |
newCursorLine := selectionStartLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5168 |
] ifFalse:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5169 |
clickLine == oldClickLine ifTrue:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5170 |
clickCol < oldClickCol ifTrue:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5171 |
newCursorLine := selectionStartLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5172 |
newCursorCol := selectionStartCol. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5173 |
] ifFalse:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5174 |
clickCol == oldClickCol ifTrue:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5175 |
newCursorLine := selectionStartLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5176 |
newCursorCol := selectionStartCol. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5177 |
] ifFalse:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5178 |
newCursorLine := selectionEndLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5179 |
newCursorCol := selectionEndCol + 1 |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5180 |
] |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5181 |
] |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5182 |
] ifFalse:[ |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5183 |
newCursorLine := selectionEndLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5184 |
newCursorCol := selectionEndCol + 1. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5185 |
] |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5186 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5187 |
]. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5188 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5189 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5190 |
self setCursorCol: newCursorCol. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5191 |
self setCursorLine: newCursorLine. |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5192 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5193 |
"Created: / 28-08-2013 / 15:28:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5194 |
"Modified: / 28-08-2013 / 17:18:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5195 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
5196 |
|
4609 | 5197 |
getCompletionSuggestions |
5198 |
UserInformation ignoreIn:[ |
|
5199 |
DoWhatIMeanSupport |
|
5200 |
codeCompletionForClass:nil |
|
5201 |
context:nil |
|
5202 |
codeView:self |
|
5203 |
askWith:[:listOfSuggestions | ^ listOfSuggestions] |
|
5204 |
into:nil. |
|
5205 |
]. |
|
5206 |
^ nil |
|
5207 |
! |
|
5208 |
||
5209 |
handleCompletionService |
|
5210 |
^ self. |
|
5211 |
||
5212 |
"/ unfinished. |
|
4630 | 5213 |
"/ (self sensor hasKeyPressEventFor:nil) ifTrue:[ self closeCompletionView. ^ self]. |
5214 |
"/ |
|
5215 |
"/"/ ^ self. |
|
5216 |
"/ UserInformation ignoreIn:[ |
|
5217 |
"/ DoWhatIMeanSupport |
|
5218 |
"/ codeCompletionForMethod:self editedMethod |
|
5219 |
"/ orClass:self editedClass |
|
5220 |
"/ context:nil |
|
5221 |
"/ codeView:self |
|
5222 |
"/ into:[:listOfSuggestions :listOfActions | suggestions := listOfSuggestions. actions := listOfActions] |
|
5223 |
"/ ]. |
|
5224 |
"/Transcript showCR:suggestions. |
|
5225 |
"/Transcript showCR:actions. |
|
5226 |
"/ suggestions isEmptyOrNil ifTrue:[ |
|
5227 |
"/ self closeCompletionView. |
|
5228 |
"/ ^ self |
|
5229 |
"/ ]. |
|
5230 |
"/ |
|
5231 |
"/ pos := device translatePoint:(self xOfCursor @ self yOfCursor) fromView:self toView:nil. |
|
5232 |
"/ pos := pos + (20 @ (font height)). |
|
5233 |
"/ "/ suggestions := #( 'foo' 'bar' 'baz'). |
|
4609 | 5234 |
"/ |
4630 | 5235 |
"/ completionView isNil ifTrue:[ |
5236 |
"/ completionView := SelectionInListView new. |
|
5237 |
"/ topView := CodeCompletionHelpView with:completionView. |
|
5238 |
"/ topView origin:pos. |
|
5239 |
"/ topView open. |
|
5240 |
"/ ]. |
|
5241 |
"/ |
|
5242 |
"/ completionView list:suggestions. |
|
5243 |
"/ completionView extent:completionView preferredExtentForContents. |
|
5244 |
"/ completionView action: |
|
5245 |
"/ [:index | |
|
5246 |
"/ completionView notNil ifTrue:[ |
|
5247 |
"/ completionView topView destroy. |
|
5248 |
"/ completionView := nil |
|
5249 |
"/ ]. |
|
5250 |
"/ actions isBlock ifTrue:[ |
|
5251 |
"/ actions value:index |
|
5252 |
"/ ] ifFalse:[ |
|
5253 |
"/ (actions at:index) value |
|
5254 |
"/ ]. |
|
5255 |
"/ ]. |
|
5256 |
"/ |
|
5257 |
"/ completionView topView |
|
5258 |
"/ resizeToFit; |
|
5259 |
"/ origin:pos; |
|
5260 |
"/ raise. |
|
5261 |
"/ |
|
5262 |
"/"/ self halt. |
|
5263 |
"/"/ |
|
5264 |
"/"/ v origin:pos. |
|
5265 |
"/"/ v beUndecorated. |
|
5266 |
"/"/ v open. |
|
5267 |
"/ "/ Delay waitForSeconds:0.5. |
|
5268 |
"/ "/ v destroy. |
|
4609 | 5269 |
! |
5270 |
||
2952 | 5271 |
handleNonCommandKey:keyArg |
5272 |
|selStartLine selStartCol selEndLine selEndCol sel key| |
|
5273 |
||
5274 |
self isReadOnly ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5275 |
self flash. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5276 |
^ self. |
2952 | 5277 |
]. |
5278 |
||
5279 |
key := keyArg. |
|
5280 |
||
5281 |
typeOfSelection == #paste ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5282 |
"pasted selection will NOT be replaced by keystroke" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5283 |
self unselect |
2952 | 5284 |
]. |
5285 |
||
5286 |
selStartLine := selectionStartLine. |
|
5287 |
selStartCol := self selectionStartCol. |
|
5288 |
selEndLine := selectionEndLine. |
|
5289 |
selEndCol := self selectionEndCol. |
|
5290 |
sel := self selection. |
|
5291 |
||
4481 | 5292 |
(characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
5293 |
key isCharacter ifTrue:[ |
|
5294 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding. |
|
5295 |
] ifFalse:[ |
|
5296 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:characterEncoding. |
|
5297 |
]. |
|
2952 | 5298 |
]. |
5299 |
||
5300 |
"replace selection by what is typed in - |
|
3235 | 5301 |
if word was selected with a space, keep it. |
5302 |
if there was no selection, the keys character is inserted" |
|
5303 |
||
5304 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5305 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5306 |
]. |
2952 | 5307 |
|
5308 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5309 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5310 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5311 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5312 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5313 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5314 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5315 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5316 |
] |
3160 | 5317 |
]. |
2952 | 5318 |
selectStyle := nil. |
5319 |
||
3235 | 5320 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5321 |
selectionStartLine := selStartLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5322 |
selectionStartCol := selStartCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5323 |
selectionEndLine := selEndLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5324 |
selectionEndCol := selEndCol. |
3235 | 5325 |
]. |
5326 |
||
2952 | 5327 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5328 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5329 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5330 |
"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
|
5331 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5332 |
" |
2952 | 5333 |
" |
4481 | 5334 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5335 |
" |
4481 | 5336 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5337 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5338 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5339 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5340 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5341 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5342 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5343 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5344 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5345 |
self cursorLine:line col:col. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5346 |
device flush. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5347 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5348 |
"/ 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
|
5349 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5350 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5351 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5352 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5353 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5354 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5355 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5356 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5357 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5358 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5359 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5360 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5361 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5362 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5363 |
] |
2952 | 5364 |
]. |
5365 |
||
5366 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5367 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5368 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5369 |
"/ |
|
5370 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5371 |
"/ self selection. |
|
5372 |
"/ typeOfSelection := #paste. |
|
3160 | 5373 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5374 |
"/ ]. |
3235 | 5375 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5376 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5377 |
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
|
5378 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5379 |
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
|
5380 |
]. |
3235 | 5381 |
]. |
4609 | 5382 |
self handleCompletionService |
4360 | 5383 |
|
5384 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5385 |
! |
5386 |
||
5387 |
keyPress:key x:x y:y |
|
5388 |
"handle keyboard input" |
|
5389 |
||
5390 |
self undoableDo:[ |
|
4242 | 5391 |
self doKeyPress:key x:x y:y |
5392 |
]. |
|
5393 |
self repairDamage |
|
5394 |
||
5395 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
2952 | 5396 |
! |
5397 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5398 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5399 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5400 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5401 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5402 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5403 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5404 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5405 |
requestAutoAccept |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5406 |
"this is invoked when a dialog closes via accept or cancel. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5407 |
This forces my value to be accepted into my model" |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5408 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5409 |
acceptEnabled == false ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5410 |
"/ nope - |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5411 |
^ false |
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5412 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5413 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5414 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5415 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5416 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5417 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5418 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5419 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5420 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5421 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5422 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5423 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5424 |
cv notNil ifTrue:[ |
3160 | 5425 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5426 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5427 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5428 |
|
1807 | 5429 |
!EditTextView methodsFor:'focus handling'! |
5430 |
||
5431 |
hasKeyboardFocus:aBoolean |
|
5432 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5433 |
(otherwise, I would not know about this)" |
|
5434 |
||
5435 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5436 |
|
3160 | 5437 |
(cursorShown |
5438 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5439 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5440 |
self drawCursor |
5441 |
]. |
|
5442 |
||
5443 |
hasKeyboardFocus ifFalse:[ |
|
5444 |
self closeCompletionView |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5445 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5446 |
|
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5447 |
"Modified: / 23.3.1999 / 13:49:35 / cg" |
1807 | 5448 |
! |
5449 |
||
5450 |
showFocus:explicit |
|
5451 |
"in addition to however my superclass thinks how a focusView is to be |
|
5452 |
displayed, show the cursor when I got the focus" |
|
5453 |
||
5454 |
self showCursor. |
|
5455 |
self hasKeyboardFocus:true. |
|
5456 |
super showFocus:explicit |
|
5457 |
||
5458 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5459 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5460 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5461 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5462 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5463 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5464 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5465 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5466 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5467 |
and:[self enabled |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5468 |
and:[self isReadOnly not]]] |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5469 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5470 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5471 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5472 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5473 |
^ false |
1807 | 5474 |
! ! |
5475 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5476 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5477 |
|
4237 | 5478 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5479 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5480 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5481 |
|
4482 | 5482 |
|cmdMacro| |
5483 |
||
5484 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5485 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5486 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5487 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5488 |
^ true |
4238 | 5489 |
|
5490 |
" |
|
4483 | 5491 |
EditTextView open |
4238 | 5492 |
contents:'bla'; |
5493 |
selectAll; |
|
5494 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5495 |
EditTextView open |
4238 | 5496 |
contents:'bla'; |
5497 |
selectAll; |
|
5498 |
executekeyboardMacroNamed:#blabla. |
|
5499 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5500 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5501 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5502 |
! |
5503 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5504 |
indent |
3221 | 5505 |
"indent a line-range - this is done by searching for the |
5506 |
last non-empty line before the selection, and changing the indent |
|
5507 |
of the selected line-range based on that lines indent." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5508 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5509 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5511 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5512 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5513 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5514 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5515 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5516 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5517 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5518 |
self unselect. |
3160 | 5519 |
self |
3786 | 5520 |
undoableDo:[self indentFromLine:start toLine:end] |
5521 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5522 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5523 |
|
4237 | 5524 |
indentBy4 |
4238 | 5525 |
self executekeyboardMacroNamed:#IndentBy4 |
4237 | 5526 |
|
5527 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5528 |
! |
|
5529 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5530 |
indentFromLine:start toLine:end |
3221 | 5531 |
"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
|
5532 |
last non-empty line before start, and change the indent |
3221 | 5533 |
of the selected line-range based on that lines indent." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5534 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5535 |
|leftStart delta d line spaces| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5536 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5537 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5538 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5539 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5540 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5541 |
(delta == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5542 |
(delta > 0) ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5543 |
spaces := String new:delta |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5544 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5545 |
start to:end do:[:lineNr | |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5546 |
line := self listAt:lineNr. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5547 |
line notNil ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5548 |
line isBlank ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5549 |
list at:lineNr put:nil |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5550 |
] ifFalse:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5551 |
(delta > 0) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5552 |
line := spaces , line. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5553 |
widthOfWidestLine notNil ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5554 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5555 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5556 |
] ifFalse:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5557 |
"check if deletion is ok" |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5558 |
d := delta negated + 1. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5559 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5560 |
line size > d ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5561 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5562 |
line := line copyFrom:d |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5563 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5564 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5565 |
widthOfWidestLine := nil |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5566 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5567 |
self replaceLine:lineNr with:line. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5568 |
self textChanged. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5569 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5570 |
] |
3221 | 5571 |
]. |
5572 |
"/ self redrawFromLine:start to:end |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5573 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5574 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5575 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5576 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5577 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5578 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5579 |
this is done by searching for the last non-empty line before it |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5580 |
and returning its indent." |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5581 |
|
827 | 5582 |
"SHOULD GO TO ListView" |
5583 |
||
5584 |
|line lnr indent| |
|
5585 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5586 |
lnr := lineNr. |
827 | 5587 |
|
5588 |
[lnr ~~ 1] whileTrue:[ |
|
3160 | 5589 |
lnr := lnr - 1. |
5590 |
line := self listAt:lnr. |
|
5591 |
||
5592 |
line notNil ifTrue:[ |
|
5593 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5594 |
indent ~~ 0 ifTrue:[ |
|
5595 |
^ indent - 1 |
|
5596 |
] |
|
5597 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5598 |
]. |
827 | 5599 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5600 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5601 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5602 |
! |
5603 |
||
5604 |
undentBy4 |
|
4238 | 5605 |
self executekeyboardMacroNamed:#UndentBy4. |
4237 | 5606 |
|
5607 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
105 | 5608 |
! ! |
5609 |
||
0 | 5610 |
!EditTextView methodsFor:'initialization'! |
5611 |
||
941 | 5612 |
fetchDeviceResources |
5613 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5614 |
||
5615 |
super fetchDeviceResources. |
|
5616 |
||
1993 | 5617 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
5618 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
5619 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 5620 |
|
5621 |
"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
|
5622 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5623 |
! |
5624 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5625 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5626 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5628 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5629 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5631 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5633 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5635 |
super initStyle. |
4576 | 5636 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5638 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5639 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5640 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5641 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5642 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
1334 | 5643 |
cursorType := cursorTypeNoFocus := DefaultCursorType. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5644 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
4576 | 5645 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5646 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5647 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5648 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 5649 |
cursorType ~~ #block ifTrue:[ |
5650 |
cursorNoFocusFgColor := cursorBgColor |
|
5651 |
] ifFalse:[ |
|
5652 |
cursorNoFocusFgColor := cursorFgColor |
|
5653 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5654 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5655 |
|
2088 | 5656 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5657 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5658 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5659 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5660 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5661 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5662 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5663 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5664 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5665 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5666 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5667 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5668 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5669 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5670 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5671 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5672 |
cursorCol := 1. |
2815 | 5673 |
cursorLineHolder := 1 asValue. |
5674 |
cursorColHolder := 1 asValue. |
|
2119 | 5675 |
modifiedChannel := ValueHolder with:false. |
5676 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
5677 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5678 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5679 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5680 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5681 |
autoIndent := false. |
3235 | 5682 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5683 |
learnMode := false asValue. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5684 |
trimBlankLines := self st80EditMode not. |
2131 | 5685 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 5686 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
5687 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5688 |
"/ enable drop by default |
2589 | 5689 |
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
|
5690 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5691 |
undoSupport := UndoSupport for:self. |
0 | 5692 |
! ! |
5693 |
||
2580 | 5694 |
!EditTextView methodsFor:'macros'! |
5695 |
||
5696 |
executeLearnedKeyboardMacro |
|
4673 | 5697 |
"replay the characters as learned previously" |
5698 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5699 |
(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
|
5700 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5701 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5702 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5703 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5704 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5705 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5706 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5707 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5708 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5709 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5710 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5711 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5712 |
]. |
2580 | 5713 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5714 |
self flash. |
2580 | 5715 |
]. |
5716 |
! |
|
5717 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5718 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5719 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5720 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5721 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5722 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5723 |
|
2580 | 5724 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5725 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5726 |
|
2580 | 5727 |
|fg bg| |
5728 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5729 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5730 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5731 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5732 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5733 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5734 |
bg := Color black. |
2580 | 5735 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5736 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5737 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 5738 |
]. |
5739 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5740 |
! |
|
5741 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5742 |
learnModeHolder |
4673 | 5743 |
"a holder returning true, if in learn mode" |
5744 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5745 |
learnMode isNil ifTrue:[ |
4673 | 5746 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5747 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5748 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5749 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5750 |
|
4673 | 5751 |
rememberLearnedMacroAs: nameString |
5752 |
Macros isNil ifTrue:[ |
|
5753 |
Macros := Dictionary new. |
|
5754 |
]. |
|
5755 |
Macros at:nameString put:learnedMacro |
|
5756 |
! |
|
5757 |
||
2580 | 5758 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5759 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5760 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5761 |
self learnMode:(self learnMode not). |
2580 | 5762 |
! ! |
5763 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
5764 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 5765 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5766 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5767 |
"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
|
5768 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5769 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5770 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5771 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5772 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5773 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5774 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
5775 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 5776 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
5777 |
] do:[ |
|
5778 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5779 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5780 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5781 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5782 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5783 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5784 |
self unselect. |
3799 | 5785 |
self |
5786 |
undoablePaste:translated |
|
5787 |
info:'Translate' |
|
3495 | 5788 |
|
5789 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5790 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5791 |
|
3517 | 5792 |
compareWithClipboard |
5793 |
"compare the selection against the clipboard contents" |
|
5794 |
||
5795 |
|t1 t2| |
|
5796 |
||
5797 |
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
|
5798 |
t2 isEmptyOrNil ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5799 |
Dialog information:'Clipboard is empty.'. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5800 |
^ self. |
3517 | 5801 |
]. |
5802 |
||
5803 |
self hasSelection ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5804 |
t1 := self selectionAsString. |
3517 | 5805 |
] ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5806 |
t1 := self contents asString |
3517 | 5807 |
]. |
5808 |
t1 := t1 string. |
|
5809 |
||
5810 |
t1 = t2 ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5811 |
Dialog information:'Strings are equal.'. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5812 |
^ self. |
3517 | 5813 |
]. |
5814 |
DiffTextView |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5815 |
openOn:t1 label:'Editor' |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5816 |
and:t2 label:'Clipboard' |
3517 | 5817 |
! |
5818 |
||
121 | 5819 |
cut |
5820 |
"cut selection into copybuffer" |
|
5821 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5822 |
self deleteCopyToClipboard:true |
121 | 5823 |
! |
5824 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5825 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5826 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5827 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5828 |
cursorLine notNil ifTrue:[ |
3160 | 5829 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5830 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5831 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5832 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5833 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5834 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5835 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5836 |
|
4129 | 5837 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5838 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5839 |
(self checkModificationsAllowed) ifFalse:[ |
3786 | 5840 |
self flash. |
5841 |
^ self |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5842 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5843 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5844 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5845 |
sel notNil ifTrue:[ |
4129 | 5846 |
self setLastStringToReplace: sel. |
4053 | 5847 |
|
3786 | 5848 |
line := selectionStartLine. |
5849 |
col := selectionStartCol. |
|
5850 |
||
5851 |
toClipboard ifTrue:[ |
|
5852 |
" |
|
5853 |
remember in CopyBuffer |
|
5854 |
" |
|
5855 |
self setClipboardText:sel. "/ lastString. |
|
5856 |
]. |
|
5857 |
||
5858 |
" |
|
5859 |
append to DeleteHistory (if there is one) |
|
5860 |
" |
|
5861 |
history := Smalltalk at:#DeleteHistory. |
|
5862 |
history notNil ifTrue:[ |
|
5863 |
history addAll:(sel asStringCollection). |
|
5864 |
history size > 1000 ifTrue:[ |
|
5865 |
history := history copyFrom:(history size - 1000) |
|
5866 |
]. |
|
5867 |
]. |
|
5868 |
||
5869 |
" |
|
5870 |
now, delete it |
|
5871 |
" |
|
5872 |
self |
|
5873 |
undoableDo:[self deleteSelection] |
|
5874 |
info:'Delete'. |
|
4048 | 5875 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5876 |
] ifFalse:[ |
3786 | 5877 |
" |
5878 |
a cut without selection will search&cut again |
|
5879 |
" |
|
5880 |
self undoableDo:[ |
|
5881 |
self again |
|
5882 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5883 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5884 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5885 |
"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
|
5886 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5887 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5888 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5889 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
5890 |
|
3781 | 5891 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5892 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 5893 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 5894 |
#ToggleAutoIndent #ToggleInsertMode |
5895 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
5896 |
<resource: #programMenu> |
1054 | 5897 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5898 |
|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
|
5899 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 5900 |
|
2460 | 5901 |
items := #( |
3781 | 5902 |
('Redo' redo Redo ) |
5903 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 5904 |
('-' ) |
5905 |
('Search...' search Find ) |
|
5906 |
('Goto Line...' gotoLine GotoLine ) |
|
5907 |
('-' ) |
|
4213 | 5908 |
('Tools' tools ) ). |
5909 |
CharacterSetView notNil ifTrue:[ |
|
5910 |
items := items , |
|
5911 |
#( |
|
5912 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
5913 |
). |
|
5914 |
]. |
|
5915 |
items := items , #( |
|
3731 | 5916 |
('-' ) |
5917 |
('Save As...' save SaveAs ) |
|
5918 |
('Print' doPrint Print ) |
|
5919 |
('=' ) |
|
4213 | 5920 |
('Misc' misc ShiftCtrl) ). |
2460 | 5921 |
|
2866 | 5922 |
miscItems := #( |
3781 | 5923 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
5924 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 5925 |
('-' ) |
5926 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 5927 |
('Join Lines' joinLines Join ) |
4388 | 5928 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 5929 |
('-' ) |
3781 | 5930 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
5931 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 5932 |
('-' ) |
3811 | 5933 |
('Insert File...' insertFile ) |
5934 |
('Insert URL Contents...' insertURL ) |
|
3781 | 5935 |
('Insert new UUID' insertUUID ) |
5936 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 5937 |
('-' ) |
5938 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
5939 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 5940 |
('-' ) |
5941 |
). |
|
4213 | 5942 |
"/ CharacterSetView notNil ifTrue:[ |
5943 |
"/ miscItems := miscItems , |
|
5944 |
"/ #( |
|
5945 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
5946 |
"/ ). |
|
5947 |
"/ ]. |
|
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
5948 |
miscItems := miscItems , |
3731 | 5949 |
#( |
5950 |
('Font...' changeFont ) |
|
2870 | 5951 |
"/ ('Encoding...' changeEncoding ) |
3731 | 5952 |
). |
2866 | 5953 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5954 |
translateItems := #( |
3731 | 5955 |
('English -> German' (babelFishTranslate: 'en_de') ) |
5956 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
5957 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
5958 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
5959 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
5960 |
('-' ) |
|
5961 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
5962 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
5963 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
5964 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
5965 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
5966 |
). |
|
3221 | 5967 |
|
5968 |
sortItems := #( |
|
3731 | 5969 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
5970 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 5971 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
5972 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
5973 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 5974 |
('Words' (sortSelection:ignoreCase: #words false) ) |
5975 |
('-' ) |
|
4373 | 5976 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
5977 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
5978 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
5979 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
3731 | 5980 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5981 |
|
2762 | 5982 |
toolItems := #( |
3731 | 5983 |
('Indent' indent ) |
4287 | 5984 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 5985 |
('Sort' sort ) |
5986 |
('-' ) |
|
5987 |
('Google Spell' googleSpellingSuggestion ) |
|
5988 |
('Translate' babelFishTranslate ) |
|
5989 |
('Compare with Clipboard...' compareWithClipboard ) |
|
5990 |
). |
|
2762 | 5991 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5992 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 5993 |
toolItems := toolItems , #( |
5994 |
('-' ) |
|
5995 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
5996 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
5997 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5998 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
5999 |
|
2460 | 6000 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6001 |
sub receiver:self. |
2460 | 6002 |
|
2919 | 6003 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6004 |
toolSub receiver:self. |
|
6005 |
sub subMenuAt:#tools put:toolSub. |
|
6006 |
||
3495 | 6007 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6008 |
transSub receiver:self. |
|
6009 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6010 |
||
6011 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6012 |
sortSub receiver:self. |
|
6013 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6014 |
|
2866 | 6015 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6016 |
subSub receiver:self. |
|
2952 | 6017 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6018 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6019 |
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
|
6020 |
|
2866 | 6021 |
sub subMenuAt:#misc put:subSub. |
6022 |
||
3495 | 6023 |
mainItems := #( |
3731 | 6024 |
('Undo' undo Undo ) |
6025 |
('Again' again Again ) |
|
6026 |
('-' ) |
|
6027 |
('Cut' cut Cut ) |
|
6028 |
('Copy' copySelection Copy ) |
|
6029 |
('Paste' pasteOrReplace Paste ) |
|
6030 |
('-' ) |
|
6031 |
('Accept' accept Accept ) |
|
6032 |
('=' ) |
|
6033 |
('More' others Ctrl ) |
|
6034 |
). |
|
3495 | 6035 |
main := PopUpMenu itemList:mainItems resources:resources. |
6036 |
main subMenuAt:#others put:sub. |
|
6037 |
||
6038 |
sensor := self sensor. |
|
6039 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6040 |
sensor shiftDown ifTrue:[ |
|
3731 | 6041 |
m := subSub |
6042 |
] ifFalse:[ |
|
6043 |
m := sub |
|
6044 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6045 |
] ifFalse:[ |
3731 | 6046 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6047 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6048 |
|
4373 | 6049 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6050 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6051 |
m disable:#googleSpellingSuggestion |
|
2676 | 6052 |
]. |
6053 |
||
3811 | 6054 |
HTTPInterface isNil ifTrue:[ |
6055 |
m disableAll:#(insertURL) |
|
6056 |
]. |
|
6057 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6058 |
self isReadOnly ifTrue:[ |
4475 | 6059 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6060 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6061 |
cut indent autoIndent: insertMode: |
|
3811 | 6062 |
insertFile insertFileAsStringLiteral insertURL |
6063 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6064 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
3731 | 6065 |
joinLines insertUUID insertDateAndTime pasteAsStringLiteral |
6066 |
specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6067 |
]. |
2817 | 6068 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6069 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6070 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6071 |
self hasSelection ifFalse:[ |
3731 | 6072 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt openWorkspaceWithIt sort indent). |
2762 | 6073 |
] ifTrue:[ |
3731 | 6074 |
(Error handle:[:ex | |
6075 |
ex return:false |
|
6076 |
] do:[ |
|
4042 | 6077 |
|fn| |
6078 |
fn := self selectionAsString. |
|
6079 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6080 |
]) ifFalse:[ |
6081 |
m disableAll:#(openFileBrowserOnIt). |
|
6082 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6083 |
]. |
2569 | 6084 |
self hasUndoAction ifFalse:[ |
3731 | 6085 |
m disable:#undo. |
3115 | 6086 |
] ifTrue:[ |
3731 | 6087 |
what := undoSupport undoActionInfo. |
6088 |
what notNil ifTrue:[ |
|
6089 |
undoIdx := m indexOf:#undo. |
|
6090 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6091 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6092 |
]. |
2952 | 6093 |
self hasRedoAction ifFalse:[ |
3731 | 6094 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6095 |
] ifTrue:[ |
3731 | 6096 |
what := undoSupport redoActionInfo. |
6097 |
what notNil ifTrue:[ |
|
6098 |
redoIdx := sub indexOf:#redo. |
|
6099 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6100 |
] |
|
2952 | 6101 |
]. |
1108 | 6102 |
acceptEnabled == false ifTrue:[ |
3731 | 6103 |
m disable:#accept |
1108 | 6104 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6105 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6106 |
|
4388 | 6107 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6108 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6109 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6110 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6111 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6112 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6113 |
history := device getCopyBufferHistory copy. |
3160 | 6114 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6115 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6116 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6117 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6118 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6119 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6120 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6121 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6122 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6123 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6124 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6125 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6126 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6127 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6128 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6129 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6130 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6131 |
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
|
6132 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6133 |
box show. |
3160 | 6134 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6135 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6136 |
"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
|
6137 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6138 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6139 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6140 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6141 |
self sensor shiftDown ifTrue:[ |
3855 | 6142 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6143 |
]. |
2724 | 6144 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6145 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6146 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6147 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6148 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6149 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6150 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6151 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6152 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6153 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6154 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6155 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6156 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6157 |
"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
|
6158 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6159 |
|
2676 | 6160 |
googleSpellingSuggestion |
6161 |
"insert the google-spelling suggestion for the selected text. |
|
6162 |
Requires that the SOAP stuff is loaded and working." |
|
6163 |
||
2677 | 6164 |
|text suggestion| |
2676 | 6165 |
|
6166 |
self withWaitCursorDo:[ |
|
3799 | 6167 |
text := self selection asString string withoutSeparators. |
6168 |
text size == 0 ifTrue:[^ self]. |
|
6169 |
||
6170 |
SOAP::SoapImplError handle:[:ex | |
|
6171 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
6172 |
^ self. |
|
6173 |
] do:[ |
|
6174 |
suggestion := SOAP::GoogleClient new spellingSuggestionOf:text. |
|
6175 |
]. |
|
6176 |
suggestion size == 0 ifTrue:[ |
|
6177 |
Transcript showCR:'No SpellingSuggestion from Google for: ' , text. |
|
6178 |
^ self. |
|
6179 |
]. |
|
6180 |
]. |
|
6181 |
self |
|
6182 |
undoablePaste:suggestion |
|
6183 |
info:'Spelling Suggestion'. |
|
3495 | 6184 |
|
6185 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6186 |
! |
6187 |
||
3595 | 6188 |
insertDateAndTime |
6189 |
"insert the curent date and time string" |
|
6190 |
||
6191 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6192 |
self |
3786 | 6193 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6194 |
info:'Paste Date and Time' |
3595 | 6195 |
! |
6196 |
||
2676 | 6197 |
insertFile |
3160 | 6198 |
"insert contents of a file |
2676 | 6199 |
- ask user for filename using a fileSelectionBox." |
6200 |
||
3731 | 6201 |
self insertFileAsStringLiteral:false |
6202 |
! |
|
6203 |
||
6204 |
insertFileAsStringLiteral |
|
6205 |
"insert a file's contents as a string literal. |
|
6206 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6207 |
to make it a legal string literal" |
|
6208 |
||
6209 |
self insertFileAsStringLiteral:true |
|
6210 |
! |
|
6211 |
||
6212 |
insertFileAsStringLiteral:asStringLiteral |
|
6213 |
"insert contents of a file; either as-is or as a string literal. |
|
6214 |
- ask user for filename using a fileSelectionBox." |
|
6215 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6216 |
|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
|
6217 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6218 |
((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
|
6219 |
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
|
6220 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6221 |
ifTrue:[ |
3731 | 6222 |
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
|
6223 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6224 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6225 |
[ |
3731 | 6226 |
|why| |
6227 |
||
6228 |
file := Dialog |
|
6229 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6230 |
default:initial |
|
6231 |
ok:(resources string:'Insert') |
|
6232 |
abort:(resources string:'Cancel') |
|
6233 |
pattern:nil |
|
6234 |
fromDirectory:directoryForFileDialog. |
|
6235 |
file isNil ifTrue:[ |
|
6236 |
"cancel" |
|
6237 |
^ self. |
|
6238 |
]. |
|
6239 |
file := file asFilename. |
|
6240 |
directoryForFileDialog := file. |
|
6241 |
||
6242 |
ok := file isReadable and:[file isDirectory not]. |
|
6243 |
ok ifFalse:[ |
|
6244 |
file isReadable ifFalse:[ |
|
6245 |
why := '%1 is unreadable.\\Please try again.' |
|
6246 |
] ifTrue:[ |
|
6247 |
why := '%1 is a directory.\\Please try again.' |
|
6248 |
]. |
|
6249 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6250 |
]. |
|
2909 | 6251 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6252 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6253 |
text := file contentsOfEntireFile. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6254 |
self |
3786 | 6255 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6256 |
info:'Paste File' |
3495 | 6257 |
|
6258 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6259 |
! |
|
6260 |
||
3811 | 6261 |
insertURL |
6262 |
"insert contents of a URL |
|
6263 |
- ask user for URL using a dialog." |
|
6264 |
||
6265 |
self insertURLAsStringLiteral:false |
|
6266 |
! |
|
6267 |
||
6268 |
insertURLAsStringLiteral:asStringLiteral |
|
6269 |
"insert contents of a file; either as-is or as a string literal. |
|
6270 |
- ask user for filename using a fileSelectionBox." |
|
6271 |
||
6272 |
|sel url text response initial| |
|
6273 |
||
6274 |
(sel := self selectionAsString) notEmptyOrNil |
|
6275 |
ifTrue:[ |
|
6276 |
initial := sel. |
|
6277 |
]. |
|
6278 |
||
6279 |
url := Dialog |
|
6280 |
request:(resources string:'Insert Contents of URL:') |
|
6281 |
initialAnswer:initial |
|
6282 |
okLabel:(resources string:'Insert') |
|
6283 |
title:(resources string:'URL'). |
|
6284 |
url isNil ifTrue:[ |
|
6285 |
"cancel" |
|
6286 |
^ self. |
|
6287 |
]. |
|
6288 |
response := HTTPInterface get:url. |
|
6289 |
response isErrorResponse ifTrue:[ |
|
6290 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6291 |
^ self. |
|
6292 |
]. |
|
6293 |
text := response data asString. |
|
6294 |
||
6295 |
self |
|
6296 |
undoableDo:[ |
|
6297 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6298 |
] |
|
6299 |
info:'Insert Contents of URL' |
|
6300 |
! |
|
6301 |
||
3495 | 6302 |
insertUUID |
6303 |
"insert a new UUID's string" |
|
6304 |
||
6305 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6306 |
self |
3786 | 6307 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6308 |
info:'Paste New UUID' |
3495 | 6309 |
|
6310 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6311 |
! |
6312 |
||
2762 | 6313 |
openFileBrowserOnIt |
6314 |
"open a fileBrowser on the selected fileName" |
|
6315 |
||
4630 | 6316 |
|fn| |
2762 | 6317 |
|
6318 |
fn := self selectionAsString asFilename. |
|
6319 |
fn exists ifFalse:[ |
|
4042 | 6320 |
fn := self selectionAsString withoutSeparators withoutQuotes asFilename. |
6321 |
fn exists ifFalse:[ |
|
6322 |
^ self warn:'Oops - file is gone'. |
|
6323 |
]. |
|
2762 | 6324 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6325 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6326 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6327 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6328 |
! |
6329 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6330 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6331 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6332 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6333 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6334 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6335 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6336 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6337 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6338 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6339 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6340 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6341 |
paste |
1289 | 6342 |
"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
|
6343 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6344 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6345 |
self checkModificationsAllowed ifTrue:[ |
3160 | 6346 |
self withSelfAndTextForPasteDo:[:me :text | |
6347 |
me unselect. |
|
6348 |
me undoablePaste:text |
|
6349 |
] |
|
2952 | 6350 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6351 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6352 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6353 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6354 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6355 |
|
3825 | 6356 |
self paste:someText withCR:false |
6357 |
! |
|
6358 |
||
6359 |
paste:someText withCR:withCR |
|
6360 |
"paste someText at cursor" |
|
6361 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6362 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6363 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6364 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6365 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6366 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6367 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6368 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6369 |
CharacterEncoderError handle:[:ex | |
3825 | 6370 |
|code msg| |
6371 |
||
6372 |
code := ex parameter. |
|
6373 |
codingErrorReported ifFalse:[ |
|
6374 |
msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'. |
|
6375 |
code notNil ifTrue:[ |
|
6376 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6377 |
]. |
|
6378 |
Dialog warn:(resources stringWithCRs:msg). |
|
6379 |
codingErrorReported := true. |
|
6380 |
]. |
|
6381 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6382 |
] do:[ |
3825 | 6383 |
s isString ifTrue:[ |
6384 |
s encoding ~~ characterEncoding ifTrue:[ |
|
6385 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
6386 |
]. |
|
6387 |
||
6388 |
s := s asStringCollection. |
|
6389 |
(someText endsWith:Character cr) ifTrue:[ |
|
6390 |
"/ s := s copyWith:nil. |
|
6391 |
s := s copyWith:'' "/ an empty line at the end |
|
6392 |
||
6393 |
] |
|
6394 |
] ifFalse:[ |
|
6395 |
s isStringCollection ifTrue:[ |
|
6396 |
s := s encodeFrom:(s encoding) into:characterEncoding. |
|
6397 |
] ifFalse:[ |
|
6398 |
(self |
|
6399 |
confirm:(resources |
|
6400 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6401 |
with:s class name)) ifFalse:[^ self]. |
|
6402 |
s := StringCollection with:s storeString . |
|
6403 |
"/ ^ self |
|
6404 |
]. |
|
6405 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6406 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6407 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6408 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6409 |
(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
|
6410 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6411 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6412 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6413 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6414 |
startCol := c1 := cursorCol. |
3180 | 6415 |
|
4328 | 6416 |
"do not expand tabs into spaces here - |
3180 | 6417 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
6418 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6419 |
||
3825 | 6420 |
self insertLines:s withCR:withCR. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6421 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6422 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6423 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6424 |
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
|
6425 |
"/ 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
|
6426 |
"/ 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
|
6427 |
"/ 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
|
6428 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
6429 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6430 |
|
4328 | 6431 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6432 |
"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
|
6433 |
"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
|
6434 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6435 |
|
3731 | 6436 |
pasteAsStringLiteral |
6437 |
"insert clipboard string as a string literal. |
|
6438 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6439 |
to make it a legal string literal" |
|
6440 |
||
6441 |
typeOfSelection := nil. |
|
6442 |
self |
|
3786 | 6443 |
undoableDo:[ self pasteOrReplace:(self getClipboardText storeString) ] |
6444 |
info:'Paste as String Literal' |
|
3731 | 6445 |
! |
6446 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6447 |
pasteOrReplace |
1289 | 6448 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6449 |
otherwise paste at cursor position. |
6450 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6451 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6452 |
|
2724 | 6453 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6454 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6455 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6456 |
pasteOrReplace:someText |
1289 | 6457 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6458 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6459 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6460 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6461 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6462 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6463 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6464 |
self undoableDo:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6465 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6466 |
self replace:someText |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6467 |
] ifFalse:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6468 |
self paste:someText. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6469 |
] |
3542 | 6470 |
] info:'Paste/Replace'. |
1289 | 6471 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6472 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6473 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6474 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6475 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6476 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6477 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6478 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6479 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6480 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6481 |
self checkModificationsAllowed ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6482 |
self flash. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6483 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6484 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6485 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6486 |
text notNil ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6487 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6488 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6489 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6490 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6491 |
replace |
1289 | 6492 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6493 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6494 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6495 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6496 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6497 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 6498 |
me undoableDo:[ me replace:text ] |
6499 |
info:'Replace' |
|
2952 | 6500 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6501 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6502 |
|
121 | 6503 |
replace:someText |
1289 | 6504 |
"replace the selection by someText" |
121 | 6505 |
|
3160 | 6506 |
|selected selectedString |
6507 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 6508 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6509 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6510 |
|
3130 | 6511 |
self undoableDo:[ |
4010 | 6512 |
selected := self selection. |
6513 |
selected isNil ifTrue:[ |
|
6514 |
^ self paste:someText |
|
6515 |
]. |
|
6516 |
||
6517 |
self deleteSelection. |
|
6518 |
||
6519 |
"take care, if we replace a selection without space by a word selected |
|
6520 |
with one - in this case we usually do not want the space. |
|
6521 |
But, if we replace a word-selected selection by something without a |
|
6522 |
space, we DO want the space added." |
|
6523 |
||
6524 |
selected size == 1 ifTrue:[ |
|
6525 |
selectedString := selected at:1. |
|
6526 |
]. |
|
6527 |
||
6528 |
someText size == 1 ifTrue:[ |
|
6529 |
|cutOffSpace addSpace replacement replacementString| |
|
6530 |
||
6531 |
cutOffSpace := false. |
|
6532 |
addSpace := false. |
|
6533 |
replacement := someText copyFrom:1. |
|
6534 |
||
6535 |
selectedString notNil ifTrue:[ |
|
6536 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
6537 |
"selection has no space" |
|
6538 |
||
6539 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
6540 |
cutOffSpace := true |
|
6541 |
] |
|
6542 |
] ifTrue:[ |
|
6543 |
addSpace := true |
|
6544 |
] |
|
6545 |
]. |
|
6546 |
replacementString := replacement at:1. |
|
6547 |
cutOffSpace ifTrue:[ |
|
6548 |
(replacementString startsWith:' ') ifTrue:[ |
|
6549 |
replacementString := replacementString withoutSpaces |
|
6550 |
]. |
|
6551 |
] ifFalse:[ |
|
6552 |
selectStyle == #wordLeft ifTrue:[ |
|
6553 |
"want a space at left" |
|
6554 |
(replacementString startsWith:' ') ifFalse:[ |
|
6555 |
replacementString := replacementString withoutSpaces. |
|
6556 |
replacementString := ' ' , replacementString |
|
6557 |
] |
|
6558 |
]. |
|
6559 |
selectStyle == #wordRight ifTrue:[ |
|
6560 |
"want a space at right" |
|
6561 |
||
6562 |
(replacementString endsWith:' ') ifFalse:[ |
|
6563 |
replacementString := replacementString withoutSpaces. |
|
6564 |
replacementString := replacementString , ' ' |
|
6565 |
] |
|
6566 |
]. |
|
6567 |
]. |
|
6568 |
replacement at:1 put: replacementString. |
|
6569 |
self paste:replacement. |
|
6570 |
] ifFalse:[ |
|
6571 |
self paste:someText |
|
6572 |
]. |
|
4053 | 6573 |
self setLastStringToReplace: selectedString. |
6574 |
||
4048 | 6575 |
lastReplacementInfo lastReplacement: someText. |
4010 | 6576 |
|
6577 |
selStartLine := selectionStartLine. |
|
6578 |
selStartCol := self selectionStartCol. |
|
6579 |
selEndLine := selectionEndLine. |
|
6580 |
selEndCol := self selectionEndCol. |
|
3130 | 6581 |
] |
3542 | 6582 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
6583 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6584 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6585 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 6586 |
! |
6587 |
||
3430 | 6588 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6589 |
"search for a string - show a box to enter searchpattern |
3430 | 6590 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
6591 |
- 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
|
6592 |
|
3430 | 6593 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
6594 |
||
6595 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
6596 |
lastSearchDirection := #forward. |
|
6597 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
6598 |
caseHolder := ign asValue. |
|
6599 |
patternHolder := '' asValue. |
|
6600 |
replacePatternHolder := '' asValue. |
|
6601 |
lastSearchPattern notNil ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6602 |
initialString := lastSearchPattern |
3430 | 6603 |
]. |
6604 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6605 |
initialString := self selectionAsString |
3430 | 6606 |
]. |
6607 |
initialString isNil ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6608 |
LastSearchPatterns size > 0 ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6609 |
initialString := LastSearchPatterns first |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6610 |
] |
3430 | 6611 |
]. |
6612 |
initialString notNil ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6613 |
patternHolder value:initialString. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6614 |
replacePatternHolder value:initialString. |
3430 | 6615 |
]. |
6616 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6617 |
search := [:fwd | |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6618 |
self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6619 |
search:patternHolder value |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6620 |
ignoreCase:caseHolder value |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6621 |
forward:fwd. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6622 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6623 |
replace := [:all | |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6624 |
self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6625 |
replace:patternHolder value |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6626 |
by:replacePatternHolder value |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6627 |
all:all |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6628 |
ignoreCase:caseHolder value |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6629 |
]. |
3430 | 6630 |
bindings := IdentityDictionary new. |
6631 |
bindings at:#searchPattern put:patternHolder. |
|
6632 |
bindings at:#replacePattern put:replacePatternHolder. |
|
6633 |
modal ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6634 |
bindings at:#nextAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6635 |
put:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6636 |
flag := true. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6637 |
action := search. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6638 |
searchBox doAccept. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6639 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6640 |
bindings at:#prevAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6641 |
put:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6642 |
flag := false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6643 |
action := search. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6644 |
searchBox doAccept. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6645 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6646 |
bindings at:#replaceAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6647 |
put:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6648 |
flag := false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6649 |
action := replace. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6650 |
searchBox doAccept. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6651 |
]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6652 |
bindings at:#replaceAllAction |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6653 |
put:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6654 |
flag := true. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6655 |
action := replace. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6656 |
searchBox doAccept. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6657 |
]. |
3430 | 6658 |
] ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6659 |
bindings at:#nextAction put:[ search value:true. ]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6660 |
bindings at:#prevAction put:[ search value:false. ]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6661 |
bindings at:#replaceAction put:[ replace value:false. ]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6662 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
3430 | 6663 |
]. |
6664 |
bindings at:#ignoreCase put:caseHolder. |
|
6665 |
bindings at:#patternList put:LastSearchPatterns. |
|
6666 |
modal ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6667 |
searchBox := SimpleDialog new. |
3430 | 6668 |
] ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6669 |
searchBox := ApplicationModel new. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6670 |
searchBox createBuilder. |
3430 | 6671 |
]. |
6672 |
searchBox resources:(self resources). |
|
6673 |
bldr := searchBox builder. |
|
6674 |
bldr addBindings:bindings. |
|
6675 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
6676 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
6677 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
6678 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
6679 |
modal ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6680 |
searchBox openDialog. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6681 |
searchBox accepted ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6682 |
action value:flag |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6683 |
]. |
3430 | 6684 |
] ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6685 |
(bldr componentAt:#nextButton) isReturnButton:false. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6686 |
(bldr componentAt:#cancelButton) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6687 |
label:(resources string:'Close'); |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6688 |
action:[ searchBox closeRequest ]. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6689 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6690 |
"/ searchBox masterApplication:self application. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6691 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6692 |
self topView beMaster. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6693 |
(searchBox window) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6694 |
beSlave; |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6695 |
openInGroup:(self windowGroup). |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6696 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6697 |
"/ searchBox window open. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6698 |
|
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6699 |
searchBox window assignKeyboardFocusToFirstInputField. |
3430 | 6700 |
] |
6701 |
||
6702 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6703 |
! |
|
6704 |
||
121 | 6705 |
showDeleted |
6706 |
"open a readonly editor on all deleted text" |
|
6707 |
||
6708 |
|v| |
|
6709 |
||
6710 |
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
|
6711 |
v readOnly:true. |
121 | 6712 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6713 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6714 |
|
3221 | 6715 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
6716 |
"sort the selected lines" |
|
6717 |
||
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6718 |
|lines extractor innerExtractor fetcher lineWise nStr n s words| |
3221 | 6719 |
|
6720 |
lineWise := true. |
|
6721 |
||
6722 |
how == #lines ifTrue:[ |
|
4373 | 6723 |
extractor := [:l | l withoutLeadingSeparators]. |
6724 |
] ifFalse:[ |
|
6725 |
how == #linesByFirstWord ifTrue:[ |
|
6726 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
6727 |
] ifFalse:[ |
|
6728 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
6729 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
6730 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
6731 |
n := Integer readFrom:nStr onError:[^ self]. |
|
6732 |
LastColumnNumberForSort := n. |
|
6733 |
extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')]. |
|
6734 |
how == #linesByNthNumber ifTrue:[ |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6735 |
innerExtractor := extractor. |
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6736 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
4373 | 6737 |
] ifFalse:[ |
6738 |
how == #linesByNthHexNumber ifTrue:[ |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6739 |
innerExtractor := extractor. |
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6740 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) radix:16 onError:0] |
4373 | 6741 |
] |
6742 |
]. |
|
6743 |
] ifFalse:[ |
|
6744 |
how == #words ifTrue:[ |
|
6745 |
lineWise := false. |
|
6746 |
extractor := [:w | w]. |
|
6747 |
] ifFalse:[ |
|
6748 |
self error:'unknown sort criteria: ', how printString. |
|
6749 |
] |
|
6750 |
] |
|
6751 |
] |
|
6752 |
]. |
|
3221 | 6753 |
|
6754 |
ignoreCase ifTrue:[ |
|
4373 | 6755 |
fetcher := [:l | (extractor value:l) asLowercase]. |
3221 | 6756 |
] ifFalse:[ |
4373 | 6757 |
fetcher := extractor. |
3221 | 6758 |
]. |
6759 |
||
6760 |
lineWise ifTrue:[ |
|
4373 | 6761 |
start == end ifTrue:[^ self ]. |
6762 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
6763 |
lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)]. |
|
6764 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
6765 |
self textChanged. |
|
6766 |
^ self. |
|
3221 | 6767 |
]. |
6768 |
||
6769 |
s := self selectionAsString. |
|
6770 |
words := s asCollectionOfWords. |
|
6771 |
words := words sort:[:w1 :w2 | (fetcher value:w1) < (fetcher value:w2)]. |
|
6772 |
s := words asStringCollection asStringWith:Character space. |
|
6773 |
self replace:s. |
|
6774 |
self textChanged. |
|
4373 | 6775 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
6776 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 6777 |
! |
6778 |
||
6779 |
sortSelection:how ignoreCase:ignoreCase |
|
6780 |
"sort the selected lines" |
|
6781 |
||
6782 |
|start end| |
|
6783 |
||
6784 |
selectionStartLine isNil ifTrue:[^ self]. |
|
6785 |
||
6786 |
start := selectionStartLine. |
|
6787 |
end := selectionEndLine. |
|
6788 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 6789 |
end := end - 1 |
3221 | 6790 |
]. |
6791 |
||
6792 |
self |
|
4373 | 6793 |
undoableDo:[ |
6794 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
6795 |
] |
|
3786 | 6796 |
info:'Sort' |
4373 | 6797 |
|
6798 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 6799 |
! |
6800 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6801 |
specialCharacters |
2915 | 6802 |
CharacterSetView |
3160 | 6803 |
openAsInputFor:self |
6804 |
label:'Special Character Input' |
|
6805 |
clickLabel:'Click to Insert Character'. |
|
2866 | 6806 |
! |
6807 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6808 |
undoablePaste:someText |
3495 | 6809 |
self undoablePaste:someText info:nil. |
6810 |
||
6811 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
6812 |
! |
|
6813 |
||
6814 |
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
|
6815 |
self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6816 |
undoableDo:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6817 |
self paste:someText. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6818 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6819 |
info:infoOrNil |
3495 | 6820 |
|
6821 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
6822 |
! |
|
6823 |
||
6824 |
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
|
6825 |
self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6826 |
undoableDo:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6827 |
self pasteOrReplace:someText. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6828 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6829 |
info:infoOrNil |
3495 | 6830 |
|
6831 |
"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
|
6832 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6833 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6834 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6835 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6836 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6837 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6838 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6839 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6840 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6841 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6842 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6843 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
6844 |
|
2724 | 6845 |
withSelfAndTextForPasteDo:aBlock |
6846 |
"common code for paste/replace of the copybuffer" |
|
6847 |
||
6848 |
|sel| |
|
6849 |
||
6850 |
self checkModificationsAllowed ifFalse:[ |
|
3160 | 6851 |
self flash. |
6852 |
^ self |
|
2724 | 6853 |
]. |
6854 |
||
6855 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
6856 |
sel notNil ifTrue:[ |
|
3160 | 6857 |
aBlock value:self value:sel. |
2724 | 6858 |
] |
105 | 6859 |
! ! |
6860 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6861 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6862 |
|
3880 | 6863 |
beep |
6864 |
UserPreferences current beepInEditor ifTrue:[ |
|
6865 |
super beep |
|
6866 |
] |
|
6867 |
! |
|
6868 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6869 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6870 |
"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
|
6871 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6872 |
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
|
6873 |
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
|
6874 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6875 |
self isReadOnly ifTrue: [ |
3160 | 6876 |
exceptionBlock isNil ifTrue:[ |
6877 |
^ false |
|
6878 |
]. |
|
6879 |
||
6880 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
6881 |
^ false |
|
6882 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6883 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6884 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
6885 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
6886 |
"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
|
6887 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
6888 |
|
2596 | 6889 |
currentSelectionBgColor |
6890 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 6891 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 6892 |
]. |
6893 |
^ super currentSelectionBgColor |
|
6894 |
||
6895 |
" |
|
6896 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
6897 |
" |
|
6898 |
! |
|
6899 |
||
6900 |
currentSelectionFgColor |
|
6901 |
typeOfSelection == #paste ifTrue:[ |
|
3160 | 6902 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 6903 |
]. |
6904 |
^ super currentSelectionFgColor |
|
6905 |
! |
|
6906 |
||
3996 | 6907 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
6908 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 6909 |
|
6910 |
super resetVariablesBeforeNewSearch. |
|
6911 |
||
6912 |
"/ new search invalidates remembered string |
|
4048 | 6913 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
6914 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
6915 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 6916 |
! |
6917 |
||
4053 | 6918 |
setLastStringToReplace: aString |
6919 |
||
6920 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
6921 |
||
6922 |
|lastReplaceIgnoredCase| |
|
6923 |
||
4064 | 6924 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
6925 |
self clearSearchAction. |
|
6926 |
||
4053 | 6927 |
lastReplacementInfo lastStringToReplace: aString. |
6928 |
lastStringFromReplaceForNextSearch := aString. |
|
6929 |
||
6930 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 6931 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
6932 |
ifTrue: [lastSearchIgnoredCase] |
|
6933 |
ifFalse: [nil]. |
|
4053 | 6934 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
6935 |
! |
|
6936 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6937 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6938 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6939 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
6940 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6941 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6942 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6943 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6944 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6945 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
6946 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6947 |
textChanged |
522 | 6948 |
"my text was modified (internally). |
6949 |
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
|
6950 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 6951 |
is used to notify scrollers, other views etc.). |
6952 |
||
6953 |
As some authors of this code have been very sloppy in tha past |
|
6954 |
(not sending contentsChanged, but textChanged), |
|
6955 |
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
|
6956 |
|
641 | 6957 |
self contentsChanged. |
1015 | 6958 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6959 |
contentsWasSaved := false |
641 | 6960 |
|
1015 | 6961 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 6962 |
! |
6963 |
||
2617 | 6964 |
textChangedButNoSizeChange |
2207 | 6965 |
"my text was modified (internally). |
6966 |
Sent whenever text has been edited (not to confuse with |
|
6967 |
contentsChanged, which is triggered when the size has changed, and |
|
6968 |
is used to notify scrollers, other views etc.)" |
|
6969 |
||
6970 |
self modified:true. |
|
6971 |
contentsWasSaved := false |
|
6972 |
||
6973 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6974 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6976 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6977 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6978 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6979 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6980 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6981 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6982 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6983 |
"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
|
6984 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
6985 |
|
4064 | 6986 |
hasSearchActionSelection |
6987 |
||
6988 |
^ typeOfSelection == #searchAction |
|
6989 |
! |
|
6990 |
||
1878 | 6991 |
isKeyboardConsumer |
6992 |
"return true, if the receiver is a keyboard consumer; |
|
6993 |
Return true here, redefined from SimpleView." |
|
6994 |
||
3476 | 6995 |
^ self isReadOnly not |
1878 | 6996 |
! |
6997 |
||
997 | 6998 |
specClass |
1390 | 6999 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7000 |
||
997 | 7001 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7002 |
^ super specClass |
7003 |
||
1390 | 7004 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7005 |
! |
7006 |
||
324 | 7007 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7008 |
"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
|
7009 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7010 |
"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
|
7011 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7012 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7013 |
|
7014 |
"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
|
7015 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7016 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7017 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7018 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7019 |
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
|
7020 |
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
|
7021 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7022 |
|
697 | 7023 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7024 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7025 |
w := super widthOfContents. |
697 | 7026 |
(dev := device) isNil ifTrue:[ |
3160 | 7027 |
"/ really dont know ... |
7028 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7029 |
]. |
697 | 7030 |
^ w + (font widthOn:dev) |
7031 |
||
7032 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7033 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7034 |
|
1588 | 7035 |
!EditTextView methodsFor:'realization'! |
7036 |
||
7037 |
realize |
|
7038 |
"make the view visible - scroll to make the cursor visible." |
|
7039 |
||
7040 |
super realize. |
|
7041 |
||
7042 |
self makeCursorVisible. |
|
1993 | 7043 |
cursorFgColor := cursorFgColor onDevice:device. |
7044 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7045 |
|
7046 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7047 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7048 |
! ! |
|
7049 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7050 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7051 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7052 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7053 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7054 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7055 |
cursorShown ifTrue:[ |
3160 | 7056 |
cursorVisibleLine notNil ifTrue:[ |
7057 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7058 |
self drawCursorCharacter |
|
7059 |
] |
|
7060 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7061 |
] |
105 | 7062 |
! |
7063 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7064 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7065 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7066 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7067 |
cursorShown ifTrue:[ |
3160 | 7068 |
(visLine == cursorVisibleLine) ifTrue:[ |
7069 |
self drawCursorCharacter |
|
7070 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7071 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7072 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7073 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7074 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7075 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7076 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7077 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7078 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7079 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7080 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7081 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7082 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7083 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7084 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7085 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7086 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7087 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7088 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7089 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7090 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7091 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7092 |
cursorShown ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7093 |
(visLine == cursorVisibleLine) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7094 |
(colNr == cursorCol) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7095 |
self drawCursorCharacter. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7096 |
^ self |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7097 |
] |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7098 |
] |
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7099 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7100 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7101 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7102 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7103 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7104 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7105 |
"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
|
7106 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7107 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7108 |
cursorShown ifTrue:[ |
7109 |
self redrawCursorIfInVisibleLine:visLine |
|
7110 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7111 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7112 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7113 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7114 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7116 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7117 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7118 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7119 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7120 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7121 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7122 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7123 |
"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
|
7124 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7125 |
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
|
7126 |
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
|
7127 |
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
|
7128 |
|
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7129 |
^ 10 max:font width |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7130 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7131 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7132 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7133 |
"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
|
7134 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7135 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7136 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7137 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7138 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7139 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7140 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7141 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7142 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7143 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7144 |
"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
|
7145 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7146 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7147 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7148 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7149 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7150 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7151 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7152 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7153 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7154 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7155 |
"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
|
7156 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7157 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7158 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7159 |
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
|
7160 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7161 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7162 |
prevCursorState ifTrue:[ |
3160 | 7163 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7164 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7165 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7166 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7167 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7168 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7169 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7170 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7171 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7172 |
prevCursorState := cursorShown. |
1601 | 7173 |
"/ cursorShown := false. |
1591 | 7174 |
cursorShown ifTrue:[ |
3160 | 7175 |
self hideCursor |
1591 | 7176 |
] |
7177 |
||
1601 | 7178 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7179 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7180 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7181 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7182 |
"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
|
7183 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7185 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7186 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7187 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7188 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7189 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7190 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7191 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7192 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7193 |
"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
|
7194 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7195 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7196 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7197 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7198 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7199 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7200 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7201 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7202 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7203 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7204 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7205 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7206 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7207 |
|
2822 | 7208 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7209 |
! |
7210 |
||
7211 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7212 |
"do a backward search" |
|
7213 |
||
7214 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7215 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7216 |
! |
7217 |
||
7218 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7219 |
"do a backward search" |
|
7220 |
||
7221 |
cursorLine isNil ifTrue:[^ self]. |
|
7222 |
||
3160 | 7223 |
self |
4119 | 7224 |
searchBackwardFor:pattern |
7225 |
ignoreCase:ign |
|
7226 |
startingAtLine:startLine col:startCol |
|
7227 |
ifFound:[:line :col | |
|
7228 |
self cursorMovementAllowed ifTrue:[ |
|
7229 |
self cursorLine:line col:col. |
|
7230 |
]. |
|
7231 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7232 |
"/ self makeLineVisible:cursorLine |
4119 | 7233 |
typeOfSelection := #search] |
7234 |
ifAbsent:aBlock |
|
1339 | 7235 |
|
7236 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7237 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7239 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7240 |
"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
|
7241 |
|
2554 | 7242 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7243 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7245 |
searchForMatchingParenthesis |
3160 | 7246 |
"search for a matching parenthesis starting at cursor position. |
7247 |
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
|
7248 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7249 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7250 |
|
2822 | 7251 |
self cursorMovementAllowed ifFalse:[^ self]. |
7252 |
||
3160 | 7253 |
self |
7254 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
|
7255 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7256 |
ifNotFound:[self showNotFound] |
|
7257 |
onError:[self beep] |
|
1339 | 7258 |
|
7259 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7260 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7261 |
|
3967 | 7262 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7263 |
"do a forward search" |
7264 |
||
7265 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7266 |
self |
7267 |
searchForwardFor:pattern |
|
7268 |
ignoreCase:ign |
|
7269 |
match: match |
|
7270 |
startingAtLine:startLine col:startCol |
|
7271 |
ifFound:[:line :col | |
|
7272 |
self cursorMovementAllowed ifTrue:[ |
|
7273 |
self cursorLine:line col:col. |
|
7274 |
]. |
|
4119 | 7275 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7276 |
"/ self makeLineVisible:cursorLine |
3967 | 7277 |
typeOfSelection := #search |
7278 |
] |
|
7279 |
ifAbsent:aBlock |
|
1339 | 7280 |
|
7281 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7282 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7283 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7284 |
|
3967 | 7285 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7286 |
"do a forward search" |
|
7287 |
||
7288 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7289 |
! |
|
7290 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7291 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7292 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7293 |
|
2822 | 7294 |
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
|
7295 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7296 |
|
3982 | 7297 |
searchPatternForSearchBar |
7298 |
||
7299 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7300 |
||
7301 |
|searchPattern| |
|
7302 |
||
4138 | 7303 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7304 |
searchPattern isNil |
7305 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7306 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7307 |
^ searchPattern |
|
7308 |
! |
|
7309 |
||
3578 | 7310 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7311 |
"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
|
7312 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7313 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7314 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7315 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7316 |
"/ |
3967 | 7317 |
"/ 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
|
7318 |
"/ original string (for search after again) |
4121 | 7319 |
"/ 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
|
7320 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7321 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7322 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7323 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7324 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7325 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7326 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7327 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7328 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7329 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7330 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7331 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7332 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7333 |
"/ 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
|
7334 |
"/ if there was a previous search, only take the selection if |
3967 | 7335 |
"/ 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
|
7336 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7337 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7338 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7339 |
sel notNil ifTrue:[ |
3967 | 7340 |
(lastSearchPattern isNil |
4484 | 7341 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7342 |
) ifTrue:[ |
|
3967 | 7343 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7344 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7345 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7346 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7347 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7348 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7349 |
"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
|
7350 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7351 |
|
4484 | 7352 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7353 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7354 |
typeOfSelection := #search. |
|
7355 |
! |
|
7356 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7357 |
startPositionForSearchBackward |
2822 | 7358 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7359 |
! |
|
7360 |
||
7361 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7362 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7363 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7364 |
selectionStartLine notNil ifTrue:[ |
3160 | 7365 |
startLine := selectionStartLine. |
7366 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7367 |
] ifFalse:[ |
3160 | 7368 |
cursorLine isNil ifTrue:[ |
7369 |
startLine := list size. |
|
7370 |
startCol := self listAt:startLine size. |
|
7371 |
] ifFalse:[ |
|
7372 |
startLine := cursorLine min:list size. |
|
7373 |
startCol := cursorCol |
|
7374 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7375 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7376 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7377 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7378 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7379 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7380 |
startPositionForSearchForward |
2822 | 7381 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7382 |
! |
|
7383 |
||
7384 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7385 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7386 |
|
3160 | 7387 |
"/ 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
|
7388 |
"/ 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
|
7389 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7390 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7391 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7392 |
] ifFalse:[ |
4064 | 7393 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7394 |
startCol := 0 |
|
7395 |
]. |
|
7396 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7397 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7398 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7399 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7400 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7401 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7402 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7403 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7404 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7405 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7406 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7407 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7408 |
after evaluation of `aBlock`. Used to implement |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7409 |
Shift-Home & Shift-End. " |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7410 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7411 |
"/ Following comment is in czech and thus now very useful. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7412 |
"/ However I (JV) keep it here as this is one of the very |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7413 |
"/ 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
|
7414 |
"/ 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
|
7415 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7416 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7417 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7418 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7419 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7420 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7421 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7422 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7423 |
| startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown | |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7424 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7425 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7426 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7427 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7428 |
self hasSelection ifTrue: [ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7429 |
startLine := selectionStartLine . |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7430 |
startCol := selectionStartCol . |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7431 |
endLine := selectionEndLine . |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7432 |
endCol := selectionEndCol . |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7433 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7434 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7435 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7436 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7437 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7438 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7439 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7440 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7441 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7442 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7443 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7444 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7445 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7446 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7447 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7448 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7449 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7450 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7451 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7452 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7453 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7454 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7455 |
(cursorLine > endLine or:[cursorLine == endLine and:[cursorCol > endCol]]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7456 |
startLine := endLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7457 |
startCol := endCol + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7458 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7459 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7460 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7461 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7462 |
startCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7463 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7464 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7465 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7466 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7467 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7468 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7469 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7470 |
(cursorLine < startLine or:[cursorLine == startLine and:[cursorCol < startCol]]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7471 |
endLine := startLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7472 |
endCol := startCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7473 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7474 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7475 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7476 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7477 |
endCol := cursorCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7478 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7479 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7480 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7481 |
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
|
7482 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7483 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7484 |
"Modified: / 28-08-2013 / 01:23:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7485 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7486 |
|
1850 | 7487 |
autoMoveCursorToEndOfSelection |
7488 |
"return true, if the cursor should be automatically moved to the |
|
7489 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
7490 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 7491 |
not be affected by selecting" |
7492 |
||
7493 |
^ true |
|
7494 |
! |
|
7495 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7496 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7497 |
typeOfSelection ~~ newType ifTrue:[ |
3160 | 7498 |
typeOfSelection := newType. |
7499 |
selectionStartLine notNil ifTrue:[ |
|
7500 |
self |
|
7501 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
7502 |
toLine:selectionEndLine col:selectionEndCol |
|
7503 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7504 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7505 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7506 |
|
4138 | 7507 |
searchPatternFromUserSelectionOrReplace |
7508 |
||
7509 |
|sel searchPattern| |
|
7510 |
||
7511 |
"/ |
|
7512 |
"/ if the last operation was a replace, set pattern to last |
|
7513 |
"/ original string (for search after again) |
|
7514 |
"/ |
|
7515 |
(lastStringFromReplaceForNextSearch notNil |
|
7516 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
7517 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
7518 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
7519 |
] ifFalse:[ |
|
7520 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
7521 |
]. |
|
7522 |
^ searchPattern |
|
7523 |
]. |
|
7524 |
||
7525 |
"/ |
|
7526 |
"/ if there is a selection: |
|
7527 |
"/ if there was no previous search, take it as search pattern. |
|
7528 |
"/ if there was a previous search, only take the selection if |
|
7529 |
"/ it did not result from a paste. |
|
7530 |
"/ (to allow search-paste to be repeated) |
|
7531 |
"/ |
|
7532 |
sel := self selection. |
|
7533 |
sel notNil ifTrue:[ |
|
7534 |
typeOfSelection ~~ #search ifTrue:[ |
|
7535 |
typeOfSelection ~~ #paste ifTrue:[ |
|
7536 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
7537 |
searchPattern := sel asStringWithoutFinalCR. |
|
7538 |
] |
|
7539 |
]. |
|
7540 |
]. |
|
7541 |
||
7542 |
^ searchPattern |
|
7543 |
! |
|
7544 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7545 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7546 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7547 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7548 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7549 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7550 |
list isNil ifTrue:[ |
3160 | 7551 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7552 |
] ifFalse:[ |
3160 | 7553 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
7554 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7555 |
] |
1082 | 7556 |
|
7557 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7558 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7559 |
|
4117 | 7560 |
selectAllInitially |
7561 |
"select the whole text. This is called only once during the initialization |
|
7562 |
for editFields which are shown in a table or tree. |
|
7563 |
The selectAll is called via this method to allow for easier redefinition and |
|
7564 |
to distinguish auto-select from user-initiated selects." |
|
7565 |
||
7566 |
self selectAll |
|
7567 |
! |
|
7568 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7569 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7570 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7571 |
|
3160 | 7572 |
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
|
7573 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7575 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7576 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7577 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7578 |
cursorCol > 1 ifTrue:[ |
3160 | 7579 |
self selectFromLine:cursorLine col:1 |
7580 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7581 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7582 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7583 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7584 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7585 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7586 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7587 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7588 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7589 |
selectionStartLine isNil ifTrue:[ |
3160 | 7590 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7591 |
] ifFalse:[ |
3160 | 7592 |
self selectFromLine:selectionStartLine col:selectionStartCol |
7593 |
toLine:cursorLine+1 col:0. |
|
7594 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7595 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7596 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7597 |
|
4257 | 7598 |
selectFromBeginOfLine |
7599 |
"select the text from the beginning of the current line to the current cursor position." |
|
7600 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7601 |
| newCursorCol ln | |
4271 | 7602 |
|
4257 | 7603 |
list isNil ifTrue:[ |
7604 |
self unselect |
|
7605 |
] ifFalse:[ |
|
7606 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7607 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7608 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 7609 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
7610 |
cursorCol := newCursorCol. |
|
4257 | 7611 |
typeOfSelection := nil |
7612 |
] |
|
7613 |
] |
|
7614 |
||
7615 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7616 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7617 |
! |
7618 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7619 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7620 |
"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
|
7621 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7622 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7623 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7624 |
list isNil ifTrue:[ |
3160 | 7625 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7626 |
] ifFalse:[ |
3160 | 7627 |
cursorCol == 0 ifTrue:[ |
7628 |
col := 0 |
|
7629 |
] ifFalse:[ |
|
7630 |
col := cursorCol - 1 |
|
7631 |
]. |
|
7632 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
7633 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7634 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7635 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7636 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7637 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7638 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7639 |
super 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
|
7640 |
"JV: That's atctuall rubbish as then you loose the original positon |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7641 |
and if user wants to extend/shring the selection further, you don't know |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7642 |
from which end to do it!!" |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7643 |
"/ (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7644 |
"/ self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7645 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7646 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7647 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7648 |
"Modified: / 27-08-2013 / 13:28:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7649 |
"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
|
7650 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7651 |
|
4257 | 7652 |
selectToEndOfLine |
7653 |
"select the text from the current cursor position to the end of the current line" |
|
7654 |
||
4271 | 7655 |
| newCursorCol line | |
7656 |
||
4257 | 7657 |
list isNil ifTrue:[ |
7658 |
self unselect |
|
7659 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7660 |
cursorCol >= 1 ifTrue:[ |
4271 | 7661 |
line := list at: cursorLine. |
7662 |
newCursorCol := line size. |
|
7663 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
7664 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
7665 |
||
7666 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
7667 |
cursorCol := newCursorCol. |
|
4257 | 7668 |
typeOfSelection := nil |
7669 |
] |
|
7670 |
] |
|
7671 |
||
7672 |
"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
|
7673 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7674 |
! |
7675 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7676 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7677 |
"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
|
7678 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7679 |
list isNil ifTrue:[ |
3160 | 7680 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7681 |
] ifFalse:[ |
3160 | 7682 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
7683 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7684 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7685 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7686 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7687 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7688 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7689 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7690 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7691 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7692 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7693 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7694 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7695 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7696 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7697 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7698 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7699 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7700 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7701 |
wasOn ifTrue:[self showCursor] |
105 | 7702 |
! ! |
7703 |
||
7704 |
!EditTextView methodsFor:'undo & again'! |
|
7705 |
||
2952 | 7706 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7707 |
^ undoSupport addUndo:action. |
2952 | 7708 |
! |
7709 |
||
105 | 7710 |
again |
7711 |
"repeat the last action (which was a cut or replace). |
|
7712 |
If current selection is not last string, search forward to |
|
3160 | 7713 |
next occurrence of it before repeating the last operation." |
105 | 7714 |
|
4048 | 7715 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 7716 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 7717 |
|
7718 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 7719 |
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
|
7720 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7721 |
]. |
4048 | 7722 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
7723 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7724 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7725 |
self undoableDo:[ |
4010 | 7726 |
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
|
7727 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
7728 |
(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
|
7729 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 7730 |
|
4053 | 7731 |
"set lastStringToReplace as the next search string |
7732 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 7733 |
lastStringFromReplaceForNextSearch := s. |
4053 | 7734 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 7735 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7736 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7737 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7738 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7739 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7740 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7741 |
"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
|
7742 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7743 |
(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
|
7744 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7745 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7746 |
self deleteSelection. |
4051 | 7747 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7748 |
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
|
7749 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 7750 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7751 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7752 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7753 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7754 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7755 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7756 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7757 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7758 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7759 |
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
|
7760 |
]. |
4048 | 7761 |
self |
7762 |
searchForwardFor:s |
|
7763 |
ignoreCase: lastReplaceIgnoredCase |
|
7764 |
match: lastReplaceWasMatch |
|
7765 |
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
|
7766 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7767 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7768 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7769 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7770 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7771 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7772 |
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
|
7773 |
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
|
7774 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7775 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7776 |
self deleteSelection. |
4051 | 7777 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7778 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
7779 |
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
|
7780 |
] ifTrue:[ |
4051 | 7781 |
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
|
7782 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7783 |
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
|
7784 |
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
|
7785 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7786 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7787 |
selectStyle := savedSelectStyle. |
4484 | 7788 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7789 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7790 |
] |
4048 | 7791 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7792 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7793 |
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
|
7794 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7795 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7796 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7797 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7798 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7799 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7800 |
^ true. |
501 | 7801 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
7802 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 7803 |
! |
7804 |
||
2952 | 7805 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7806 |
^ undoSupport hasRedoAction. |
2952 | 7807 |
! |
7808 |
||
7809 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7810 |
^ undoSupport hasUndoAction. |
2952 | 7811 |
! |
7812 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7813 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7814 |
"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
|
7815 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7816 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7817 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7818 |
|
2952 | 7819 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7820 |
undoSupport nonUndoableDo:aBlock. |
2952 | 7821 |
! |
7822 |
||
7823 |
redo |
|
3780 | 7824 |
"undo the last undo" |
7825 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7826 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 7827 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7828 |
] ifTrue:[ |
3780 | 7829 |
undoSupport redo. |
2952 | 7830 |
] |
7831 |
! |
|
7832 |
||
121 | 7833 |
undo |
3780 | 7834 |
"undo the last edit operation" |
7835 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7836 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 7837 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7838 |
] ifTrue:[ |
3780 | 7839 |
undoSupport undo. |
121 | 7840 |
] |
2952 | 7841 |
! |
7842 |
||
7843 |
undoableDo:aBlock |
|
3495 | 7844 |
self undoableDo:aBlock info:nil. |
7845 |
||
7846 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 7847 |
! |
7848 |
||
7849 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
7850 |
self checkModificationsAllowed ifFalse:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7851 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7852 |
aBlock value. |
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
7853 |
] ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7854 |
undoSupport undoableDo:aBlock info:aString. |
3495 | 7855 |
]. |
7856 |
||
7857 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 7858 |
! ! |
7859 |
||
7860 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
7861 |
||
7862 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
7863 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
7864 |
! |
|
7865 |
||
3115 | 7866 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 7867 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 7868 |
! |
7869 |
||
2952 | 7870 |
line:arg1 col:arg2 character:arg3 |
7871 |
^ self new line:arg1 col:arg2 character:arg3 |
|
7872 |
! |
|
7873 |
||
3115 | 7874 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 7875 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 7876 |
! |
7877 |
||
3235 | 7878 |
line:arg1 col:arg2 characters:arg3 info:info |
7879 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
7880 |
! |
|
7881 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7882 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7883 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7884 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7885 |
|
2952 | 7886 |
line:arg1 col:arg2 string:arg3 |
7887 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 7888 |
! |
7889 |
||
7890 |
line:arg1 col:arg2 string:arg3 info:info |
|
7891 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 7892 |
! |
7893 |
||
7894 |
line:arg1 string:arg3 info:info |
|
7895 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 7896 |
! |
7897 |
||
7898 |
text:arg info:info |
|
7899 |
^ (self new text:arg) info:info |
|
3115 | 7900 |
! ! |
7901 |
||
7902 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
7903 |
||
7904 |
info |
|
7905 |
^ userFriendlyInfo |
|
7906 |
! |
|
7907 |
||
7908 |
info:aString |
|
7909 |
userFriendlyInfo := aString |
|
2952 | 7910 |
! ! |
7911 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7912 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7913 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7914 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7915 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7916 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7917 |
"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
|
7918 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
7919 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7920 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7921 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7922 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7923 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7924 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7925 |
|
2952 | 7926 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
7927 |
||
3160 | 7928 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 7929 |
"set instance variables (automatically generated)" |
7930 |
||
7931 |
self assert:(line1Arg notNil). |
|
7932 |
self assert:(col1Arg notNil). |
|
7933 |
self assert:(line2Arg notNil). |
|
7934 |
self assert:(col2Arg notNil). |
|
7935 |
||
7936 |
line1 := line1Arg. |
|
7937 |
col1 := col1Arg. |
|
7938 |
line2 := line2Arg. |
|
7939 |
col2 := col2Arg. |
|
7940 |
! ! |
|
7941 |
||
7942 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
7943 |
||
3160 | 7944 |
executeIn:editor |
2952 | 7945 |
editor unselect. |
3160 | 7946 |
editor |
7947 |
deleteFromLine:line1 |
|
7948 |
col:col1 |
|
7949 |
toLine:line2 |
|
7950 |
col:col2. |
|
2952 | 7951 |
editor cursorLine:line1 col:col1. |
7952 |
! ! |
|
7953 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7954 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7955 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7956 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7957 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7958 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7959 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7960 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7961 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7962 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7963 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7964 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7965 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7966 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7967 |
|
3160 | 7968 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7969 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7970 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7971 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7972 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7973 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7974 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7975 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7976 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7977 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7978 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7979 |
|
3160 | 7980 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7981 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7982 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7983 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7984 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7985 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7986 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7987 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7988 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7989 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7990 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7991 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7992 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7993 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7994 |
|
3160 | 7995 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7996 |
"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
|
7997 |
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
|
7998 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
7999 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8000 |
previousDeleteAction line == line ifTrue:[ |
3160 | 8001 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8002 |
^ true |
|
8003 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8004 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8005 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8006 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8007 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8008 |
|
3160 | 8009 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8010 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8011 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8012 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8013 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8014 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8015 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8016 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8017 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8018 |
|
3160 | 8019 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8020 |
editor unselect. |
3160 | 8021 |
editor |
8022 |
deleteFromLine:line |
|
8023 |
col:col1 |
|
8024 |
toLine:line |
|
8025 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8026 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8027 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8028 |
|
3235 | 8029 |
!EditTextView::EditMode class methodsFor:'constants'! |
8030 |
||
8031 |
insertAndSelectMode |
|
8032 |
^ InsertAndSelectMode |
|
8033 |
! |
|
8034 |
||
8035 |
insertMode |
|
8036 |
^ InsertMode |
|
8037 |
! |
|
8038 |
||
8039 |
overwriteMode |
|
8040 |
^ OverwriteMode |
|
8041 |
! ! |
|
8042 |
||
8043 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8044 |
||
8045 |
isInsertAndSelectMode |
|
8046 |
^ false |
|
8047 |
! |
|
8048 |
||
8049 |
isInsertMode |
|
8050 |
^ false |
|
8051 |
! |
|
8052 |
||
8053 |
symbolicName |
|
8054 |
self subclassResponsibility |
|
8055 |
! ! |
|
8056 |
||
8057 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8058 |
||
8059 |
infoPrintString |
|
8060 |
^ 'IS' |
|
8061 |
! ! |
|
8062 |
||
8063 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8064 |
||
8065 |
isInsertAndSelectMode |
|
8066 |
^ true |
|
8067 |
! |
|
8068 |
||
8069 |
isInsertMode |
|
8070 |
^ true |
|
8071 |
! ! |
|
8072 |
||
8073 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8074 |
||
8075 |
infoPrintString |
|
8076 |
^ 'I' |
|
8077 |
! ! |
|
8078 |
||
8079 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8080 |
||
8081 |
isInsertMode |
|
8082 |
^ true |
|
8083 |
! ! |
|
8084 |
||
8085 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8086 |
||
8087 |
infoPrintString |
|
8088 |
^ 'O' |
|
8089 |
! ! |
|
8090 |
||
4048 | 8091 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8092 |
||
8093 |
lastReplaceIgnoredCase |
|
8094 |
^ lastReplaceIgnoredCase ? false |
|
8095 |
! |
|
8096 |
||
8097 |
lastReplaceIgnoredCase:something |
|
8098 |
lastReplaceIgnoredCase := something. |
|
8099 |
! |
|
8100 |
||
8101 |
lastReplaceWasMatch |
|
8102 |
^ lastReplaceWasMatch ? false |
|
8103 |
! |
|
8104 |
||
8105 |
lastReplaceWasMatch:something |
|
8106 |
lastReplaceWasMatch := something. |
|
8107 |
! |
|
8108 |
||
8109 |
lastReplacement |
|
8110 |
^ lastReplacement |
|
8111 |
! |
|
8112 |
||
8113 |
lastReplacement:something |
|
4053 | 8114 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8115 |
lastReplacement := something. |
8116 |
! |
|
8117 |
||
8118 |
lastStringToReplace |
|
8119 |
^ lastStringToReplace |
|
8120 |
! |
|
8121 |
||
8122 |
lastStringToReplace:something |
|
8123 |
lastStringToReplace := something. |
|
8124 |
! ! |
|
8125 |
||
2952 | 8126 |
!EditTextView::PasteString methodsFor:'accessing'! |
8127 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8128 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8129 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8130 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8131 |
"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
|
8132 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8133 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8134 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8135 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8136 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8137 |
"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
|
8138 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8139 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8140 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8141 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8142 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8143 |
"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
|
8144 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8145 |
|
3160 | 8146 |
line:lineArg col:colArg string:stringArg |
2952 | 8147 |
self assert:(lineArg notNil). |
8148 |
self assert:(colArg notNil). |
|
8149 |
self assert:(stringArg notNil). |
|
8150 |
||
8151 |
line := lineArg. |
|
8152 |
col := colArg. |
|
8153 |
string := stringArg. |
|
8154 |
! |
|
8155 |
||
8156 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8157 |
self assert:(lineArg notNil). |
|
8158 |
self assert:(colArg notNil). |
|
8159 |
self assert:(stringArg notNil). |
|
8160 |
||
8161 |
line := lineArg. |
|
8162 |
col := colArg. |
|
8163 |
string := stringArg. |
|
8164 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8165 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8166 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8167 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8168 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8169 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8170 |
"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
|
8171 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8172 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8173 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8174 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8175 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8176 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8177 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8178 |
"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
|
8179 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8180 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8181 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8182 |
"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
|
8183 |
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
|
8184 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8185 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8186 |
previousPasteAction line == line ifTrue:[ |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8187 |
previousPasteAction col == (self col2+1) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8188 |
^ true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8189 |
]. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8190 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8191 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8192 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8193 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8194 |
"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
|
8195 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8196 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8197 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8198 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8199 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8200 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8201 |
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
|
8202 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8203 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8204 |
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
|
8205 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8206 |
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
|
8207 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8208 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8209 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8210 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8211 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8212 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8213 |
! ! |
8214 |
||
8215 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8216 |
||
3160 | 8217 |
executeIn:editor |
2952 | 8218 |
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
|
8219 |
editor paste:string. |
2952 | 8220 |
selected ~~ true ifTrue:[ |
3160 | 8221 |
editor unselect |
2952 | 8222 |
]. |
8223 |
! ! |
|
8224 |
||
8225 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8226 |
||
3235 | 8227 |
col |
8228 |
^ col |
|
8229 |
! |
|
8230 |
||
8231 |
col1 |
|
8232 |
^ col |
|
8233 |
! |
|
8234 |
||
8235 |
col2 |
|
8236 |
^ col |
|
8237 |
! |
|
8238 |
||
8239 |
line |
|
8240 |
^ line |
|
8241 |
! |
|
8242 |
||
3160 | 8243 |
line:lineArg col:colArg character:characterArg |
2952 | 8244 |
line := lineArg. |
8245 |
col := colArg. |
|
8246 |
character := characterArg. |
|
8247 |
! ! |
|
8248 |
||
8249 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8250 |
||
3160 | 8251 |
executeIn:editor |
8252 |
editor |
|
8253 |
replace:character |
|
8254 |
atLine:line |
|
8255 |
col:col. |
|
2952 | 8256 |
editor cursorLine:line col:col. |
105 | 8257 |
! ! |
8258 |
||
3235 | 8259 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8260 |
||
8261 |
characters |
|
8262 |
^ characters |
|
8263 |
! |
|
8264 |
||
8265 |
col1 |
|
8266 |
^ col1 |
|
8267 |
! |
|
8268 |
||
8269 |
col2 |
|
8270 |
^ col2 |
|
8271 |
! |
|
8272 |
||
8273 |
line |
|
8274 |
^ line |
|
8275 |
! |
|
8276 |
||
8277 |
line:lineArg col:colArg character:characterArg |
|
8278 |
line := lineArg. |
|
8279 |
col1 := col2 := colArg. |
|
8280 |
characters := characterArg asString. |
|
8281 |
! |
|
8282 |
||
8283 |
line:lineArg col:colArg characters:charactersArg |
|
8284 |
line := lineArg. |
|
8285 |
col1 := colArg. |
|
8286 |
characters := charactersArg asString. |
|
8287 |
col2 := col1 + charactersArg size - 1 |
|
8288 |
! ! |
|
8289 |
||
8290 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8291 |
||
8292 |
canCombineWithNext:anotherAction |
|
8293 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8294 |
! |
|
8295 |
||
8296 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8297 |
"I will combine only if we both are single character deletes, |
|
8298 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8299 |
(i.e. single-character typing)" |
|
8300 |
||
8301 |
previousReplaceAction line == line ifTrue:[ |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8302 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8303 |
^ true |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8304 |
]. |
3235 | 8305 |
]. |
8306 |
||
8307 |
^ false |
|
8308 |
! |
|
8309 |
||
8310 |
combineWithNext:nextReplaceAction |
|
8311 |
self assert:(line == nextReplaceAction line). |
|
8312 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8313 |
||
8314 |
col2 := nextReplaceAction col2. |
|
8315 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8316 |
characters := characters , nextReplaceAction characters. |
|
8317 |
! ! |
|
8318 |
||
8319 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8320 |
||
8321 |
executeIn:editor |
|
8322 |
editor |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8323 |
replaceString:characters |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8324 |
atLine:line |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8325 |
col:col1. |
3235 | 8326 |
editor cursorLine:line col:col1. |
8327 |
! ! |
|
8328 |
||
3131 | 8329 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8330 |
||
8331 |
text:something |
|
8332 |
text := something. |
|
8333 |
! ! |
|
8334 |
||
8335 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8336 |
||
3160 | 8337 |
executeIn:editor |
3131 | 8338 |
editor contents:text |
8339 |
! ! |
|
8340 |
||
3130 | 8341 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8342 |
||
3160 | 8343 |
line:lineArg string:stringArg |
3130 | 8344 |
line := lineArg. |
8345 |
text := stringArg. |
|
8346 |
! ! |
|
8347 |
||
8348 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
8349 |
||
3160 | 8350 |
executeIn:editor |
3130 | 8351 |
editor list at:line put:text. |
8352 |
editor invalidateLine:line |
|
8353 |
! ! |
|
8354 |
||
3402 | 8355 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
8356 |
||
8357 |
line:lineArg lines:lineCollectionArg |
|
8358 |
line := lineArg. |
|
8359 |
text := lineCollectionArg. |
|
8360 |
||
8361 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
8362 |
! ! |
|
8363 |
||
8364 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
8365 |
||
8366 |
executeIn:editor |
|
8367 |
|lnr| |
|
8368 |
||
8369 |
lnr := line. |
|
8370 |
text do:[:eachLine | |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8371 |
editor list at:lnr put:eachLine. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8372 |
editor invalidateLine:lnr. |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8373 |
lnr := lnr + 1. |
3402 | 8374 |
]. |
8375 |
||
8376 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
8377 |
! ! |
|
8378 |
||
865 | 8379 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8380 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8381 |
version |
4674 | 8382 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.562 2013-08-25 10:58:10 cg Exp $' |
3945 | 8383 |
! |
8384 |
||
8385 |
version_CVS |
|
4674 | 8386 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.562 2013-08-25 10:58:10 cg Exp $' |
4843
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
8387 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
8388 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
8389 |
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
|
8390 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
8391 |
^ '$Changeset: <not expanded> $' |
0 | 8392 |
! ! |
4481 | 8393 |