author | ca |
Thu, 07 Mar 1996 10:33:53 +0100 | |
changeset 487 | 4ee60598df58 |
parent 486 | 4c1cfc595c51 |
child 489 | 5816aa12fec8 |
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 |
|
725 |
|labels selectors m| |
|
726 |
||
727 |
labels := #( |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
728 |
'copy' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
729 |
'-' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
730 |
'font ...' |
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 |
'search ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
733 |
'goto ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
734 |
'-' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
735 |
'save as ...' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
736 |
'print' |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
737 |
). |
248 | 738 |
|
739 |
selectors := #( |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
740 |
copySelection |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
741 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
742 |
changeFont |
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 |
search |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
745 |
gotoLine |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
746 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
747 |
save |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
748 |
|
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
749 |
). |
248 | 750 |
|
751 |
m := PopUpMenu |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
752 |
labels:(resources array:labels) |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
753 |
selectors:selectors. |
248 | 754 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
755 |
m accelerators:#( |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
756 |
#Copy |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
757 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
758 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
759 |
#Find |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
760 |
#Goto |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
761 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
762 |
#SaveAs |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
763 |
nil |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
764 |
). |
248 | 765 |
self hasSelection ifFalse:[ |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
766 |
m disable:#copySelection. |
248 | 767 |
]. |
768 |
^ m |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
769 |
|
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
770 |
"Modified: 28.2.1996 / 18:53:56 / cg" |
248 | 771 |
! |
772 |
||
773 |
gotoLine |
|
774 |
"show a box to enter lineNumber for positioning" |
|
775 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
776 |
|l lineNumberBox| |
248 | 777 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
778 |
lineNumberBox := |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
779 |
EnterBox |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
780 |
title:(resources string:'line number:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
781 |
okText:(resources string:'goto') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
782 |
abortText:(resources string:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
783 |
action:[:l | |num| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
784 |
num := Integer readFromString:l onError:nil. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
785 |
num notNil ifTrue:[self gotoLine:num] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
786 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
787 |
|
248 | 788 |
l := self defaultForGotoLine. |
789 |
l notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
790 |
l := l printString |
248 | 791 |
]. |
792 |
lineNumberBox initialText:l . |
|
793 |
lineNumberBox showAtPointer |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
794 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
795 |
"Modified: 6.3.1996 / 13:12:27 / cg" |
248 | 796 |
! |
797 |
||
798 |
||
799 |
"print the contents on the printer" |
|
800 |
||
801 |
|printStream| |
|
802 |
||
803 |
list isNil ifTrue:[^ self]. |
|
804 |
printStream := Printer new. |
|
805 |
printStream notNil ifTrue:[ |
|
486
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
806 |
Printer writeErrorSignal handle:[:ex | |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
807 |
self warn:('error while printing:\\' |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
808 |
, ex errorString |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
809 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
810 |
] do:[ |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
811 |
self fileOutContentsOn:printStream. |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
812 |
]. |
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
813 |
printStream close |
248 | 814 |
] |
486
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
815 |
|
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
816 |
"Modified: 6.3.1996 / 18:28:14 / cg" |
248 | 817 |
! |
818 |
||
819 |
save |
|
820 |
"save contents into a file |
|
821 |
- ask user for filename using a fileSelectionBox." |
|
822 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
823 |
|fileBox| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
824 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
825 |
fileBox := FileSaveBox |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
826 |
title:(resources string:'save contents in:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
827 |
okText:(resources string:'save') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
828 |
abortText:(resources string:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
829 |
action:[:fileName | self saveAs:fileName]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
830 |
fileBox appendAction:[:fileName | self appendTo:fileName]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
831 |
directoryForFileDialog notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
832 |
fileBox directory:directoryForFileDialog |
248 | 833 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
834 |
fileBox showAtPointer. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
835 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
836 |
directoryForFileDialog := fileBox directory "/ remember for next time |
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 |
"Modified: 6.3.1996 / 13:09:19 / cg" |
248 | 839 |
! |
840 |
||
841 |
saveAs:fileName |
|
842 |
"save contents into a file named fileName" |
|
843 |
||
844 |
|aStream msg| |
|
845 |
||
846 |
aStream := FileStream newFileNamed:fileName. |
|
847 |
aStream isNil ifTrue:[ |
|
848 |
msg := resources string:'cannot write file %1 !!' with:fileName. |
|
849 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
|
850 |
] ifFalse:[ |
|
851 |
self fileOutContentsOn:aStream. |
|
852 |
aStream close. |
|
853 |
contentsWasSaved := true |
|
854 |
] |
|
855 |
! ! |
|
856 |
||
857 |
!TextView methodsFor:'private'! |
|
858 |
||
859 |
fileOutContentsOn:aStream |
|
860 |
"save contents on a stream, replacing leading spaces by tab-characters." |
|
861 |
||
862 |
self fileOutContentsOn:aStream compressTabs:true |
|
863 |
! |
|
864 |
||
865 |
fileOutContentsOn:aStream compressTabs:compressTabs |
|
866 |
"save contents on a stream. If compressTabs is true, |
|
867 |
leading spaces will be replaced by tab-characters in the output." |
|
868 |
||
869 |
|startNr nLines string| |
|
870 |
||
871 |
"on some systems, writing linewise is very slow (via NFS) |
|
872 |
therefore we convert to a string and write it in big chunks. |
|
873 |
To avoid creating huge strings, we do it in blocks of 1000 lines, |
|
874 |
limiting temporary string creation to about 50-80k. |
|
875 |
" |
|
876 |
startNr := 1. |
|
877 |
nLines := list size. |
|
878 |
[startNr <= nLines] whileTrue:[ |
|
879 |
string := list asStringWithCRsFrom:startNr |
|
880 |
to:((startNr + 1000) min:nLines) |
|
881 |
compressTabs:compressTabs. |
|
882 |
aStream nextPutAll:string. |
|
883 |
startNr := startNr + 1000 + 1. |
|
884 |
]. |
|
885 |
||
886 |
"/ "the old (obsolete) code:" |
|
887 |
"/ |
|
888 |
"/ list do:[:aLine | |
|
889 |
"/ aLine notNil ifTrue:[ |
|
890 |
"/ aStream nextPutAll:aLine. |
|
891 |
"/ ]. |
|
892 |
"/ aStream cr |
|
893 |
"/ ] |
|
894 |
||
895 |
! |
|
896 |
||
897 |
scrollSelectDown |
|
898 |
"auto scroll action; scroll and reinstall timed-block" |
|
899 |
||
900 |
|prevEndLine| |
|
901 |
||
902 |
"just to make certain ..." |
|
903 |
selectionEndLine isNil ifTrue:[^ self]. |
|
904 |
||
905 |
self scrollDown. |
|
906 |
||
907 |
"make new selection immediately visible" |
|
908 |
prevEndLine := selectionEndLine. |
|
909 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
910 |
selectionEndCol := 0. |
|
911 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
912 |
self redrawLine:lineNr |
|
913 |
]. |
|
914 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
915 |
! |
|
916 |
||
917 |
scrollSelectLeft |
|
918 |
"auto scroll action; scroll and reinstall timed-block" |
|
919 |
||
920 |
|prevStartLine| |
|
921 |
||
922 |
"just to make certain ..." |
|
923 |
selectionStartLine isNil ifTrue:[^ self]. |
|
924 |
selectionStartCol isNil ifTrue:[^ self]. |
|
925 |
||
926 |
"make new selection immediately visible" |
|
927 |
prevStartLine := selectionStartLine. |
|
928 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
929 |
self scrollLeft. |
|
930 |
||
931 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
932 |
! |
|
933 |
||
934 |
scrollSelectRight |
|
935 |
"auto scroll action; scroll and reinstall timed-block" |
|
936 |
||
937 |
|prevEndCol| |
|
938 |
||
939 |
"just to make certain ..." |
|
940 |
selectionEndCol isNil ifTrue:[^ self]. |
|
941 |
||
942 |
prevEndCol := selectionEndCol. |
|
943 |
selectionEndCol := selectionEndCol + 1. |
|
944 |
self scrollRight. |
|
945 |
||
946 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
947 |
! |
|
948 |
||
949 |
scrollSelectUp |
|
950 |
"auto scroll action; scroll and reinstall timed-block" |
|
951 |
||
952 |
|prevStartLine| |
|
953 |
||
954 |
"just to make certain ..." |
|
955 |
selectionStartLine isNil ifTrue:[^ self]. |
|
956 |
||
957 |
self scrollUp. |
|
958 |
||
959 |
"make new selection immediately visible" |
|
960 |
prevStartLine := selectionStartLine. |
|
961 |
selectionStartLine := firstLineShown. |
|
962 |
selectionStartCol := 1. |
|
963 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
964 |
self redrawLine:lineNr |
|
965 |
]. |
|
966 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT. |
|
967 |
! |
|
968 |
||
969 |
stopScrollSelect |
|
970 |
"stop auto scroll; deinstall timed-block" |
|
971 |
||
972 |
autoScrollBlock notNil ifTrue:[ |
|
973 |
Processor removeTimedBlock:autoScrollBlock. |
|
974 |
self compressMotionEvents:true. |
|
975 |
autoScrollBlock := nil. |
|
976 |
autoScrollDeltaT := nil |
|
977 |
] |
|
978 |
! |
|
979 |
||
980 |
widthForScrollBetween:firstLine and:lastLine |
|
981 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
982 |
||
983 |
selectionStartLine notNil ifTrue:[ |
|
984 |
(lastLine < selectionStartLine) ifFalse:[ |
|
985 |
(firstLine > selectionEndLine) ifFalse:[ |
|
986 |
^ width |
|
987 |
] |
|
988 |
] |
|
989 |
]. |
|
990 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
991 |
! ! |
|
992 |
||
993 |
!TextView methodsFor:'redrawing'! |
|
994 |
||
995 |
clearMarginOfVisible:visLine with:color |
|
996 |
"if there is a margin, clear it - a helper for selection drawing" |
|
997 |
||
998 |
(leftMargin ~~ 0) ifTrue:[ |
|
999 |
self paint:color. |
|
1000 |
self fillRectangleX:margin |
|
1001 |
y:(self yOfVisibleLine:visLine) |
|
1002 |
width:leftMargin |
|
1003 |
height:fontHeight |
|
1004 |
] |
|
1005 |
! |
|
1006 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1007 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1008 |
"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
|
1009 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1010 |
(leftMargin ~~ 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1011 |
self paint:color. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1012 |
self fillRectangleX:margin |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1013 |
y:(self yOfVisibleLine:visLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1014 |
width:leftMargin |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1015 |
height:fontHeight |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1016 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1017 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1018 |
"Created: 6.3.1996 / 14:22:55 / cg" |
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 |
|
248 | 1021 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
1022 |
"redraw a visible line range" |
|
1023 |
||
1024 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
1025 |
||
1026 |
shown ifFalse:[^ self]. |
|
1027 |
||
1028 |
end := endVisLineNr. |
|
1029 |
(end > nLinesShown) ifTrue:[ |
|
1030 |
end := nLinesShown |
|
1031 |
]. |
|
1032 |
||
1033 |
selectionStartLine isNil ifTrue:[ |
|
1034 |
specialCare := false |
|
1035 |
] ifFalse:[ |
|
1036 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
|
1037 |
(startLine > selectionEndLine) ifTrue:[ |
|
1038 |
specialCare := false |
|
1039 |
] ifFalse:[ |
|
1040 |
endLine := self visibleLineToAbsoluteLine:end. |
|
1041 |
(endLine < selectionStartLine) ifTrue:[ |
|
1042 |
specialCare := false |
|
1043 |
] ifFalse:[ |
|
1044 |
specialCare := true |
|
1045 |
] |
|
1046 |
] |
|
1047 |
]. |
|
1048 |
||
1049 |
"easy: nothing is selected" |
|
1050 |
specialCare ifFalse:[ |
|
1051 |
super redrawFromVisibleLine:startVisLineNr to:end. |
|
1052 |
^ self |
|
1053 |
]. |
|
1054 |
||
1055 |
"easy: all is selected" |
|
1056 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
1057 |
self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor |
|
1058 |
and:selectionBgColor. |
|
1059 |
^ self |
|
1060 |
]. |
|
1061 |
||
1062 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
1063 |
"draw unselected top part" |
|
1064 |
||
1065 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
1066 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
1067 |
||
1068 |
"and first partial selected line" |
|
1069 |
self redrawVisibleLine:selVisStart. |
|
1070 |
||
1071 |
"rest starts after this one" |
|
1072 |
line1 := selVisStart + 1 |
|
1073 |
] ifFalse:[ |
|
1074 |
line1 := 1 |
|
1075 |
]. |
|
1076 |
||
1077 |
(line1 > end) ifTrue:[^ self]. |
|
1078 |
(line1 < startVisLineNr) ifTrue:[ |
|
1079 |
line1 := startVisLineNr |
|
1080 |
]. |
|
1081 |
||
1082 |
"draw middle part of selection" |
|
1083 |
||
1084 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
1085 |
line2 := nLinesShown |
|
1086 |
] ifFalse:[ |
|
1087 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
|
1088 |
]. |
|
1089 |
(line2 > end) ifTrue:[ |
|
1090 |
line2 := end |
|
1091 |
]. |
|
1092 |
||
1093 |
self drawFromVisibleLine:line1 to:line2 with:selectionFgColor |
|
1094 |
and:selectionBgColor. |
|
1095 |
||
1096 |
(line2 >= end) ifTrue:[^ self]. |
|
1097 |
||
1098 |
"last line of selection" |
|
1099 |
self redrawVisibleLine:(line2 + 1). |
|
1100 |
||
1101 |
((line2 + 2) <= end) ifTrue:[ |
|
1102 |
super redrawFromVisibleLine:(line2 + 2) to:end |
|
1103 |
] |
|
1104 |
! |
|
1105 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1106 |
redrawMarginOfVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1107 |
"draw margin - a helper for selection drawing" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1108 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1109 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1110 |
(leftMargin ~~ 0) ifTrue:[ |
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 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1113 |
"Created: 6.3.1996 / 14:21:48 / cg" |
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 |
|
248 | 1116 |
redrawVisibleLine:visLine |
1117 |
"redraw visible line lineNr" |
|
1118 |
||
1119 |
|len line l| |
|
1120 |
||
1121 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1122 |
line := self visibleLineToAbsoluteLine:visLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1123 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1124 |
(line == selectionStartLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1125 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1126 |
"its part-of-single-line selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1127 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1128 |
(selectionStartCol > 1) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1129 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1130 |
from:1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1131 |
to:(selectionStartCol - 1) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1132 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1133 |
self drawVisibleLine:visLine from:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1134 |
to:selectionEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1135 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1136 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1137 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1138 |
from:(selectionEndCol + 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1139 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1140 |
]. |
248 | 1141 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1142 |
"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
|
1143 |
(selectionStartCol ~~ 1) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1144 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1145 |
super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1146 |
from:1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1147 |
to:(selectionStartCol - 1) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1148 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1149 |
leftOffset == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1150 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1151 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1152 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1153 |
self drawVisibleLine:visLine from:selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1154 |
with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1155 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1156 |
]. |
248 | 1157 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1158 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1159 |
"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
|
1160 |
(selectionEndCol == 0) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1161 |
^ super redrawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1162 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1163 |
l := self visibleAt:selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1164 |
len := l size. |
248 | 1165 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1166 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1167 |
self drawVisibleLine:visLine from:1 to:selectionEndCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1168 |
with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1169 |
super redrawVisibleLine:visLine from:(selectionEndCol + 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1170 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1171 |
]. |
248 | 1172 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1173 |
"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
|
1174 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1175 |
self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1176 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1177 |
] |
248 | 1178 |
]. |
1179 |
super redrawVisibleLine:visLine |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1180 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1181 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 1182 |
! |
1183 |
||
1184 |
redrawVisibleLine:visLine col:col |
|
1185 |
"redraw single character at col in visible line lineNr" |
|
1186 |
||
1187 |
|line| |
|
1188 |
||
1189 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1190 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1191 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1192 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1193 |
and: [col < selectionStartCol]) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1194 |
((line == selectionEndLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1195 |
and: [col > selectionEndCol]) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1196 |
"its in the selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1197 |
self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1198 |
drawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1199 |
col:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1200 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1201 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1202 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1203 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1204 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1205 |
] |
248 | 1206 |
]. |
1207 |
super redrawVisibleLine:visLine col:col |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1208 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1209 |
"Modified: 6.3.1996 / 14:20:14 / cg" |
248 | 1210 |
! |
1211 |
||
1212 |
redrawVisibleLine:visLine from:startCol |
|
1213 |
"redraw visible line lineNr from startCol to end of line" |
|
1214 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1215 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1216 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1217 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1218 |
col == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1219 |
col := 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1220 |
]. |
248 | 1221 |
|
1222 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1223 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1224 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1225 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1226 |
or:[line == selectionEndLine]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1227 |
"since I'm lazy, redraw full line" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1228 |
self redrawVisibleLine:visLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1229 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1230 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1231 |
"the line is fully within the selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1232 |
self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1233 |
drawVisibleLine:visLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1234 |
from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1235 |
with:selectionFgColor |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1236 |
and:selectionBgColor. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1237 |
^ self |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1238 |
] |
248 | 1239 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1240 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1241 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1242 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 1243 |
! |
1244 |
||
1245 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
1246 |
"redraw visible line lineNr from startCol to endCol" |
|
1247 |
||
1248 |
|line allOut allIn leftCol rightCol| |
|
1249 |
||
1250 |
line := self visibleLineToAbsoluteLine:visLine. |
|
1251 |
||
1252 |
allIn := false. |
|
1253 |
allOut := false. |
|
1254 |
selectionStartLine isNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1255 |
allOut := true |
248 | 1256 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1257 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1258 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1259 |
] ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1260 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1261 |
((endCol < selectionStartCol) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1262 |
or:[startCol > selectionEndCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1263 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1264 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1265 |
((startCol >= selectionStartCol) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1266 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1267 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1268 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1269 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1270 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1271 |
(line == selectionStartLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1272 |
(endCol < selectionStartCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1273 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1274 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1275 |
(startCol >= selectionStartCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1276 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1277 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1278 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1279 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1280 |
(line == selectionEndLine) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1281 |
(startCol > selectionEndCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1282 |
allOut := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1283 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1284 |
(endCol <= selectionEndCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1285 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1286 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1287 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1288 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1289 |
allIn := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1290 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1291 |
] |
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 |
] |
248 | 1294 |
]. |
1295 |
allOut ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1296 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1297 |
^ self |
248 | 1298 |
]. |
1299 |
||
1300 |
allIn ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1301 |
self drawVisibleLine:visLine from:startCol to:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1302 |
with:selectionFgColor and:selectionBgColor |
248 | 1303 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1304 |
"redraw part before selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1305 |
((line == selectionStartLine) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1306 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1307 |
super redrawVisibleLine:visLine from:startCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1308 |
to:(selectionStartCol - 1). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1309 |
leftCol := selectionStartCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1310 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1311 |
leftCol := startCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1312 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1313 |
"redraw selected part" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1314 |
(selectionEndLine > line) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1315 |
rightCol := endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1316 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1317 |
rightCol := selectionEndCol min:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1318 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1319 |
self drawVisibleLine:visLine from:leftCol to:rightCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1320 |
with:selectionFgColor and:selectionBgColor. |
248 | 1321 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1322 |
"redraw part after selection" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1323 |
(rightCol < endCol) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1324 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1325 |
] |
248 | 1326 |
]. |
1327 |
||
1328 |
"special care for first and last line of selection: |
|
1329 |
must handle margin also" |
|
1330 |
||
1331 |
((line == selectionEndLine) |
|
1332 |
and:[(startCol == 1) |
|
1333 |
and:[selectionStartLine < selectionEndLine]]) |
|
1334 |
ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1335 |
self clearMarginOfVisibleLine:visLine with:selectionBgColor. |
248 | 1336 |
]. |
1337 |
||
1338 |
((line == selectionStartLine) |
|
1339 |
and:[(startCol == 1) |
|
1340 |
and:[selectionStartLine < selectionEndLine]]) |
|
1341 |
ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1342 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
248 | 1343 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1344 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1345 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 1346 |
! ! |
1347 |
||
1348 |
!TextView methodsFor:'searching'! |
|
1349 |
||
1350 |
search |
|
1351 |
"show a box to enter searchpattern |
|
1352 |
- currently no regular expressions are handled." |
|
1353 |
||
1354 |
" |
|
1355 |
cache the searchBox |
|
1356 |
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
|
1357 |
(we could then preserve the last searchstring between views) |
248 | 1358 |
" |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1359 |
|searchBox| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1360 |
|
248 | 1361 |
|
1362 |
"/ "soon to come: search & replace box ... |
|
1363 |
"/ |box| |
|
1364 |
"/ |
|
1365 |
"/ box := Dialog new. |
|
1366 |
"/ (box addTextLabel:(resources at:'searchPattern:')) layout:#left. |
|
1367 |
"/ box addVerticalSpace. |
|
1368 |
"/ box addInputFieldOn:'' asValue. |
|
1369 |
"/ box addVerticalSpace. |
|
1370 |
"/ (box addTextLabel:(resources at:'replace with:')) layout:#left. |
|
1371 |
"/ box addVerticalSpace. |
|
1372 |
"/ box addInputFieldOn:'' asValue. |
|
1373 |
"/ box addAbortButtonLabelled:(resources at:'cancel'); |
|
1374 |
"/ addButton:(Button label:(resources at:'all')); |
|
1375 |
"/ addButton:(Button label:(resources at:'prev')); |
|
1376 |
"/ addOkButtonLabelled:(resources at:'next'). |
|
1377 |
"/ box open. |
|
1378 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1379 |
searchBox := |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1380 |
EnterBox2 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1381 |
title:(resources at:'searchPattern:') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1382 |
okText1:(resources at:'prev') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1383 |
okText2:(resources at:'next') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1384 |
abortText:(resources at:'cancel') |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1385 |
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
|
1386 |
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
|
1387 |
|
248 | 1388 |
searchPattern notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1389 |
searchBox initialText:searchPattern |
248 | 1390 |
]. |
1391 |
self hasSelection ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1392 |
selectionStartLine == selectionEndLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1393 |
searchBox initialText:self selection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1394 |
] |
248 | 1395 |
]. |
1396 |
searchBox showAtPointer |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1397 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1398 |
"Modified: 6.3.1996 / 13:11:46 / cg" |
248 | 1399 |
! |
1400 |
||
1401 |
searchBwd |
|
1402 |
"search backward and -if found- position cursor" |
|
1403 |
||
1404 |
self setSearchPattern. |
|
1405 |
searchPattern notNil ifTrue:[ |
|
1406 |
self searchBwd:searchPattern |
|
1407 |
] |
|
1408 |
! |
|
1409 |
||
1410 |
searchBwd:pattern |
|
1411 |
"do a backward search" |
|
1412 |
||
1413 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
1414 |
searchPattern := pattern |
|
1415 |
||
1416 |
! |
|
1417 |
||
1418 |
searchBwd:pattern ifAbsent:aBlock |
|
1419 |
"do a backward search" |
|
1420 |
||
1421 |
|startLine startCol| |
|
1422 |
||
1423 |
selectionStartLine notNil ifTrue:[ |
|
1424 |
startLine := selectionStartLine. |
|
1425 |
startCol := selectionStartCol |
|
1426 |
] ifFalse:[ |
|
1427 |
startLine := 1. |
|
1428 |
startCol := 1 |
|
1429 |
]. |
|
1430 |
self searchBackwardFor:pattern startingAtLine:startLine col:startCol |
|
1431 |
ifFound:[:line :col | |
|
1432 |
self showMatch:pattern atLine:line col:col |
|
1433 |
] ifAbsent:aBlock |
|
1434 |
! |
|
1435 |
||
1436 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1437 |
ifFound:foundBlock |
|
1438 |
ifNotFound:notFoundBlock |
|
1439 |
onError:failBlock |
|
1440 |
||
1441 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
|
1442 |
Search for the corresponding character is done forward if its an opening, |
|
1443 |
backwards if its a closing parenthesis. |
|
1444 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
1445 |
If there is a nesting error, performs failBlock." |
|
1446 |
||
1447 |
^ self |
|
1448 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
1449 |
ifFound:foundBlock |
|
1450 |
ifNotFound:notFoundBlock |
|
1451 |
onError:failBlock |
|
1452 |
ignoring:#( $' $" ) |
|
1453 |
||
1454 |
"Modified: 18.11.1995 / 16:28:23 / cg" |
|
1455 |
! |
|
1456 |
||
1457 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1458 |
ifFound:foundBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1459 |
ifNotFound:notFoundBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1460 |
onError:failBlock |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1461 |
ignoring:ignoreSet |
248 | 1462 |
"search for a matching parenthesis, parChar is one of '$( $[ ${ $) $] $}'. |
1463 |
Search for the corresponding character is done forward if its an opening, |
|
1464 |
backwards if its a closing parenthesis. |
|
1465 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not. |
|
1466 |
If there is a nesting error, performs failBlock." |
|
1467 |
||
1468 |
|i direction lineString line col parChar charSet closingChar |
|
1469 |
ignoring delta endCol cc incSet decSet nesting maxLine| |
|
1470 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1471 |
charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
248 | 1472 |
|
1473 |
parChar := self characterAtLine:startLine col:startCol. |
|
1474 |
i := charSet indexOf:parChar. |
|
1475 |
i == 0 ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1476 |
^ failBlock value "not a parenthesis" |
248 | 1477 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1478 |
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
|
1479 |
closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
248 | 1480 |
|
1481 |
col := startCol. |
|
1482 |
line := startLine. |
|
1483 |
direction == #fwd ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1484 |
delta := 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1485 |
incSet := #( $( $[ ${ "$<" ). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1486 |
decSet := #( $) $] $} "$>" ). |
248 | 1487 |
] ifFalse:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1488 |
delta := -1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1489 |
incSet := #( $) $] $} "$>" ). |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1490 |
decSet := #( $( $[ ${ "$<" ). |
248 | 1491 |
]. |
1492 |
||
1493 |
nesting := 1. |
|
1494 |
ignoring := false. |
|
1495 |
lineString := list at:line. |
|
1496 |
maxLine := list size. |
|
1497 |
||
1498 |
col := col + delta. |
|
1499 |
[nesting ~~ 0] whileTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1500 |
lineString notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1501 |
direction == #fwd ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1502 |
endCol := lineString size. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1503 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1504 |
endCol := 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1505 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1506 |
col to:endCol by:delta do:[:runCol | |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1507 |
cc := lineString at:runCol. |
248 | 1508 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1509 |
(ignoreSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1510 |
ignoring := ignoring not |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1511 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1512 |
ignoring ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1513 |
(incSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1514 |
nesting := nesting + 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1515 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1516 |
(decSet includes:cc) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1517 |
nesting := nesting - 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1518 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1519 |
] |
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 |
nesting == 0 ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1522 |
"check if legal" |
248 | 1523 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1524 |
cc == closingChar ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1525 |
^ failBlock value |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1526 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1527 |
^ foundBlock value:line value:runCol. |
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 |
]. |
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 |
line := line + delta. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1532 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1533 |
^ failBlock value |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1534 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1535 |
lineString := list at:line. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1536 |
direction == #fwd ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1537 |
col := 1 |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1538 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1539 |
col := lineString size |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1540 |
] |
248 | 1541 |
]. |
1542 |
||
1543 |
^ notFoundBlock value |
|
1544 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1545 |
"Modified: 6.3.1996 / 14:58:29 / cg" |
248 | 1546 |
! |
1547 |
||
1548 |
searchFwd |
|
1549 |
"search forward for pattern or selection" |
|
1550 |
||
1551 |
selectStyle == #wordLeft ifTrue:[ |
|
1552 |
" |
|
1553 |
remove the space from the selection |
|
1554 |
" |
|
1555 |
selectionStartCol := selectionStartCol + 1. |
|
1556 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1557 |
selectStyle := #word. |
248 | 1558 |
]. |
1559 |
self setSearchPattern. |
|
1560 |
searchPattern notNil ifTrue:[ |
|
1561 |
self searchFwd:searchPattern |
|
1562 |
] |
|
1563 |
! |
|
1564 |
||
1565 |
searchFwd:pattern |
|
1566 |
"do a forward search" |
|
1567 |
||
1568 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
1569 |
searchPattern := pattern |
|
1570 |
! |
|
1571 |
||
1572 |
searchFwd:pattern ifAbsent:aBlock |
|
1573 |
"do a forward search" |
|
1574 |
||
1575 |
|startLine startCol| |
|
1576 |
||
1577 |
selectionStartLine notNil ifTrue:[ |
|
1578 |
startLine := selectionStartLine. |
|
1579 |
startCol := selectionStartCol |
|
1580 |
] ifFalse:[ |
|
1581 |
startLine := 1. |
|
1582 |
startCol := 1 |
|
1583 |
]. |
|
1584 |
self searchForwardFor:pattern startingAtLine:startLine col:startCol |
|
1585 |
ifFound:[:line :col | |
|
1586 |
self showMatch:pattern atLine:line col:col |
|
1587 |
] ifAbsent:aBlock |
|
1588 |
! |
|
1589 |
||
1590 |
searchPattern |
|
1591 |
"return the last search pattern" |
|
1592 |
||
1593 |
^ searchPattern |
|
1594 |
! |
|
1595 |
||
1596 |
setSearchPattern |
|
1597 |
"set the searchpattern from the selection if there is one" |
|
1598 |
||
1599 |
|sel| |
|
1600 |
||
1601 |
sel := self selection. |
|
1602 |
sel notNil ifTrue:[ |
|
1603 |
searchPattern := sel asString withoutSeparators |
|
1604 |
] |
|
1605 |
! |
|
1606 |
||
1607 |
setSearchPattern:aString |
|
1608 |
"set the searchpattern for future searches" |
|
1609 |
||
1610 |
aString isNil ifTrue:[ |
|
1611 |
searchPattern := aString |
|
1612 |
] ifFalse:[ |
|
1613 |
searchPattern := aString withoutSeparators |
|
1614 |
] |
|
1615 |
! |
|
1616 |
||
1617 |
showMatch:pattern atLine:line col:col |
|
1618 |
"after a search, highlight the matched pattern. |
|
1619 |
The code below needs a rewrite to take care of match-characters |
|
1620 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
1621 |
||
1622 |
|realPattern| |
|
1623 |
||
1624 |
realPattern := pattern. |
|
1625 |
(realPattern startsWith:$*) ifTrue:[ |
|
1626 |
realPattern := realPattern copyFrom:2 |
|
1627 |
]. |
|
1628 |
(realPattern endsWith:$*) ifTrue:[ |
|
1629 |
realPattern := realPattern copyWithoutLast:1 |
|
1630 |
]. |
|
1631 |
||
1632 |
self selectFromLine:line col:col |
|
1633 |
toLine:line col:(col + realPattern size - 1). |
|
1634 |
self makeLineVisible:line |
|
1635 |
! |
|
1636 |
||
1637 |
showNotFound |
|
1638 |
"search not found - tell user by beeping and changing |
|
1639 |
cursor for a while (sometimes I work with a headset :-) |
|
1640 |
(used to be: tell user by changing cursor for a while)" |
|
1641 |
||
1642 |
|savedCursor| |
|
1643 |
||
1644 |
device beep. |
|
1645 |
||
1646 |
" |
|
1647 |
uncomment if you want a CROSS cursor to be shown for a while .. |
|
1648 |
" |
|
1649 |
||
1650 |
" " |
|
1651 |
savedCursor := cursor. |
|
1652 |
self cursor:(Cursor cross). |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1653 |
Processor activeProcess millisecondDelay:300. |
248 | 1654 |
self cursor:savedCursor |
1655 |
" " |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
248
diff
changeset
|
1657 |
"Modified: 16.12.1995 / 13:11:31 / cg" |
248 | 1658 |
! ! |
1659 |
||
1660 |
!TextView methodsFor:'selections'! |
|
1661 |
||
458 | 1662 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1663 |
|l t| |
458 | 1664 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1665 |
selectionStartLine notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1666 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1667 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1668 |
selectionStartLine := selectionStartLine + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1669 |
(selectionStartLine > clickLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1670 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1671 |
ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1672 |
t := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1673 |
selectionStartLine := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1674 |
selectionEndLine := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1675 |
t := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1676 |
selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1677 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1678 |
expandingTop := false |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1679 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1680 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1681 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1682 |
selectionEndLine := selectionEndLine + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1683 |
selectionEndLine <= clickLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1684 |
expandingTop := true |
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 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1687 |
self redrawLine:l. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1688 |
self redrawLine:l+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1689 |
self makeSelectionVisible. |
458 | 1690 |
]. |
1691 |
||
1692 |
"Created: 1.3.1996 / 23:35:08 / cg" |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1693 |
"Modified: 6.3.1996 / 14:18:12 / cg" |
458 | 1694 |
! |
1695 |
||
1696 |
expandSelectionLeft |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1697 |
|c l t| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1698 |
|
458 | 1699 |
selectionStartLine notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1700 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1701 |
selectionStartCol == 0 ifTrue:[^ self]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1702 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1703 |
selectionStartCol := (selectionStartCol - 1) max:0. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1704 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1705 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1706 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1707 |
selectionEndCol := (selectionEndCol - 1) max:0. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1708 |
c := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1709 |
selectionEndLine == selectionStartLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1710 |
selectionEndCol <= selectionStartCol ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1711 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1712 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1713 |
expandingTop := true. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1714 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1715 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1716 |
]. |
458 | 1717 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1718 |
self redrawLine:l from:c to:c+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1719 |
self makeSelectionVisible. |
458 | 1720 |
]. |
1721 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1722 |
"Modified: 6.3.1996 / 14:18:27 / cg" |
458 | 1723 |
! |
1724 |
||
1725 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1726 |
|l c t| |
458 | 1727 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1728 |
selectionStartLine notNil ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1729 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1730 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1731 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1732 |
selectionStartCol := selectionStartCol + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1733 |
l == selectionEndLine ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1734 |
c >= selectionEndCol ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1735 |
expandingTop := false. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1736 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1737 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1738 |
c := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1739 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1740 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1741 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1742 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1743 |
c := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1744 |
selectionEndCol := selectionEndCol + 1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1745 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1746 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1747 |
self redrawLine:l from:c to:c+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1748 |
self makeSelectionVisible. |
458 | 1749 |
]. |
1750 |
||
1751 |
"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
|
1752 |
"Modified: 6.3.1996 / 13:54:10 / cg" |
458 | 1753 |
! |
1754 |
||
1755 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1756 |
|l t| |
458 | 1757 |
|
1758 |
selectionStartLine notNil ifTrue:[ |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1759 |
expandingTop ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1760 |
selectionStartLine := (selectionStartLine - 1) max:1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1761 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1762 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1763 |
selectionEndLine := (selectionEndLine - 1) max:0. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1764 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1765 |
l := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1766 |
(selectionEndLine < clickLine |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1767 |
or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])]) |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1768 |
ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1769 |
t := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1770 |
selectionStartLine := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1771 |
selectionEndLine := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1772 |
t := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1773 |
selectionStartCol := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1774 |
selectionEndCol := t. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1775 |
l := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1776 |
expandingTop := true |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1777 |
]. |
458 | 1778 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1779 |
self redrawLine:l. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1780 |
self redrawLine:l+1. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1781 |
self makeSelectionVisible. |
458 | 1782 |
]. |
1783 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1784 |
"Modified: 6.3.1996 / 14:12:06 / cg" |
458 | 1785 |
! |
1786 |
||
248 | 1787 |
hasSelection |
1788 |
"return true, if there is a selection" |
|
1789 |
||
1790 |
^ selectionStartLine notNil |
|
1791 |
! |
|
1792 |
||
1793 |
makeSelectionVisible |
|
1794 |
"scroll to make the selection visible" |
|
1795 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1796 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1797 |
|
248 | 1798 |
selectionStartLine notNil ifTrue:[ |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1799 |
expandingTop ~~ false ifTrue:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1800 |
line := selectionStartLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1801 |
col := selectionStartCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1802 |
] ifFalse:[ |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1803 |
line := selectionEndLine. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1804 |
col := selectionEndCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1805 |
]. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1806 |
self makeLineVisible:line. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
1807 |
self makeColVisible:col inLine:line. |
248 | 1808 |
] |
478
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 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 1811 |
! |
1812 |
||
1813 |
selectAll |
|
1814 |
"select the whole text" |
|
1815 |
||
1816 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
1817 |
! |
|
1818 |
||
1819 |
selectFromCharacterPosition:pos1 to:pos2 |
|
1820 |
"compute line/col from character positions and select the text" |
|
1821 |
||
1822 |
|line1 col1 line2 col2| |
|
1823 |
||
1824 |
line1 := self lineOfCharacterPosition:pos1. |
|
1825 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
1826 |
line2 := self lineOfCharacterPosition:pos2. |
|
1827 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
1828 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
|
1829 |
! |
|
1830 |
||
1831 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
1832 |
"select a piece of text and redraw that area" |
|
1833 |
||
1834 |
self unselect. |
|
1835 |
startLine notNil ifTrue:[ |
|
1836 |
"new:" |
|
1837 |
endLine < startLine ifTrue:[ |
|
1838 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
|
1839 |
]. |
|
1840 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
|
1841 |
endCol ~~ 0 ifTrue:[ |
|
1842 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
|
1843 |
]. |
|
1844 |
^ self |
|
1845 |
]. |
|
1846 |
||
1847 |
" old: |
|
1848 |
endLine < startLine ifTrue:[^ self]. |
|
1849 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
|
1850 |
" |
|
1851 |
selectionStartLine := startLine. |
|
1852 |
selectionStartCol := startCol. |
|
1853 |
selectionEndLine := endLine. |
|
1854 |
selectionEndCol := endCol. |
|
1855 |
(startLine == endLine) ifTrue:[ |
|
1856 |
self redrawLine:startLine from:startCol to:endCol |
|
1857 |
] ifFalse:[ |
|
1858 |
startLine to:endLine do:[:lineNr | |
|
1859 |
self redrawLine:lineNr |
|
1860 |
] |
|
1861 |
]. |
|
1862 |
selectStyle := nil. |
|
1863 |
] |
|
1864 |
! |
|
1865 |
||
1866 |
selectLine:selectLine |
|
1867 |
"select one line and redraw it" |
|
1868 |
||
1869 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
1870 |
wordStartCol := selectionStartCol. |
|
1871 |
wordEndCol := selectionEndCol. |
|
1872 |
wordStartLine := selectionStartLine. |
|
1873 |
wordEndLine := selectionEndLine. |
|
1874 |
selectStyle := #line |
|
1875 |
! |
|
1876 |
||
1877 |
selectLineAtY:y |
|
1878 |
"select the line at given y-(view-)coordinate" |
|
1879 |
||
1880 |
|selectVisibleLine selectLine| |
|
1881 |
||
1882 |
selectVisibleLine := self visibleLineOfY:y. |
|
1883 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
1884 |
selectLine notNil ifTrue:[ |
|
1885 |
self selectLine:selectLine |
|
1886 |
] |
|
1887 |
! |
|
1888 |
||
1889 |
selectLineWhereCharacterPosition:pos |
|
1890 |
"select the line, where characterPosition pos is living. |
|
1891 |
The argument pos starts at 1 from the start of the text |
|
1892 |
and counts characters (i.e. can be used to convert from |
|
1893 |
character position within a string to line-position in view)." |
|
1894 |
||
1895 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
1896 |
! |
|
1897 |
||
1898 |
selectWordAtLine:line col:col |
|
1899 |
"select the word at given line/col" |
|
1900 |
||
1901 |
self wordAtLine:line col:col do:[ |
|
1902 |
:beginLine :beginCol :endLine :endCol :style | |
|
1903 |
||
1904 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
1905 |
selectStyle := style |
|
1906 |
] |
|
1907 |
! |
|
1908 |
||
1909 |
selectWordAtX:x y:y |
|
1910 |
"select the word at given x/y-(view-)coordinate" |
|
1911 |
||
1912 |
|selectVisibleLine selectLine selectCol| |
|
1913 |
||
1914 |
selectStyle := nil. |
|
1915 |
selectVisibleLine := self visibleLineOfY:y. |
|
1916 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
1917 |
selectLine notNil ifTrue:[ |
|
1918 |
selectCol := self colOfX:x inVisibleLine:selectLine. |
|
1919 |
self selectWordAtLine:selectLine col:selectCol |
|
1920 |
] |
|
1921 |
! |
|
1922 |
||
1923 |
selection |
|
1924 |
"return the selection as a collection of (line-)strings. |
|
1925 |
If the selection ends in a full line, the last entry in the returned |
|
1926 |
collection will be an empty string." |
|
1927 |
||
1928 |
|text sz index last |
|
1929 |
startLine "{ Class: SmallInteger }" |
|
1930 |
endLine "{ Class: SmallInteger }"| |
|
1931 |
||
1932 |
selectionStartLine isNil ifTrue:[^ nil]. |
|
1933 |
startLine := selectionStartLine. |
|
1934 |
endLine := selectionEndLine. |
|
1935 |
||
1936 |
(startLine == endLine) ifTrue:[ |
|
1937 |
"part of a line" |
|
1938 |
^ StringCollection with:(self listAt:startLine |
|
1939 |
from:selectionStartCol |
|
1940 |
to:selectionEndCol) |
|
1941 |
]. |
|
1942 |
sz := endLine - startLine + 1. |
|
1943 |
text := StringCollection new:sz. |
|
1944 |
||
1945 |
"get 1st and last (possibly) partial lines" |
|
1946 |
text at:1 put:(self listAt:startLine from:selectionStartCol). |
|
1947 |
selectionEndCol == 0 ifTrue:[ |
|
1948 |
last := '' |
|
1949 |
] ifFalse:[ |
|
1950 |
last := self listAt:selectionEndLine to:selectionEndCol. |
|
1951 |
]. |
|
1952 |
text at:sz put:last. |
|
1953 |
||
1954 |
"get bulk of text" |
|
1955 |
index := 2. |
|
1956 |
(startLine + 1) to:(endLine - 1) do:[:lineNr | |
|
1957 |
text at:index put:(self listAt:lineNr). |
|
1958 |
index := index + 1 |
|
1959 |
]. |
|
1960 |
^ text |
|
1961 |
! |
|
1962 |
||
1963 |
selectionEndCol |
|
1964 |
^ selectionEndCol |
|
1965 |
! |
|
1966 |
||
1967 |
selectionEndLine |
|
1968 |
^ selectionEndLine |
|
1969 |
! |
|
1970 |
||
1971 |
selectionStartCol |
|
1972 |
^ selectionStartCol |
|
1973 |
! |
|
1974 |
||
1975 |
selectionStartLine |
|
1976 |
^ selectionStartLine |
|
1977 |
! |
|
1978 |
||
1979 |
unselect |
|
1980 |
"unselect - if there was a selection redraw that area" |
|
1981 |
||
1982 |
|startLine endLine startVisLine endVisLine| |
|
1983 |
||
1984 |
selectionStartLine notNil ifTrue:[ |
|
1985 |
startLine := selectionStartLine. |
|
1986 |
endLine := selectionEndLine. |
|
1987 |
selectionStartLine := nil. |
|
1988 |
||
1989 |
"if selection is not visible, we are done" |
|
1990 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
|
1991 |
endLine < firstLineShown ifTrue:[^ self]. |
|
1992 |
||
1993 |
startLine < firstLineShown ifTrue:[ |
|
1994 |
startVisLine := 1 |
|
1995 |
] ifFalse:[ |
|
1996 |
startVisLine := self listLineToVisibleLine:startLine |
|
1997 |
]. |
|
1998 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
|
1999 |
endVisLine := nLinesShown |
|
2000 |
] ifFalse:[ |
|
2001 |
endVisLine := self listLineToVisibleLine:endLine |
|
2002 |
]. |
|
2003 |
"if its only part of a line, just redraw what has to be" |
|
2004 |
(startVisLine == endVisLine) ifTrue:[ |
|
2005 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
|
2006 |
] ifFalse:[ |
|
2007 |
super redrawFromVisibleLine:startVisLine to:endVisLine |
|
2008 |
]. |
|
2009 |
self unselectWithoutRedraw |
|
2010 |
]. |
|
2011 |
selectStyle := nil |
|
2012 |
! |
|
2013 |
||
2014 |
unselectWithoutRedraw |
|
2015 |
"forget selection but do not redraw the selection area |
|
2016 |
- can be done when the selected area is redrawn anyway or |
|
2017 |
known to be invisible." |
|
2018 |
||
2019 |
selectionStartLine := nil. |
|
2020 |
! |
|
2021 |
||
2022 |
validateNewSelection |
|
2023 |
^ self |
|
2024 |
! |
|
2025 |
||
2026 |
wordAtLine:selectLine col:selectCol do:aFiveArgBlock |
|
2027 |
"find word boundaries, evaluate the block argument with those. |
|
2028 |
A helper for nextWord and selectWord functions." |
|
2029 |
||
2030 |
|beginCol endCol endLine thisCharacter flag| |
|
2031 |
||
2032 |
flag := #word. |
|
2033 |
beginCol := selectCol. |
|
2034 |
endCol := selectCol. |
|
2035 |
endLine := selectLine. |
|
2036 |
thisCharacter := self characterAtLine:selectLine col:beginCol. |
|
2037 |
||
2038 |
beginCol := self findBeginOfWordAtLine:selectLine col:selectCol. |
|
2039 |
endCol := self findEndOfWordAtLine:selectLine col:selectCol. |
|
2040 |
endCol == 0 ifTrue:[ |
|
2041 |
endLine := selectLine + 1 |
|
2042 |
]. |
|
2043 |
||
2044 |
"is the initial acharacter within a word ?" |
|
2045 |
(wordCheck value:thisCharacter) ifTrue:[ |
|
2046 |
" |
|
2047 |
try to catch a blank ... |
|
2048 |
" |
|
2049 |
((beginCol == 1) |
|
2050 |
or:[(self characterAtLine:selectLine col:(beginCol - 1)) |
|
2051 |
~~ Character space]) ifTrue:[ |
|
2052 |
((self characterAtLine:selectLine col:(endCol + 1)) |
|
2053 |
== Character space) ifTrue:[ |
|
2054 |
endCol := endCol + 1. |
|
2055 |
flag := #wordRight |
|
2056 |
] |
|
2057 |
] ifFalse:[ |
|
2058 |
beginCol := beginCol - 1. |
|
2059 |
flag := #wordLeft |
|
2060 |
]. |
|
2061 |
]. |
|
2062 |
aFiveArgBlock value:selectLine |
|
2063 |
value:beginCol |
|
2064 |
value:endLine |
|
2065 |
value:endCol |
|
2066 |
value:flag |
|
2067 |
! ! |
|
2068 |
||
2069 |
!TextView class methodsFor:'documentation'! |
|
2070 |
||
2071 |
version |
|
486
4c1cfc595c51
better error box if printing fails
Claus Gittinger <cg@exept.de>
parents:
478
diff
changeset
|
2072 |
^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.42 1996-03-07 09:01:39 cg Exp $' |
248 | 2073 |
! ! |