author | Claus Gittinger <cg@exept.de> |
Mon, 18 Mar 1996 17:19:09 +0100 | |
changeset 502 | 6f3d0d7a782c |
parent 489 | 5816aa12fec8 |
child 503 | 468d4a36ed67 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 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 |
" |
|
12 |
||
13 |
ListView subclass:#TextView |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
14 |
instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine |
248 | 15 |
selectionEndCol clickStartLine clickStartCol clickLine clickCol |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
16 |
clickCount expandingTop wordStartCol wordStartLine wordEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
17 |
wordEndLine selectionFgColor selectionBgColor selectStyle |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
18 |
directoryForFileDialog contentsWasSaved' |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
19 |
classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor |
248 | 20 |
DefaultSelectionBackgroundColor MatchDelayTime' |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
21 |
poolDictionaries:'' |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
22 |
category:'Views-Text' |
0 | 23 |
! |
24 |
||
25 |
!TextView class methodsFor:'documentation'! |
|
26 |
||
38 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 30 |
All Rights Reserved |
38 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
22 | 41 |
documentation |
0 | 42 |
" |
120 | 43 |
a view for readOnly text - this class adds selections to a simple list. |
38 | 44 |
The text is not editable and there is no cursor. |
120 | 45 |
Use TextViews for readonly text, EditTextView for editable text. |
0 | 46 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
47 |
Please read the historic notice in the ListView class. |
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
48 |
|
38 | 49 |
Instance variables: |
0 | 50 |
|
120 | 51 |
selectionStartLine <Number> the line of the selection start (or nil) |
52 |
selectionStartCol <Number> the col of the selection start |
|
53 |
selectionEndLine <Number> the line of the selection end |
|
54 |
selectionEndCol <Number> the col of the selection end |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
55 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
56 |
clickStartLine <Number> temporary - remember where select operation started |
120 | 57 |
clickStartCol <Number> temporary |
58 |
clickLine <Number> temporary |
|
59 |
clickCol <Number> temporary |
|
60 |
clickCount <Number> temporary |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
61 |
expandingTop <Boolean> temporary - for expandSelection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
62 |
|
120 | 63 |
selectionFgColor <Color> color used to draw selections |
64 |
selectionBgColor <Color> color used to draw selections |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
65 |
|
120 | 66 |
selectStyle <Symbol> how words are selected |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
67 |
|
120 | 68 |
directoryForFileDialog <nil|pathName> directory where save dialog should start |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
69 |
|
120 | 70 |
contentsWasSaved <Boolean> set to true, whenever saved in a file |
77 | 71 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
72 |
|
77 | 73 |
StyleSheet parameters: |
74 |
||
120 | 75 |
textViewBackground defaults to viewBackground |
76 |
textSelectionForegroundColor defaults to textBackgroundColor |
|
77 |
textSelectionBackgroundColor defaults to textForegroundColor |
|
78 |
textViewFont defaults to textFont |
|
0 | 79 |
" |
80 |
! ! |
|
81 |
||
119 | 82 |
!TextView class methodsFor:'instance creation'! |
83 |
||
84 |
on:aModel aspect:aspect change:change menu:menu initialSelection:initial |
|
85 |
"for ST-80 compatibility" |
|
86 |
||
120 | 87 |
^ (self new) |
88 |
on:aModel |
|
89 |
aspect:aspect |
|
90 |
list:aspect |
|
91 |
change:change |
|
92 |
menu:menu |
|
93 |
initialSelection:initial |
|
119 | 94 |
! ! |
95 |
||
59 | 96 |
!TextView class methodsFor:'defaults'! |
38 | 97 |
|
59 | 98 |
updateStyleCache |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
99 |
"extract values from the styleSheet and cache them in class variables" |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
100 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
101 |
<resource: #style (#textViewBackground |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
102 |
#textSelectionForegroundColor #textSelectionBackgroundColor |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
103 |
#textViewFont)> |
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
104 |
|
60 | 105 |
DefaultViewBackground := StyleSheet colorAt:'textViewBackground' default:White. |
106 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelectionForegroundColor'. |
|
107 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelectionBackgroundColor'. |
|
77 | 108 |
DefaultFont := StyleSheet fontAt:'textViewFont'. |
186 | 109 |
MatchDelayTime := 0.6 |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
110 |
|
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
111 |
"Modified: 1.3.1996 / 13:50:14 / cg" |
0 | 112 |
! ! |
113 |
||
248 | 114 |
!TextView class methodsFor:'startup'! |
121 | 115 |
|
248 | 116 |
open |
117 |
"start an empty TextView" |
|
118 |
||
119 |
^ self openWith:nil |
|
0 | 120 |
! |
121 |
||
248 | 122 |
openOn:aFileName |
123 |
"start a textView on a file" |
|
124 |
||
125 |
|top textView stream| |
|
0 | 126 |
|
248 | 127 |
textView := self setupEmpty. |
128 |
top := textView topView. |
|
129 |
aFileName notNil ifTrue:[ |
|
130 |
top label:(OperatingSystem baseNameOf:aFileName). |
|
131 |
stream := aFileName asFilename readStream. |
|
132 |
stream notNil ifTrue:[ |
|
133 |
textView contents:(stream contents) |
|
59 | 134 |
] |
135 |
]. |
|
248 | 136 |
|
137 |
top open. |
|
138 |
^ textView |
|
139 |
||
140 |
" |
|
141 |
TextView openOn:'../doc/info.doc' |
|
142 |
EditTextView openOn:'../doc/info.doc' |
|
143 |
" |
|
0 | 144 |
! |
145 |
||
248 | 146 |
openWith:aString |
147 |
"start a textView with aString as initial contents" |
|
148 |
||
149 |
^ self openWith:aString title:nil |
|
0 | 150 |
|
248 | 151 |
" |
152 |
TextView openWith:'some text' |
|
153 |
EditTextView openWith:'some text' |
|
154 |
" |
|
119 | 155 |
|
248 | 156 |
"Created: 10.12.1995 / 17:41:32 / cg" |
126 | 157 |
! |
158 |
||
248 | 159 |
openWith:aString title:aTitle |
160 |
"start a textView with aString as initial contents" |
|
161 |
||
162 |
|top textView| |
|
163 |
||
164 |
textView := self setupEmpty. |
|
165 |
top := textView topView. |
|
166 |
aTitle notNil ifTrue:[top label:aTitle]. |
|
167 |
||
168 |
aString notNil ifTrue:[ |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
169 |
textView contents:aString |
248 | 170 |
]. |
171 |
||
172 |
top open. |
|
173 |
^ textView |
|
174 |
||
175 |
" |
|
176 |
TextView openWith:'some text' title:'testing' |
|
177 |
EditTextView openWith:'some text' title:'testing' |
|
178 |
" |
|
126 | 179 |
|
248 | 180 |
"Created: 10.12.1995 / 17:40:02 / cg" |
181 |
"Modified: 10.12.1995 / 17:41:13 / cg" |
|
182 |
! |
|
183 |
||
184 |
setupEmpty |
|
185 |
"create a textview in a topview, with horizontal and |
|
186 |
vertical scrollbars - a helper for #startWith: and #startOn:" |
|
187 |
||
188 |
|top frame label| |
|
189 |
||
190 |
label := 'unnamed'. |
|
191 |
top := StandardSystemView |
|
192 |
label:label |
|
193 |
icon:(Form fromFile:'Editor.xbm' resolution:100). |
|
194 |
||
195 |
frame := HVScrollableView |
|
196 |
for:self |
|
197 |
miniScrollerH:true miniScrollerV:false |
|
198 |
in:top. |
|
199 |
frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
200 |
^ frame scrolledView |
|
119 | 201 |
! ! |
202 |
||
0 | 203 |
!TextView methodsFor:'accessing'! |
204 |
||
205 |
characterAtLine:lineNr col:colNr |
|
206 |
"return the character at physical line/col - |
|
207 |
return space if nothing is there" |
|
208 |
||
209 |
|line| |
|
210 |
||
211 |
list notNil ifTrue:[ |
|
59 | 212 |
line := self listAt:lineNr. |
213 |
line notNil ifTrue:[ |
|
214 |
(line size >= colNr) ifTrue:[ |
|
215 |
^ line at:colNr |
|
216 |
] |
|
217 |
] |
|
0 | 218 |
]. |
219 |
^ Character space |
|
220 |
! |
|
221 |
||
222 |
characterPositionOfSelection |
|
223 |
"return the character index of the first character in the selection" |
|
224 |
||
225 |
selectionStartLine isNil ifTrue:[^ 1]. |
|
226 |
^ self characterPositionOfLine:selectionStartLine |
|
59 | 227 |
col:selectionStartCol |
0 | 228 |
! |
229 |
||
230 |
contentsWasSaved |
|
231 |
"return true, if the contents was saved (by a save action), |
|
232 |
false if not (or was modified again after the last save)." |
|
233 |
||
234 |
^ contentsWasSaved |
|
235 |
! |
|
236 |
||
248 | 237 |
directoryForFileDialog:aDirectory |
238 |
"define the directory to use for save-box" |
|
239 |
||
240 |
directoryForFileDialog := aDirectory |
|
241 |
! |
|
242 |
||
0 | 243 |
fromFile:aFileName |
244 |
"take contents from a named file" |
|
245 |
||
246 |
self directoryForFileDialog:(OperatingSystem directoryNameOf:aFileName). |
|
247 |
self contents:(FileStream oldFileNamed:aFileName) contents |
|
248 |
! |
|
249 |
||
248 | 250 |
list:something |
251 |
"set the displayed contents (a collection of strings) |
|
252 |
with redraw. |
|
253 |
Redefined since changing contents implies deselect" |
|
0 | 254 |
|
255 |
self unselect. |
|
248 | 256 |
super list:something |
0 | 257 |
! |
258 |
||
248 | 259 |
selectionForegroundColor:color1 backgroundColor:color2 |
260 |
"set both selection-foreground and cursor background colors" |
|
131 | 261 |
|
248 | 262 |
selectionFgColor := color1 on:device. |
263 |
selectionBgColor := color2 on:device. |
|
264 |
shown ifTrue:[ |
|
265 |
self redraw |
|
0 | 266 |
] |
267 |
! |
|
268 |
||
248 | 269 |
setList:something |
270 |
"set the displayed contents (a collection of strings) |
|
271 |
without redraw. |
|
272 |
Redefined since changing contents implies deselect" |
|
0 | 273 |
|
248 | 274 |
self unselect. |
275 |
super setList:something |
|
0 | 276 |
! ! |
277 |
||
248 | 278 |
!TextView methodsFor:'accessing-mvc'! |
0 | 279 |
|
248 | 280 |
model:aModel |
281 |
"when my model is set, and I am the menuPerformer/menuHolder, |
|
282 |
reset holder to the model. This is a compatibility kludge, |
|
283 |
since typically, ST-80 code expects the model to provide a menu |
|
284 |
and the view to perform it. |
|
285 |
Those apps which want the TextView to provide the menu have to reset |
|
286 |
this by sending menuHolder: (again)" |
|
287 |
||
288 |
super model:aModel. |
|
289 |
(menuPerformer == self and:[menuHolder == self]) ifTrue:[ |
|
290 |
menuHolder := model |
|
0 | 291 |
] |
292 |
! |
|
293 |
||
248 | 294 |
on:aModel aspect:aspectSym list:listSym change:changeSym menu:menuSym initialSelection:initial |
295 |
"ST-80 compatibility" |
|
0 | 296 |
|
248 | 297 |
aspectSym notNil ifTrue:[aspectMsg := aspectSym. listMsg := aspectSym]. |
298 |
changeSym notNil ifTrue:[changeMsg := changeSym]. |
|
299 |
listSym notNil ifTrue:[listMsg := listSym]. |
|
300 |
menuSym notNil ifTrue:[menuMsg := menuSym]. |
|
301 |
"/ initial notNil ifTrue:[initialSelectionMsg := initial]. |
|
302 |
self model:aModel. |
|
0 | 303 |
|
248 | 304 |
listMsg notNil ifTrue:[ |
305 |
self getListFromModel |
|
0 | 306 |
]. |
307 |
! ! |
|
308 |
||
309 |
!TextView methodsFor:'event processing'! |
|
310 |
||
53 | 311 |
buttonMotion:buttonMask x:x y:y |
0 | 312 |
"mouse-move while button was pressed - handle selection changes" |
313 |
||
314 |
|movedVisibleLine movedLine movedCol |
|
315 |
movedUp |
|
316 |
oldStartLine oldEndLine oldStartCol oldEndCol| |
|
317 |
||
318 |
clickLine isNil ifTrue:[^ self]. |
|
319 |
||
63 | 320 |
"is it the select or 1-button ?" |
321 |
(device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[ |
|
322 |
(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[ |
|
323 |
^ self |
|
324 |
]. |
|
53 | 325 |
]. |
326 |
||
0 | 327 |
"if moved outside of view, start autoscroll" |
328 |
(y < 0) ifTrue:[ |
|
59 | 329 |
self compressMotionEvents:false. |
330 |
self startAutoScrollUp:y. |
|
331 |
^ self |
|
0 | 332 |
]. |
333 |
(y > height) ifTrue:[ |
|
59 | 334 |
self compressMotionEvents:false. |
335 |
self startAutoScrollDown:(y - height). |
|
336 |
^ self |
|
337 |
]. |
|
338 |
((x < 0) and:[leftOffset ~~ 0]) ifTrue:[ |
|
339 |
self compressMotionEvents:false. |
|
340 |
self startAutoScrollLeft:x. |
|
341 |
^ self |
|
342 |
]. |
|
343 |
(x > width) ifTrue:[ |
|
344 |
self compressMotionEvents:false. |
|
345 |
self startAutoScrollRight:(x - width). |
|
346 |
^ self |
|
0 | 347 |
]. |
348 |
||
349 |
"move inside - stop autoscroll if any" |
|
350 |
autoScrollBlock notNil ifTrue:[ |
|
59 | 351 |
self stopScrollSelect |
0 | 352 |
]. |
353 |
||
354 |
movedVisibleLine := self visibleLineOfY:y. |
|
355 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
|
356 |
(x < leftMargin) ifTrue:[ |
|
59 | 357 |
movedCol := 0 |
0 | 358 |
] ifFalse:[ |
59 | 359 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
0 | 360 |
]. |
361 |
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[^ self]. |
|
362 |
||
363 |
selectionStartLine isNil ifTrue:[ |
|
59 | 364 |
selectionStartLine := clickLine. |
365 |
selectionStartCol := clickCol. |
|
366 |
selectionEndLine := selectionStartLine. |
|
367 |
selectionEndCol := selectionStartCol |
|
0 | 368 |
]. |
369 |
oldStartLine := selectionStartLine. |
|
370 |
oldEndLine := selectionEndLine. |
|
371 |
oldStartCol := selectionStartCol. |
|
372 |
oldEndCol := selectionEndCol. |
|
373 |
||
374 |
||
375 |
"find out if we are before or after initial click" |
|
376 |
movedUp := false. |
|
377 |
(movedLine < clickStartLine) ifTrue:[ |
|
59 | 378 |
movedUp := true |
0 | 379 |
] ifFalse:[ |
59 | 380 |
(movedLine == clickStartLine) ifTrue:[ |
381 |
(movedCol < clickStartCol) ifTrue:[ |
|
382 |
movedUp := true |
|
383 |
] |
|
384 |
] |
|
0 | 385 |
]. |
386 |
||
387 |
movedUp ifTrue:[ |
|
59 | 388 |
"change selectionStart" |
389 |
selectionStartCol := movedCol. |
|
390 |
selectionStartLine := movedLine. |
|
391 |
selectionEndCol := clickStartCol. |
|
392 |
selectionEndLine := clickStartLine. |
|
393 |
selectStyle notNil ifTrue:[ |
|
394 |
selectionEndCol := wordEndCol. |
|
395 |
selectionEndLine := wordEndLine. |
|
396 |
] |
|
0 | 397 |
] ifFalse:[ |
59 | 398 |
"change selectionEnd" |
399 |
selectionEndCol := movedCol. |
|
400 |
selectionEndLine := movedLine. |
|
401 |
selectionStartCol := clickStartCol. |
|
402 |
selectionStartLine := clickStartLine. |
|
403 |
selectStyle notNil ifTrue:[ |
|
404 |
selectionStartCol := wordStartCol. |
|
405 |
selectionStartLine := wordStartLine. |
|
406 |
] |
|
0 | 407 |
]. |
408 |
||
164 | 409 |
selectionStartLine isNil ifTrue:[^ self]. |
410 |
||
0 | 411 |
(selectionStartCol == 0) ifTrue:[ |
59 | 412 |
selectionStartCol := 1 |
0 | 413 |
]. |
414 |
||
38 | 415 |
" |
416 |
if in word-select, just catch the rest of the word |
|
417 |
" |
|
418 |
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[ |
|
59 | 419 |
movedUp ifTrue:[ |
420 |
selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol |
|
421 |
] ifFalse:[ |
|
422 |
selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol. |
|
423 |
selectionEndCol == 0 ifTrue:[ |
|
424 |
selectionEndLine := selectionEndLine + 1 |
|
425 |
] |
|
426 |
]. |
|
38 | 427 |
]. |
428 |
||
429 |
selectStyle == #line ifTrue:[ |
|
59 | 430 |
movedUp ifTrue:[ |
431 |
selectionStartCol := 1. |
|
432 |
] ifFalse:[ |
|
433 |
selectionEndCol := 0. |
|
434 |
selectionEndLine := selectionEndLine + 1 |
|
435 |
] |
|
38 | 436 |
]. |
437 |
||
209
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
186
diff
changeset
|
438 |
self validateNewSelection. |
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
186
diff
changeset
|
439 |
|
0 | 440 |
(oldStartLine == selectionStartLine) ifTrue:[ |
59 | 441 |
(oldStartCol ~~ selectionStartCol) ifTrue:[ |
442 |
self redrawLine:oldStartLine |
|
443 |
from:((selectionStartCol min:oldStartCol) max:1) |
|
444 |
to:((selectionStartCol max:oldStartCol) max:1) |
|
445 |
] |
|
0 | 446 |
] ifFalse:[ |
59 | 447 |
self redrawFromLine:(oldStartLine min:selectionStartLine) |
448 |
to:(oldStartLine max:selectionStartLine) |
|
0 | 449 |
]. |
450 |
||
451 |
(oldEndLine == selectionEndLine) ifTrue:[ |
|
59 | 452 |
(oldEndCol ~~ selectionEndCol) ifTrue:[ |
453 |
self redrawLine:oldEndLine |
|
454 |
from:((selectionEndCol min:oldEndCol) max:1) |
|
455 |
to:((selectionEndCol max:oldEndCol) max:1) |
|
456 |
] |
|
0 | 457 |
] ifFalse:[ |
59 | 458 |
self redrawFromLine:(oldEndLine min:selectionEndLine) |
459 |
to:(oldEndLine max:selectionEndLine) |
|
0 | 460 |
]. |
461 |
clickLine := movedLine. |
|
462 |
clickCol := movedCol |
|
463 |
! |
|
464 |
||
248 | 465 |
buttonMultiPress:button x:x y:y |
466 |
"multi-mouse-click - select word under pointer" |
|
467 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
468 |
|sel ch| |
248 | 469 |
|
470 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
471 |
clickCount notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
472 |
clickCount := clickCount + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
473 |
(clickCount == 2) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
474 |
self selectWordAtX:x y:y. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
475 |
" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
476 |
special - if clicked on a parenthesis, select to matching |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
477 |
" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
478 |
((sel := self selection) size == 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
479 |
and:[(sel := sel at:1) size == 1]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
480 |
ch := sel at:1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
481 |
('()[]{}<>' includes:ch) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
482 |
self searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
483 |
ifFound:[:line :col | |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
484 |
|prevLine prevCol| |
248 | 485 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
486 |
prevLine := firstLineShown. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
487 |
prevCol := leftOffset. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
488 |
self selectFromLine:selectionStartLine col:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
489 |
toLine:line col:col. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
490 |
self sensor ctrlDown ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
491 |
"/ undo scroll operation ... |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
492 |
self withCursor:Cursor eye do:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
493 |
(')]}>' includes:ch) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
494 |
(firstLineShown ~~ prevLine or:[prevCol ~~ leftOffset]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
495 |
Delay waitForSeconds:MatchDelayTime. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
496 |
self scrollToLine:prevLine; scrollToCol:prevCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
497 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
498 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
499 |
selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
500 |
self makeLineVisible:selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
501 |
Delay waitForSeconds:MatchDelayTime. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
502 |
self scrollToLine:prevLine; scrollToCol:prevCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
503 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
504 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
505 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
506 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
507 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
508 |
ifNotFound:[self showNotFound] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
509 |
onError:[device beep]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
510 |
selectStyle := nil |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
511 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
512 |
]. |
248 | 513 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
514 |
" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
515 |
remember words position in case of a drag following |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
516 |
" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
517 |
wordStartLine := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
518 |
wordEndLine := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
519 |
selectStyle == #wordLeft ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
520 |
wordStartCol := selectionStartCol + 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
521 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
522 |
wordStartCol := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
523 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
524 |
selectStyle == #wordRight ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
525 |
wordEndCol := selectionEndCol - 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
526 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
527 |
wordEndCol := selectionEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
528 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
529 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
530 |
(clickCount == 3) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
531 |
self selectLineAtY:y. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
532 |
selectStyle := #line |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
533 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
534 |
(clickCount == 4) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
535 |
self selectAll |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
536 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
537 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
538 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
539 |
] |
248 | 540 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
541 |
super buttonMultiPress:button x:x y:y |
248 | 542 |
] |
543 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
544 |
"Modified: 6.3.1996 / 14:55:11 / cg" |
248 | 545 |
! |
546 |
||
547 |
buttonPress:button x:x y:y |
|
548 |
"mouse-click - prepare for selection change" |
|
549 |
||
550 |
|clickVisibleLine| |
|
551 |
||
552 |
((button == 1) or:[button == #select]) ifTrue:[ |
|
553 |
clickVisibleLine := self visibleLineOfY:y. |
|
554 |
clickCol := self colOfX:x inVisibleLine:clickVisibleLine. |
|
555 |
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine. |
|
556 |
clickStartLine := clickLine. |
|
557 |
clickStartCol := clickCol. |
|
558 |
self unselect. |
|
559 |
clickCount := 1 |
|
560 |
] ifFalse:[ |
|
561 |
super buttonPress:button x:x y:y |
|
562 |
] |
|
563 |
! |
|
564 |
||
0 | 565 |
buttonRelease:button x:x y:y |
566 |
"mouse- button release - turn off autoScroll if any" |
|
567 |
||
38 | 568 |
((button == 1) or:[button == #select]) ifTrue:[ |
59 | 569 |
autoScrollBlock notNil ifTrue:[ |
570 |
self stopScrollSelect |
|
571 |
]. |
|
0 | 572 |
] ifFalse:[ |
59 | 573 |
super buttonRelease:button x:x y:y |
0 | 574 |
] |
248 | 575 |
! |
576 |
||
577 |
buttonShiftPress:button x:x y:y |
|
578 |
"mouse-click with shift - adding to selection" |
|
579 |
||
580 |
"very simple - just simulate a move" |
|
581 |
^ self buttonMotion:(device button1MotionMask) x:x y:y |
|
582 |
! |
|
583 |
||
584 |
keyPress:key x:x y:y |
|
585 |
"handle some keyboard input (there is not much to be done here)" |
|
586 |
||
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
587 |
<resource: #keyboard (#Find #Copy #FindNext #FindPrev |
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
588 |
#GotoLine #SelectAll #SaveAs)> |
248 | 589 |
|
590 |
(key == #Find) ifTrue:[self search. ^self]. |
|
591 |
(key == #Copy) ifTrue:[self copySelection. ^self]. |
|
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
592 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
248 | 593 |
|
594 |
(key == #FindNext) ifTrue:[self searchFwd. ^self]. |
|
595 |
(key == #FindPrev) ifTrue:[self searchBwd. ^self]. |
|
596 |
||
597 |
(key == #SelectAll) ifTrue:[self selectAll. ^self]. |
|
598 |
||
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
599 |
(key == #SaveAs) ifTrue:[self save. ^self]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
600 |
|
248 | 601 |
" |
602 |
shift-Fn defines a key-sequence |
|
603 |
Fn pastes that sequence |
|
604 |
cmd-Fn performs a 'doIt' on the sequence (Workspaces only) |
|
605 |
||
606 |
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y) |
|
607 |
" |
|
608 |
(('[fF][0-9]' match:key) |
|
609 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
326
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
610 |
self sensor shiftDown ifTrue:[ |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
611 |
(Smalltalk at:#FunctionKeySequences) isNil ifTrue:[ |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
612 |
Smalltalk at:#FunctionKeySequences put:Dictionary new |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
613 |
]. |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
614 |
(Smalltalk at:#FunctionKeySequences) at:key put:(self selection) |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
615 |
]. |
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
616 |
^ self |
248 | 617 |
]. |
618 |
||
619 |
super keyPress:key x:x y:y |
|
326
f04c328526c4
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
620 |
|
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
621 |
"Modified: 1.3.1996 / 18:42:53 / cg" |
248 | 622 |
! |
623 |
||
624 |
mapped |
|
625 |
super mapped. |
|
626 |
selectionFgColor := selectionFgColor on:device. |
|
627 |
selectionBgColor := selectionBgColor on:device. |
|
0 | 628 |
! ! |
248 | 629 |
|
630 |
!TextView methodsFor:'initialize & release'! |
|
631 |
||
632 |
initStyle |
|
633 |
super initStyle. |
|
634 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
635 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device]. |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
636 |
|
248 | 637 |
viewBackground := DefaultViewBackground. |
638 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
639 |
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor]. |
|
640 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
641 |
selectionBgColor isNil ifTrue:[ |
|
642 |
device hasColors ifTrue:[ |
|
643 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
644 |
selectionFgColor := fgColor |
|
645 |
]. |
|
646 |
selectionBgColor := Color green |
|
647 |
] ifFalse:[ |
|
648 |
device hasGreyscales ifTrue:[ |
|
649 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
650 |
selectionFgColor := fgColor |
|
651 |
]. |
|
652 |
selectionBgColor := Color grey |
|
653 |
] ifFalse:[ |
|
654 |
selectionBgColor := fgColor |
|
655 |
] |
|
656 |
] |
|
657 |
]. |
|
658 |
! |
|
659 |
||
660 |
initialize |
|
661 |
super initialize. |
|
662 |
contentsWasSaved := false. |
|
663 |
||
664 |
" |
|
665 |
initialize menu to be provided and performed by myself. |
|
666 |
This allows textViews without a model to provide a |
|
667 |
reasonable menu AND allows models to provide their own menu. |
|
668 |
" |
|
669 |
menuHolder := menuPerformer := self. |
|
670 |
menuMsg := #editMenu |
|
671 |
! ! |
|
672 |
||
673 |
!TextView methodsFor:'menu actions'! |
|
674 |
||
675 |
appendTo:fileName |
|
676 |
"append contents to a file named fileName" |
|
677 |
||
678 |
|aStream msg| |
|
679 |
||
680 |
aStream := FileStream appendingOldFileNamed:fileName. |
|
681 |
aStream isNil ifTrue:[ |
|
682 |
msg := resources string:'cannot append to file %1 !!' with:fileName. |
|
683 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
|
684 |
] ifFalse:[ |
|
685 |
self fileOutContentsOn:aStream. |
|
686 |
aStream close. |
|
687 |
contentsWasSaved := true |
|
688 |
] |
|
689 |
! |
|
690 |
||
691 |
changeFont |
|
692 |
"pop up a fontPanel to change font" |
|
693 |
||
411 | 694 |
|newFont| |
248 | 695 |
|
411 | 696 |
newFont := FontPanel fontFromUserInitial:font. |
697 |
newFont notNil ifTrue:[ |
|
698 |
self font:newFont. |
|
699 |
] |
|
700 |
||
701 |
"Modified: 27.2.1996 / 00:53:51 / cg" |
|
248 | 702 |
! |
703 |
||
704 |
copySelection |
|
705 |
"copy contents into smalltalk copybuffer" |
|
706 |
||
707 |
|text| |
|
708 |
||
709 |
text := self selection. |
|
710 |
text notNil ifTrue:[ |
|
711 |
self unselect. |
|
712 |
self setTextSelection:text |
|
713 |
] |
|
714 |
! |
|
715 |
||
716 |
defaultForGotoLine |
|
717 |
"return a default value to show in the gotoLine box" |
|
718 |
||
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
719 |
^ selectionStartLine |
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
720 |
|
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
721 |
"Modified: 1.3.1996 / 18:44:36 / cg" |
248 | 722 |
! |
723 |
||
724 |
editMenu |
|
489 | 725 |
<resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)> |
726 |
||
248 | 727 |
|labels selectors m| |
728 |
||
729 |
labels := #( |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
730 |
'copy' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
731 |
'-' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
732 |
'font ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
733 |
'-' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
734 |
'search ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
735 |
'goto ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
736 |
'-' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
737 |
'save as ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
738 |
'print' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
739 |
). |
248 | 740 |
|
741 |
selectors := #( |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
742 |
copySelection |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
743 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
744 |
changeFont |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
745 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
746 |
search |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
747 |
gotoLine |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
748 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
749 |
save |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
750 |
|
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
751 |
). |
248 | 752 |
|
753 |
m := PopUpMenu |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
754 |
labels:(resources array:labels) |
489 | 755 |
selectors:selectors |
756 |
accelerators:#( |
|
757 |
#Copy |
|
758 |
nil |
|
759 |
nil |
|
760 |
#Find |
|
761 |
#GotoLine |
|
762 |
nil |
|
763 |
#SaveAs |
|
764 |
||
765 |
). |
|
248 | 766 |
|
767 |
self hasSelection ifFalse:[ |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
768 |
m disable:#copySelection. |
248 | 769 |
]. |
770 |
^ m |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
771 |
|
489 | 772 |
"Modified: 7.3.1996 / 13:13:15 / cg" |
248 | 773 |
! |
774 |
||
775 |
gotoLine |
|
776 |
"show a box to enter lineNumber for positioning" |
|
777 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
778 |
|l lineNumberBox| |
248 | 779 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
780 |
lineNumberBox := |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
781 |
EnterBox |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
782 |
title:(resources string:'line number:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
783 |
okText:(resources string:'goto') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
784 |
abortText:(resources string:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
785 |
action:[:l | |num| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
786 |
num := Integer readFromString:l onError:nil. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
787 |
num notNil ifTrue:[self gotoLine:num] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
788 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
789 |
|
248 | 790 |
l := self defaultForGotoLine. |
791 |
l notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
792 |
l := l printString |
248 | 793 |
]. |
794 |
lineNumberBox initialText:l . |
|
795 |
lineNumberBox showAtPointer |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
796 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
797 |
"Modified: 6.3.1996 / 13:12:27 / cg" |
248 | 798 |
! |
799 |
||
800 |
||
801 |
"print the contents on the printer" |
|
802 |
||
803 |
|printStream| |
|
804 |
||
805 |
list isNil ifTrue:[^ self]. |
|
806 |
printStream := Printer new. |
|
807 |
printStream notNil ifTrue:[ |
|
486
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
808 |
Printer writeErrorSignal handle:[:ex | |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
809 |
self warn:('error while printing:\\' |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
810 |
, ex errorString |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
811 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
812 |
] do:[ |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
813 |
self fileOutContentsOn:printStream. |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
814 |
]. |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
815 |
printStream close |
248 | 816 |
] |
486
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
817 |
|
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
818 |
"Modified: 6.3.1996 / 18:28:14 / cg" |
248 | 819 |
! |
820 |
||
821 |
save |
|
822 |
"save contents into a file |
|
823 |
- ask user for filename using a fileSelectionBox." |
|
824 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
825 |
|fileBox| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
826 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
827 |
fileBox := FileSaveBox |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
828 |
title:(resources string:'save contents in:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
829 |
okText:(resources string:'save') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
830 |
abortText:(resources string:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
831 |
action:[:fileName | self saveAs:fileName]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
832 |
fileBox appendAction:[:fileName | self appendTo:fileName]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
833 |
directoryForFileDialog notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
834 |
fileBox directory:directoryForFileDialog |
248 | 835 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
836 |
fileBox showAtPointer. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
837 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
838 |
directoryForFileDialog := fileBox directory "/ remember for next time |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
839 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
840 |
"Modified: 6.3.1996 / 13:09:19 / cg" |
248 | 841 |
! |
842 |
||
843 |
saveAs:fileName |
|
844 |
"save contents into a file named fileName" |
|
845 |
||
846 |
|aStream msg| |
|
847 |
||
848 |
aStream := FileStream newFileNamed:fileName. |
|
849 |
aStream isNil ifTrue:[ |
|
850 |
msg := resources string:'cannot write file %1 !!' with:fileName. |
|
851 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
|
852 |
] ifFalse:[ |
|
853 |
self fileOutContentsOn:aStream. |
|
854 |
aStream close. |
|
855 |
contentsWasSaved := true |
|
856 |
] |
|
857 |
! ! |
|
858 |
||
859 |
!TextView methodsFor:'private'! |
|
860 |
||
861 |
fileOutContentsOn:aStream |
|
862 |
"save contents on a stream, replacing leading spaces by tab-characters." |
|
863 |
||
864 |
self fileOutContentsOn:aStream compressTabs:true |
|
865 |
! |
|
866 |
||
867 |
fileOutContentsOn:aStream compressTabs:compressTabs |
|
868 |
"save contents on a stream. If compressTabs is true, |
|
869 |
leading spaces will be replaced by tab-characters in the output." |
|
870 |
||
871 |
|startNr nLines string| |
|
872 |
||
873 |
"on some systems, writing linewise is very slow (via NFS) |
|
874 |
therefore we convert to a string and write it in big chunks. |
|
875 |
To avoid creating huge strings, we do it in blocks of 1000 lines, |
|
876 |
limiting temporary string creation to about 50-80k. |
|
877 |
" |
|
878 |
startNr := 1. |
|
879 |
nLines := list size. |
|
880 |
[startNr <= nLines] whileTrue:[ |
|
881 |
string := list asStringWithCRsFrom:startNr |
|
882 |
to:((startNr + 1000) min:nLines) |
|
883 |
compressTabs:compressTabs. |
|
884 |
aStream nextPutAll:string. |
|
885 |
startNr := startNr + 1000 + 1. |
|
886 |
]. |
|
887 |
||
888 |
"/ "the old (obsolete) code:" |
|
889 |
"/ |
|
890 |
"/ list do:[:aLine | |
|
891 |
"/ aLine notNil ifTrue:[ |
|
892 |
"/ aStream nextPutAll:aLine. |
|
893 |
"/ ]. |
|
894 |
"/ aStream cr |
|
895 |
"/ ] |
|
896 |
||
897 |
! |
|
898 |
||
899 |
scrollSelectDown |
|
900 |
"auto scroll action; scroll and reinstall timed-block" |
|
901 |
||
902 |
|prevEndLine| |
|
903 |
||
904 |
"just to make certain ..." |
|
905 |
selectionEndLine isNil ifTrue:[^ self]. |
|
906 |
||
907 |
self scrollDown. |
|
908 |
||
909 |
"make new selection immediately visible" |
|
910 |
prevEndLine := selectionEndLine. |
|
911 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
912 |
selectionEndCol := 0. |
|
913 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
914 |
self redrawLine:lineNr |
|
915 |
]. |
|
916 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
917 |
! |
|
918 |
||
919 |
scrollSelectLeft |
|
920 |
"auto scroll action; scroll and reinstall timed-block" |
|
921 |
||
922 |
|prevStartLine| |
|
923 |
||
924 |
"just to make certain ..." |
|
925 |
selectionStartLine isNil ifTrue:[^ self]. |
|
926 |
selectionStartCol isNil ifTrue:[^ self]. |
|
927 |
||
928 |
"make new selection immediately visible" |
|
929 |
prevStartLine := selectionStartLine. |
|
930 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
931 |
self scrollLeft. |
|
932 |
||
933 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
934 |
! |
|
935 |
||
936 |
scrollSelectRight |
|
937 |
"auto scroll action; scroll and reinstall timed-block" |
|
938 |
||
939 |
|prevEndCol| |
|
940 |
||
941 |
"just to make certain ..." |
|
942 |
selectionEndCol isNil ifTrue:[^ self]. |
|
943 |
||
944 |
prevEndCol := selectionEndCol. |
|
945 |
selectionEndCol := selectionEndCol + 1. |
|
946 |
self scrollRight. |
|
947 |
||
948 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
949 |
! |
|
950 |
||
951 |
scrollSelectUp |
|
952 |
"auto scroll action; scroll and reinstall timed-block" |
|
953 |
||
954 |
|prevStartLine| |
|
955 |
||
956 |
"just to make certain ..." |
|
957 |
selectionStartLine isNil ifTrue:[^ self]. |
|
958 |
||
959 |
self scrollUp. |
|
960 |
||
961 |
"make new selection immediately visible" |
|
962 |
prevStartLine := selectionStartLine. |
|
963 |
selectionStartLine := firstLineShown. |
|
964 |
selectionStartCol := 1. |
|
965 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
966 |
self redrawLine:lineNr |
|
967 |
]. |
|
968 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
969 |
! |
|
970 |
||
971 |
stopScrollSelect |
|
972 |
"stop auto scroll; deinstall timed-block" |
|
973 |
||
974 |
autoScrollBlock notNil ifTrue:[ |
|
975 |
Processor removeTimedBlock:autoScrollBlock. |
|
976 |
self compressMotionEvents:true. |
|
977 |
autoScrollBlock := nil. |
|
978 |
autoScrollDeltaT := nil |
|
979 |
] |
|
980 |
! |
|
981 |
||
982 |
widthForScrollBetween:firstLine and:lastLine |
|
983 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
984 |
||
985 |
selectionStartLine notNil ifTrue:[ |
|
986 |
(lastLine < selectionStartLine) ifFalse:[ |
|
987 |
(firstLine > selectionEndLine) ifFalse:[ |
|
988 |
^ width |
|
989 |
] |
|
990 |
] |
|
991 |
]. |
|
992 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
993 |
! ! |
|
994 |
||
995 |
!TextView methodsFor:'redrawing'! |
|
996 |
||
997 |
clearMarginOfVisible:visLine with:color |
|
998 |
"if there is a margin, clear it - a helper for selection drawing" |
|
999 |
||
1000 |
(leftMargin ~~ 0) ifTrue:[ |
|
1001 |
self paint:color. |
|
1002 |
self fillRectangleX:margin |
|
1003 |
y:(self yOfVisibleLine:visLine) |
|
1004 |
width:leftMargin |
|
1005 |
height:fontHeight |
|
1006 |
] |
|
1007 |
! |
|
1008 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1009 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1010 |
"if there is a margin, clear it - a helper for selection drawing" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1011 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1012 |
(leftMargin ~~ 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1013 |
self paint:color. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1014 |
self fillRectangleX:margin |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1015 |
y:(self yOfVisibleLine:visLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1016 |
width:leftMargin |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1017 |
height:fontHeight |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1018 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1019 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1020 |
"Created: 6.3.1996 / 14:22:55 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1021 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1022 |
|
248 | 1023 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
1024 |
"redraw a visible line range" |
|
1025 |
||
1026 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
1027 |
||
1028 |
shown ifFalse:[^ self]. |
|
1029 |
||
1030 |
end := endVisLineNr. |
|
1031 |
(end > nLinesShown) ifTrue:[ |
|
1032 |
end := nLinesShown |
|
1033 |
]. |
|
1034 |
||
1035 |
selectionStartLine isNil ifTrue:[ |
|
1036 |
specialCare := false |
|
1037 |
] ifFalse:[ |
|
1038 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
|
1039 |
(startLine > selectionEndLine) ifTrue:[ |
|
1040 |
specialCare := false |
|
1041 |
] ifFalse:[ |
|
1042 |
endLine := self visibleLineToAbsoluteLine:end. |
|
1043 |
(endLine < selectionStartLine) ifTrue:[ |
|
1044 |
specialCare := false |
|
1045 |
] ifFalse:[ |
|
1046 |
specialCare := true |
|
1047 |
] |
|
1048 |
] |
|
1049 |
]. |
|
1050 |
||
1051 |
"easy: nothing is selected" |
|
1052 |
specialCare ifFalse:[ |
|
1053 |
super redrawFromVisibleLine:startVisLineNr to:end. |
|
1054 |
^ self |
|
1055 |
]. |
|
1056 |
||
1057 |
"easy: all is selected" |
|
1058 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
1059 |
self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor |
|
1060 |
and:selectionBgColor. |
|
1061 |
^ self |
|
1062 |
]. |
|
1063 |
||
1064 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
1065 |
"draw unselected top part" |
|
1066 |
||
1067 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
1068 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
1069 |
||
1070 |
"and first partial selected line" |
|
1071 |
self redrawVisibleLine:selVisStart. |
|
1072 |
||
1073 |
"rest starts after this one" |
|
1074 |
line1 := selVisStart + 1 |
|
1075 |
] ifFalse:[ |
|
1076 |
line1 := 1 |
|
1077 |
]. |
|
1078 |
||
1079 |
(line1 > end) ifTrue:[^ self]. |
|
1080 |
(line1 < startVisLineNr) ifTrue:[ |
|
1081 |
line1 := startVisLineNr |
|
1082 |
]. |
|
1083 |
||
1084 |
"draw middle part of selection" |
|
1085 |
||
1086 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
1087 |
line2 := nLinesShown |
|
1088 |
] ifFalse:[ |
|
1089 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
|
1090 |
]. |
|
1091 |
(line2 > end) ifTrue:[ |
|
1092 |
line2 := end |
|
1093 |
]. |
|
1094 |
||
1095 |
self drawFromVisibleLine:line1 to:line2 with:selectionFgColor |
|
1096 |
and:selectionBgColor. |
|
1097 |
||
1098 |
(line2 >= end) ifTrue:[^ self]. |
|
1099 |
||
1100 |
"last line of selection" |
|
1101 |
self redrawVisibleLine:(line2 + 1). |
|
1102 |
||
1103 |
((line2 + 2) <= end) ifTrue:[ |
|
1104 |
super redrawFromVisibleLine:(line2 + 2) to:end |
|
1105 |
] |
|
1106 |
! |
|
1107 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1108 |
redrawMarginOfVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1109 |
"draw margin - a helper for selection drawing" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1110 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1111 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1112 |
(leftMargin ~~ 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1113 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1114 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1115 |
"Created: 6.3.1996 / 14:21:48 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1116 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1117 |
|
248 | 1118 |
redrawVisibleLine:visLine |
1119 |
"redraw visible line lineNr" |
|
1120 |
||
1121 |
|len line l| |
|
1122 |
||
1123 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1124 |
line := self visibleLineToAbsoluteLine:visLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1125 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1126 |
(line == selectionStartLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1127 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1128 |
"its part-of-single-line selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1129 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1130 |
(selectionStartCol > 1) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1131 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1132 |
from:1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1133 |
to:(selectionStartCol - 1) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1134 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1135 |
self drawVisibleLine:visLine from:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1136 |
to:selectionEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1137 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1138 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1139 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1140 |
from:(selectionEndCol + 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1141 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1142 |
]. |
248 | 1143 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1144 |
"its the first line of a multi-line selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1145 |
(selectionStartCol ~~ 1) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1146 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1147 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1148 |
from:1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1149 |
to:(selectionStartCol - 1) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1150 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1151 |
leftOffset == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1152 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1153 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1154 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1155 |
self drawVisibleLine:visLine from:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1156 |
with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1157 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1158 |
]. |
248 | 1159 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1160 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1161 |
"its the last line of a multi-line selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1162 |
(selectionEndCol == 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1163 |
^ super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1164 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1165 |
l := self visibleAt:selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1166 |
len := l size. |
248 | 1167 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1168 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1169 |
self drawVisibleLine:visLine from:1 to:selectionEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1170 |
with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1171 |
super redrawVisibleLine:visLine from:(selectionEndCol + 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1172 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1173 |
]. |
248 | 1174 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1175 |
"its a full line in a multi-line selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1176 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1177 |
self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1178 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1179 |
] |
248 | 1180 |
]. |
1181 |
super redrawVisibleLine:visLine |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1182 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1183 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 1184 |
! |
1185 |
||
1186 |
redrawVisibleLine:visLine col:col |
|
1187 |
"redraw single character at col in visible line lineNr" |
|
1188 |
||
1189 |
|line| |
|
1190 |
||
1191 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1192 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1193 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1194 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1195 |
and: [col < selectionStartCol]) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1196 |
((line == selectionEndLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1197 |
and: [col > selectionEndCol]) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1198 |
"its in the selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1199 |
self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1200 |
drawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1201 |
col:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1202 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1203 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1204 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1205 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1206 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1207 |
] |
248 | 1208 |
]. |
1209 |
super redrawVisibleLine:visLine col:col |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1210 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1211 |
"Modified: 6.3.1996 / 14:20:14 / cg" |
248 | 1212 |
! |
1213 |
||
1214 |
redrawVisibleLine:visLine from:startCol |
|
1215 |
"redraw visible line lineNr from startCol to end of line" |
|
1216 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1217 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1218 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1219 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1220 |
col == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1221 |
col := 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1222 |
]. |
248 | 1223 |
|
1224 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1225 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1226 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1227 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1228 |
or:[line == selectionEndLine]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1229 |
"since I'm lazy, redraw full line" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1230 |
self redrawVisibleLine:visLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1231 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1232 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1233 |
"the line is fully within the selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1234 |
self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1235 |
drawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1236 |
from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1237 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1238 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1239 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1240 |
] |
248 | 1241 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1242 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1243 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1244 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 1245 |
! |
1246 |
||
1247 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
1248 |
"redraw visible line lineNr from startCol to endCol" |
|
1249 |
||
1250 |
|line allOut allIn leftCol rightCol| |
|
1251 |
||
1252 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1253 |
||
1254 |
allIn := false. |
|
1255 |
allOut := false. |
|
1256 |
selectionStartLine isNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1257 |
allOut := true |
248 | 1258 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1259 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1260 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1261 |
] ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1262 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1263 |
((endCol < selectionStartCol) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1264 |
or:[startCol > selectionEndCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1265 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1266 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1267 |
((startCol >= selectionStartCol) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1268 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1269 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1270 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1271 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1272 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1273 |
(line == selectionStartLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1274 |
(endCol < selectionStartCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1275 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1276 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1277 |
(startCol >= selectionStartCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1278 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1279 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1280 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1281 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1282 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1283 |
(startCol > selectionEndCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1284 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1285 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1286 |
(endCol <= selectionEndCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1287 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1288 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1289 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1290 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1291 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1292 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1293 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1294 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1295 |
] |
248 | 1296 |
]. |
1297 |
allOut ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1298 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1299 |
^ self |
248 | 1300 |
]. |
1301 |
||
1302 |
allIn ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1303 |
self drawVisibleLine:visLine from:startCol to:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1304 |
with:selectionFgColor and:selectionBgColor |
248 | 1305 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1306 |
"redraw part before selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1307 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1308 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1309 |
super redrawVisibleLine:visLine from:startCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1310 |
to:(selectionStartCol - 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1311 |
leftCol := selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1312 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1313 |
leftCol := startCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1314 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1315 |
"redraw selected part" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1316 |
(selectionEndLine > line) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1317 |
rightCol := endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1318 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1319 |
rightCol := selectionEndCol min:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1320 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1321 |
self drawVisibleLine:visLine from:leftCol to:rightCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1322 |
with:selectionFgColor and:selectionBgColor. |
248 | 1323 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1324 |
"redraw part after selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1325 |
(rightCol < endCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1326 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1327 |
] |
248 | 1328 |
]. |
1329 |
||
1330 |
"special care for first and last line of selection: |
|
1331 |
must handle margin also" |
|
1332 |
||
1333 |
((line == selectionEndLine) |
|
1334 |
and:[(startCol == 1) |
|
1335 |
and:[selectionStartLine < selectionEndLine]]) |
|
1336 |
ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1337 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
248 | 1338 |
]. |
1339 |
||
1340 |
((line == selectionStartLine) |
|
1341 |
and:[(startCol == 1) |
|
1342 |
and:[selectionStartLine < selectionEndLine]]) |
|
1343 |
ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1344 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
248 | 1345 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1346 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1347 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 1348 |
! ! |
1349 |
||
1350 |
!TextView methodsFor:'searching'! |
|
1351 |
||
1352 |
search |
|
1353 |
"show a box to enter searchpattern |
|
1354 |
- currently no regular expressions are handled." |
|
1355 |
||
1356 |
" |
|
1357 |
cache the searchBox |
|
1358 |
Q: should we use one global searchBox for all textViews ? |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1359 |
(we could then preserve the last searchstring between views) |
248 | 1360 |
" |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1361 |
|searchBox| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1362 |
|
248 | 1363 |
|
1364 |
"/ "soon to come: search & replace box ... |
|
1365 |
"/ |box| |
|
1366 |
"/ |
|
1367 |
"/ box := Dialog new. |
|
1368 |
"/ (box addTextLabel:(resources at:'searchPattern:')) layout:#left. |
|
1369 |
"/ box addVerticalSpace. |
|
1370 |
"/ box addInputFieldOn:'' asValue. |
|
1371 |
"/ box addVerticalSpace. |
|
1372 |
"/ (box addTextLabel:(resources at:'replace with:')) layout:#left. |
|
1373 |
"/ box addVerticalSpace. |
|
1374 |
"/ box addInputFieldOn:'' asValue. |
|
1375 |
"/ box addAbortButtonLabelled:(resources at:'cancel'); |
|
1376 |
"/ addButton:(Button label:(resources at:'all')); |
|
1377 |
"/ addButton:(Button label:(resources at:'prev')); |
|
1378 |
"/ addOkButtonLabelled:(resources at:'next'). |
|
1379 |
"/ box open. |
|
1380 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1381 |
searchBox := |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1382 |
EnterBox2 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1383 |
title:(resources at:'searchPattern:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1384 |
okText1:(resources at:'prev') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1385 |
okText2:(resources at:'next') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1386 |
abortText:(resources at:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1387 |
action1:[:pattern | pattern notEmpty ifTrue:[self searchBwd:(pattern withoutSeparators)]] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1388 |
action2:[:pattern | pattern notEmpty ifTrue:[self searchFwd:(pattern withoutSeparators)]]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1389 |
|
248 | 1390 |
searchPattern notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1391 |
searchBox initialText:searchPattern |
248 | 1392 |
]. |
1393 |
self hasSelection ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1394 |
selectionStartLine == selectionEndLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1395 |
searchBox initialText:self selection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1396 |
] |
248 | 1397 |
]. |
1398 |
searchBox showAtPointer |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1399 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1400 |
"Modified: 6.3.1996 / 13:11:46 / cg" |
248 | 1401 |
! |
1402 |
||
1403 |
searchBwd |
|
1404 |
"search backward and -if found- position cursor" |
|
1405 |
||
1406 |
self setSearchPattern. |
|
1407 |
searchPattern notNil ifTrue:[ |
|
1408 |
self searchBwd:searchPattern |
|
1409 |
] |
|
1410 |
! |
|
1411 |
||
1412 |
searchBwd:pattern |
|
1413 |
"do a backward search" |
|
1414 |
||
1415 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
1416 |
searchPattern := pattern |
|
1417 |
||
1418 |
! |
|
1419 |
||
1420 |
searchBwd:pattern ifAbsent:aBlock |
|
1421 |
"do a backward search" |
|
1422 |
||
1423 |
|startLine startCol| |
|
1424 |
||
1425 |
selectionStartLine notNil ifTrue:[ |
|
1426 |
startLine := selectionStartLine. |
|
1427 |
startCol := selectionStartCol |
|
1428 |
] ifFalse:[ |
|
1429 |
startLine := 1. |
|
1430 |
startCol := 1 |
|
1431 |
]. |
|
1432 |
self searchBackwardFor:pattern startingAtLine:startLine col:startCol |
|
1433 |
ifFound:[:line :col | |
|
1434 |
self showMatch:pattern atLine:line col:col |
|
1435 |
] ifAbsent:aBlock |
|
1436 |
! |
|
1437 |
||
1438 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1439 |
ifFound:foundBlock |
|
1440 |
ifNotFound:notFoundBlock |
|
1441 |
onError:failBlock |
|
1442 |
||
1443 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
|
1444 |
Search for the corresponding character is done forward if its an opening, |
|
1445 |
backwards if its a closing parenthesis. |
|
1446 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
1447 |
If there is a nesting error, performs failBlock." |
|
1448 |
||
1449 |
^ self |
|
1450 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1451 |
ifFound:foundBlock |
|
1452 |
ifNotFound:notFoundBlock |
|
1453 |
onError:failBlock |
|
1454 |
ignoring:#( $' $" ) |
|
1455 |
||
1456 |
"Modified: 18.11.1995 / 16:28:23 / cg" |
|
1457 |
! |
|
1458 |
||
1459 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1460 |
ifFound:foundBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1461 |
ifNotFound:notFoundBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1462 |
onError:failBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1463 |
ignoring:ignoreSet |
248 | 1464 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
1465 |
Search for the corresponding character is done forward if its an opening, |
|
1466 |
backwards if its a closing parenthesis. |
|
1467 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
1468 |
If there is a nesting error, performs failBlock." |
|
1469 |
||
1470 |
|i direction lineString line col parChar charSet closingChar |
|
1471 |
ignoring delta endCol cc incSet decSet nesting maxLine| |
|
1472 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1473 |
charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
248 | 1474 |
|
1475 |
parChar := self characterAtLine:startLine col:startCol. |
|
1476 |
i := charSet indexOf:parChar. |
|
1477 |
i == 0 ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1478 |
^ failBlock value "not a parenthesis" |
248 | 1479 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1480 |
direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1481 |
closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
248 | 1482 |
|
1483 |
col := startCol. |
|
1484 |
line := startLine. |
|
1485 |
direction == #fwd ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1486 |
delta := 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1487 |
incSet := #( $( $[ ${ "$<" ). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1488 |
decSet := #( $) $] $} "$>" ). |
248 | 1489 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1490 |
delta := -1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1491 |
incSet := #( $) $] $} "$>" ). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1492 |
decSet := #( $( $[ ${ "$<" ). |
248 | 1493 |
]. |
1494 |
||
1495 |
nesting := 1. |
|
1496 |
ignoring := false. |
|
1497 |
lineString := list at:line. |
|
1498 |
maxLine := list size. |
|
1499 |
||
1500 |
col := col + delta. |
|
1501 |
[nesting ~~ 0] whileTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1502 |
lineString notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1503 |
direction == #fwd ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1504 |
endCol := lineString size. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1505 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1506 |
endCol := 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1507 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1508 |
col to:endCol by:delta do:[:runCol | |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1509 |
cc := lineString at:runCol. |
248 | 1510 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1511 |
(ignoreSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1512 |
ignoring := ignoring not |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1513 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1514 |
ignoring ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1515 |
(incSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1516 |
nesting := nesting + 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1517 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1518 |
(decSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1519 |
nesting := nesting - 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1520 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1521 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1522 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1523 |
nesting == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1524 |
"check if legal" |
248 | 1525 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1526 |
cc == closingChar ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1527 |
^ failBlock value |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1528 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1529 |
^ foundBlock value:line value:runCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1530 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1531 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1532 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1533 |
line := line + delta. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1534 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1535 |
^ failBlock value |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1536 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1537 |
lineString := list at:line. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1538 |
direction == #fwd ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1539 |
col := 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1540 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1541 |
col := lineString size |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1542 |
] |
248 | 1543 |
]. |
1544 |
||
1545 |
^ notFoundBlock value |
|
1546 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1547 |
"Modified: 6.3.1996 / 14:58:29 / cg" |
248 | 1548 |
! |
1549 |
||
1550 |
searchFwd |
|
1551 |
"search forward for pattern or selection" |
|
1552 |
||
1553 |
selectStyle == #wordLeft ifTrue:[ |
|
1554 |
" |
|
1555 |
remove the space from the selection |
|
1556 |
" |
|
1557 |
selectionStartCol := selectionStartCol + 1. |
|
1558 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1559 |
selectStyle := #word. |
248 | 1560 |
]. |
1561 |
self setSearchPattern. |
|
1562 |
searchPattern notNil ifTrue:[ |
|
1563 |
self searchFwd:searchPattern |
|
1564 |
] |
|
1565 |
! |
|
1566 |
||
1567 |
searchFwd:pattern |
|
1568 |
"do a forward search" |
|
1569 |
||
1570 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
1571 |
searchPattern := pattern |
|
1572 |
! |
|
1573 |
||
1574 |
searchFwd:pattern ifAbsent:aBlock |
|
1575 |
"do a forward search" |
|
1576 |
||
1577 |
|startLine startCol| |
|
1578 |
||
1579 |
selectionStartLine notNil ifTrue:[ |
|
1580 |
startLine := selectionStartLine. |
|
1581 |
startCol := selectionStartCol |
|
1582 |
] ifFalse:[ |
|
1583 |
startLine := 1. |
|
1584 |
startCol := 1 |
|
1585 |
]. |
|
1586 |
self searchForwardFor:pattern startingAtLine:startLine col:startCol |
|
1587 |
ifFound:[:line :col | |
|
1588 |
self showMatch:pattern atLine:line col:col |
|
1589 |
] ifAbsent:aBlock |
|
1590 |
! |
|
1591 |
||
1592 |
searchPattern |
|
1593 |
"return the last search pattern" |
|
1594 |
||
1595 |
^ searchPattern |
|
1596 |
! |
|
1597 |
||
1598 |
setSearchPattern |
|
1599 |
"set the searchpattern from the selection if there is one" |
|
1600 |
||
1601 |
|sel| |
|
1602 |
||
1603 |
sel := self selection. |
|
1604 |
sel notNil ifTrue:[ |
|
1605 |
searchPattern := sel asString withoutSeparators |
|
1606 |
] |
|
1607 |
! |
|
1608 |
||
1609 |
setSearchPattern:aString |
|
1610 |
"set the searchpattern for future searches" |
|
1611 |
||
1612 |
aString isNil ifTrue:[ |
|
1613 |
searchPattern := aString |
|
1614 |
] ifFalse:[ |
|
1615 |
searchPattern := aString withoutSeparators |
|
1616 |
] |
|
1617 |
! |
|
1618 |
||
1619 |
showMatch:pattern atLine:line col:col |
|
1620 |
"after a search, highlight the matched pattern. |
|
1621 |
The code below needs a rewrite to take care of match-characters |
|
1622 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
1623 |
||
1624 |
|realPattern| |
|
1625 |
||
1626 |
realPattern := pattern. |
|
1627 |
(realPattern startsWith:$*) ifTrue:[ |
|
1628 |
realPattern := realPattern copyFrom:2 |
|
1629 |
]. |
|
1630 |
(realPattern endsWith:$*) ifTrue:[ |
|
1631 |
realPattern := realPattern copyWithoutLast:1 |
|
1632 |
]. |
|
1633 |
||
1634 |
self selectFromLine:line col:col |
|
1635 |
toLine:line col:(col + realPattern size - 1). |
|
1636 |
self makeLineVisible:line |
|
1637 |
! |
|
1638 |
||
1639 |
showNotFound |
|
1640 |
"search not found - tell user by beeping and changing |
|
1641 |
cursor for a while (sometimes I work with a headset :-) |
|
1642 |
(used to be: tell user by changing cursor for a while)" |
|
1643 |
||
1644 |
|savedCursor| |
|
1645 |
||
1646 |
device beep. |
|
1647 |
||
1648 |
" |
|
1649 |
uncomment if you want a CROSS cursor to be shown for a while .. |
|
1650 |
" |
|
1651 |
||
1652 |
" " |
|
1653 |
savedCursor := cursor. |
|
1654 |
self cursor:(Cursor cross). |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1655 |
Processor activeProcess millisecondDelay:300. |
248 | 1656 |
self cursor:savedCursor |
1657 |
" " |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1658 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1659 |
"Modified: 16.12.1995 / 13:11:31 / cg" |
248 | 1660 |
! ! |
1661 |
||
1662 |
!TextView methodsFor:'selections'! |
|
1663 |
||
458 | 1664 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1665 |
|l t| |
458 | 1666 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1667 |
selectionStartLine notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1668 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1669 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1670 |
selectionStartLine := selectionStartLine + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1671 |
(selectionStartLine > clickLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1672 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1673 |
ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1674 |
t := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1675 |
selectionStartLine := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1676 |
selectionEndLine := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1677 |
t := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1678 |
selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1679 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1680 |
expandingTop := false |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1681 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1682 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1683 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1684 |
selectionEndLine := selectionEndLine + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1685 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1686 |
self redrawLine:l. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1687 |
self redrawLine:l+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1688 |
self makeSelectionVisible. |
458 | 1689 |
]. |
1690 |
||
1691 |
"Created: 1.3.1996 / 23:35:08 / cg" |
|
502 | 1692 |
"Modified: 18.3.1996 / 17:18:15 / cg" |
458 | 1693 |
! |
1694 |
||
1695 |
expandSelectionLeft |
|
502 | 1696 |
|c l t c1 c2| |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1697 |
|
458 | 1698 |
selectionStartLine notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1699 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1700 |
selectionStartCol == 0 ifTrue:[^ self]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1701 |
l := selectionStartLine. |
502 | 1702 |
selectionStartCol := (selectionStartCol - 1) max:1. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1703 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1704 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1705 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1706 |
selectionEndCol := (selectionEndCol - 1) max:0. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1707 |
c := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1708 |
selectionEndLine == selectionStartLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1709 |
selectionEndCol <= selectionStartCol ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1710 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1711 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1712 |
expandingTop := true. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1713 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1714 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1715 |
]. |
458 | 1716 |
]. |
502 | 1717 |
c1 := c. |
1718 |
c2 := c1 + 1. |
|
1719 |
c1 == 0 ifTrue:[ |
|
1720 |
c1 := 1 |
|
1721 |
]. |
|
1722 |
self redrawLine:l from:c1 to:c2. |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1723 |
self makeSelectionVisible. |
458 | 1724 |
]. |
1725 |
||
502 | 1726 |
"Modified: 18.3.1996 / 17:05:46 / cg" |
458 | 1727 |
! |
1728 |
||
1729 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1730 |
|l c t| |
458 | 1731 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1732 |
selectionStartLine notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1733 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1734 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1735 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1736 |
selectionStartCol := selectionStartCol + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1737 |
l == selectionEndLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1738 |
c >= selectionEndCol ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1739 |
expandingTop := false. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1740 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1741 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1742 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1743 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1744 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1745 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1746 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1747 |
c := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1748 |
selectionEndCol := selectionEndCol + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1749 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1750 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1751 |
self redrawLine:l from:c to:c+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1752 |
self makeSelectionVisible. |
458 | 1753 |
]. |
1754 |
||
1755 |
"Created: 1.3.1996 / 23:33:17 / cg" |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1756 |
"Modified: 6.3.1996 / 13:54:10 / cg" |
458 | 1757 |
! |
1758 |
||
1759 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1760 |
|l t| |
458 | 1761 |
|
1762 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1763 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1764 |
selectionStartLine := (selectionStartLine - 1) max:1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1765 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1766 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1767 |
selectionEndLine := (selectionEndLine - 1) max:0. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1768 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1769 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1770 |
(selectionEndLine < clickLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1771 |
or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])]) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1772 |
ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1773 |
t := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1774 |
selectionStartLine := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1775 |
selectionEndLine := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1776 |
t := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1777 |
selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1778 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1779 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1780 |
expandingTop := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1781 |
]. |
458 | 1782 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1783 |
self redrawLine:l. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1784 |
self redrawLine:l+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1785 |
self makeSelectionVisible. |
458 | 1786 |
]. |
1787 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1788 |
"Modified: 6.3.1996 / 14:12:06 / cg" |
458 | 1789 |
! |
1790 |
||
248 | 1791 |
hasSelection |
1792 |
"return true, if there is a selection" |
|
1793 |
||
1794 |
^ selectionStartLine notNil |
|
1795 |
! |
|
1796 |
||
1797 |
makeSelectionVisible |
|
1798 |
"scroll to make the selection visible" |
|
1799 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1800 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1801 |
|
248 | 1802 |
selectionStartLine notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1803 |
expandingTop ~~ false ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1804 |
line := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1805 |
col := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1806 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1807 |
line := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1808 |
col := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1809 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1810 |
self makeLineVisible:line. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1811 |
self makeColVisible:col inLine:line. |
248 | 1812 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1813 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1814 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 1815 |
! |
1816 |
||
1817 |
selectAll |
|
1818 |
"select the whole text" |
|
1819 |
||
1820 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
1821 |
! |
|
1822 |
||
1823 |
selectFromCharacterPosition:pos1 to:pos2 |
|
1824 |
"compute line/col from character positions and select the text" |
|
1825 |
||
1826 |
|line1 col1 line2 col2| |
|
1827 |
||
1828 |
line1 := self lineOfCharacterPosition:pos1. |
|
1829 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
1830 |
line2 := self lineOfCharacterPosition:pos2. |
|
1831 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
1832 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
1833 |
! |
|
1834 |
||
1835 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
1836 |
"select a piece of text and redraw that area" |
|
1837 |
||
1838 |
self unselect. |
|
1839 |
startLine notNil ifTrue:[ |
|
1840 |
"new:" |
|
1841 |
endLine < startLine ifTrue:[ |
|
1842 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
|
1843 |
]. |
|
1844 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
|
1845 |
endCol ~~ 0 ifTrue:[ |
|
1846 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
|
1847 |
]. |
|
1848 |
^ self |
|
1849 |
]. |
|
1850 |
||
1851 |
" old: |
|
1852 |
endLine < startLine ifTrue:[^ self]. |
|
1853 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
|
1854 |
" |
|
1855 |
selectionStartLine := startLine. |
|
1856 |
selectionStartCol := startCol. |
|
1857 |
selectionEndLine := endLine. |
|
1858 |
selectionEndCol := endCol. |
|
1859 |
(startLine == endLine) ifTrue:[ |
|
1860 |
self redrawLine:startLine from:startCol to:endCol |
|
1861 |
] ifFalse:[ |
|
1862 |
startLine to:endLine do:[:lineNr | |
|
1863 |
self redrawLine:lineNr |
|
1864 |
] |
|
1865 |
]. |
|
1866 |
selectStyle := nil. |
|
1867 |
] |
|
1868 |
! |
|
1869 |
||
1870 |
selectLine:selectLine |
|
1871 |
"select one line and redraw it" |
|
1872 |
||
1873 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
1874 |
wordStartCol := selectionStartCol. |
|
1875 |
wordEndCol := selectionEndCol. |
|
1876 |
wordStartLine := selectionStartLine. |
|
1877 |
wordEndLine := selectionEndLine. |
|
1878 |
selectStyle := #line |
|
1879 |
! |
|
1880 |
||
1881 |
selectLineAtY:y |
|
1882 |
"select the line at given y-(view-)coordinate" |
|
1883 |
||
1884 |
|selectVisibleLine selectLine| |
|
1885 |
||
1886 |
selectVisibleLine := self visibleLineOfY:y. |
|
1887 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
1888 |
selectLine notNil ifTrue:[ |
|
1889 |
self selectLine:selectLine |
|
1890 |
] |
|
1891 |
! |
|
1892 |
||
1893 |
selectLineWhereCharacterPosition:pos |
|
1894 |
"select the line, where characterPosition pos is living. |
|
1895 |
The argument pos starts at 1 from the start of the text |
|
1896 |
and counts characters (i.e. can be used to convert from |
|
1897 |
character position within a string to line-position in view)." |
|
1898 |
||
1899 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
1900 |
! |
|
1901 |
||
1902 |
selectWordAtLine:line col:col |
|
1903 |
"select the word at given line/col" |
|
1904 |
||
1905 |
self wordAtLine:line col:col do:[ |
|
1906 |
:beginLine :beginCol :endLine :endCol :style | |
|
1907 |
||
1908 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
1909 |
selectStyle := style |
|
1910 |
] |
|
1911 |
! |
|
1912 |
||
1913 |
selectWordAtX:x y:y |
|
1914 |
"select the word at given x/y-(view-)coordinate" |
|
1915 |
||
1916 |
|selectVisibleLine selectLine selectCol| |
|
1917 |
||
1918 |
selectStyle := nil. |
|
1919 |
selectVisibleLine := self visibleLineOfY:y. |
|
1920 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
1921 |
selectLine notNil ifTrue:[ |
|
1922 |
selectCol := self colOfX:x inVisibleLine:selectLine. |
|
1923 |
self selectWordAtLine:selectLine col:selectCol |
|
1924 |
] |
|
1925 |
! |
|
1926 |
||
1927 |
selection |
|
1928 |
"return the selection as a collection of (line-)strings. |
|
1929 |
If the selection ends in a full line, the last entry in the returned |
|
1930 |
collection will be an empty string." |
|
1931 |
||
1932 |
|text sz index last |
|
1933 |
startLine "{ Class: SmallInteger }" |
|
1934 |
endLine "{ Class: SmallInteger }"| |
|
1935 |
||
1936 |
selectionStartLine isNil ifTrue:[^ nil]. |
|
1937 |
startLine := selectionStartLine. |
|
1938 |
endLine := selectionEndLine. |
|
1939 |
||
1940 |
(startLine == endLine) ifTrue:[ |
|
1941 |
"part of a line" |
|
1942 |
^ StringCollection with:(self listAt:startLine |
|
1943 |
from:selectionStartCol |
|
1944 |
to:selectionEndCol) |
|
1945 |
]. |
|
1946 |
sz := endLine - startLine + 1. |
|
1947 |
text := StringCollection new:sz. |
|
1948 |
||
1949 |
"get 1st and last (possibly) partial lines" |
|
1950 |
text at:1 put:(self listAt:startLine from:selectionStartCol). |
|
1951 |
selectionEndCol == 0 ifTrue:[ |
|
1952 |
last := '' |
|
1953 |
] ifFalse:[ |
|
1954 |
last := self listAt:selectionEndLine to:selectionEndCol. |
|
1955 |
]. |
|
1956 |
text at:sz put:last. |
|
1957 |
||
1958 |
"get bulk of text" |
|
1959 |
index := 2. |
|
1960 |
(startLine + 1) to:(endLine - 1) do:[:lineNr | |
|
1961 |
text at:index put:(self listAt:lineNr). |
|
1962 |
index := index + 1 |
|
1963 |
]. |
|
1964 |
^ text |
|
1965 |
! |
|
1966 |
||
1967 |
selectionEndCol |
|
1968 |
^ selectionEndCol |
|
1969 |
! |
|
1970 |
||
1971 |
selectionEndLine |
|
1972 |
^ selectionEndLine |
|
1973 |
! |
|
1974 |
||
1975 |
selectionStartCol |
|
1976 |
^ selectionStartCol |
|
1977 |
! |
|
1978 |
||
1979 |
selectionStartLine |
|
1980 |
^ selectionStartLine |
|
1981 |
! |
|
1982 |
||
1983 |
unselect |
|
1984 |
"unselect - if there was a selection redraw that area" |
|
1985 |
||
1986 |
|startLine endLine startVisLine endVisLine| |
|
1987 |
||
1988 |
selectionStartLine notNil ifTrue:[ |
|
1989 |
startLine := selectionStartLine. |
|
1990 |
endLine := selectionEndLine. |
|
1991 |
selectionStartLine := nil. |
|
1992 |
||
1993 |
"if selection is not visible, we are done" |
|
1994 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
|
1995 |
endLine < firstLineShown ifTrue:[^ self]. |
|
1996 |
||
1997 |
startLine < firstLineShown ifTrue:[ |
|
1998 |
startVisLine := 1 |
|
1999 |
] ifFalse:[ |
|
2000 |
startVisLine := self listLineToVisibleLine:startLine |
|
2001 |
]. |
|
2002 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
|
2003 |
endVisLine := nLinesShown |
|
2004 |
] ifFalse:[ |
|
2005 |
endVisLine := self listLineToVisibleLine:endLine |
|
2006 |
]. |
|
2007 |
"if its only part of a line, just redraw what has to be" |
|
2008 |
(startVisLine == endVisLine) ifTrue:[ |
|
2009 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
|
2010 |
] ifFalse:[ |
|
2011 |
super redrawFromVisibleLine:startVisLine to:endVisLine |
|
2012 |
]. |
|
2013 |
self unselectWithoutRedraw |
|
2014 |
]. |
|
2015 |
selectStyle := nil |
|
2016 |
! |
|
2017 |
||
2018 |
unselectWithoutRedraw |
|
2019 |
"forget selection but do not redraw the selection area |
|
2020 |
- can be done when the selected area is redrawn anyway or |
|
2021 |
known to be invisible." |
|
2022 |
||
2023 |
selectionStartLine := nil. |
|
2024 |
! |
|
2025 |
||
2026 |
validateNewSelection |
|
2027 |
^ self |
|
2028 |
! |
|
2029 |
||
2030 |
wordAtLine:selectLine col:selectCol do:aFiveArgBlock |
|
2031 |
"find word boundaries, evaluate the block argument with those. |
|
2032 |
A helper for nextWord and selectWord functions." |
|
2033 |
||
2034 |
|beginCol endCol endLine thisCharacter flag| |
|
2035 |
||
2036 |
flag := #word. |
|
2037 |
beginCol := selectCol. |
|
2038 |
endCol := selectCol. |
|
2039 |
endLine := selectLine. |
|
2040 |
thisCharacter := self characterAtLine:selectLine col:beginCol. |
|
2041 |
||
2042 |
beginCol := self findBeginOfWordAtLine:selectLine col:selectCol. |
|
2043 |
endCol := self findEndOfWordAtLine:selectLine col:selectCol. |
|
2044 |
endCol == 0 ifTrue:[ |
|
2045 |
endLine := selectLine + 1 |
|
2046 |
]. |
|
2047 |
||
2048 |
"is the initial acharacter within a word ?" |
|
2049 |
(wordCheck value:thisCharacter) ifTrue:[ |
|
2050 |
" |
|
2051 |
try to catch a blank ... |
|
2052 |
" |
|
2053 |
((beginCol == 1) |
|
2054 |
or:[(self characterAtLine:selectLine col:(beginCol - 1)) |
|
2055 |
~~ Character space]) ifTrue:[ |
|
2056 |
((self characterAtLine:selectLine col:(endCol + 1)) |
|
2057 |
== Character space) ifTrue:[ |
|
2058 |
endCol := endCol + 1. |
|
2059 |
flag := #wordRight |
|
2060 |
] |
|
2061 |
] ifFalse:[ |
|
2062 |
beginCol := beginCol - 1. |
|
2063 |
flag := #wordLeft |
|
2064 |
]. |
|
2065 |
]. |
|
2066 |
aFiveArgBlock value:selectLine |
|
2067 |
value:beginCol |
|
2068 |
value:endLine |
|
2069 |
value:endCol |
|
2070 |
value:flag |
|
2071 |
! ! |
|
2072 |
||
2073 |
!TextView class methodsFor:'documentation'! |
|
2074 |
||
2075 |
version |
|
502 | 2076 |
^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.44 1996-03-18 16:19:09 cg Exp $' |
248 | 2077 |
! ! |