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
|
|
14 |
instanceVariableNames:'selectionStartLine selectionStartCol
|
59
|
15 |
selectionEndLine selectionEndCol
|
|
16 |
clickStartLine clickStartCol
|
|
17 |
clickLine clickCol clickCount
|
|
18 |
wordStartCol wordStartLine wordEndCol wordEndLine
|
|
19 |
selectionFgColor selectionBgColor
|
|
20 |
fileBox searchBox lineNumberBox
|
|
21 |
selectStyle
|
|
22 |
directoryForFileDialog
|
|
23 |
contentsWasSaved'
|
38
|
24 |
classVariableNames:'MyFontPanel
|
59
|
25 |
DefaultFont
|
|
26 |
DefaultViewBackground
|
|
27 |
DefaultSelectionForegroundColor
|
|
28 |
DefaultSelectionBackgroundColor'
|
0
|
29 |
poolDictionaries:''
|
|
30 |
category:'Views-Text'
|
|
31 |
!
|
|
32 |
|
|
33 |
TextView comment:'
|
5
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
35 |
All Rights Reserved
|
0
|
36 |
|
121
|
37 |
$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.21 1995-05-06 14:17:58 claus Exp $
|
0
|
38 |
'!
|
|
39 |
|
|
40 |
!TextView class methodsFor:'documentation'!
|
|
41 |
|
38
|
42 |
copyright
|
|
43 |
"
|
|
44 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
45 |
All Rights Reserved
|
38
|
46 |
|
|
47 |
This software is furnished under a license and may be used
|
|
48 |
only in accordance with the terms of that license and with the
|
|
49 |
inclusion of the above copyright notice. This software may not
|
|
50 |
be provided or otherwise made available to, or used by, any
|
|
51 |
other person. No title to or ownership of the software is
|
|
52 |
hereby transferred.
|
|
53 |
"
|
|
54 |
!
|
|
55 |
|
|
56 |
version
|
|
57 |
"
|
121
|
58 |
$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.21 1995-05-06 14:17:58 claus Exp $
|
38
|
59 |
"
|
|
60 |
!
|
|
61 |
|
22
|
62 |
documentation
|
0
|
63 |
"
|
120
|
64 |
a view for readOnly text - this class adds selections to a simple list.
|
38
|
65 |
The text is not editable and there is no cursor.
|
120
|
66 |
Use TextViews for readonly text, EditTextView for editable text.
|
0
|
67 |
|
38
|
68 |
Instance variables:
|
0
|
69 |
|
120
|
70 |
selectionStartLine <Number> the line of the selection start (or nil)
|
|
71 |
selectionStartCol <Number> the col of the selection start
|
|
72 |
selectionEndLine <Number> the line of the selection end
|
|
73 |
selectionEndCol <Number> the col of the selection end
|
|
74 |
clickStartLine <Number> temporary
|
|
75 |
clickStartCol <Number> temporary
|
|
76 |
clickLine <Number> temporary
|
|
77 |
clickCol <Number> temporary
|
|
78 |
clickCount <Number> temporary
|
|
79 |
selectionFgColor <Color> color used to draw selections
|
|
80 |
selectionBgColor <Color> color used to draw selections
|
|
81 |
fileBox <FileSelectionBox> box for save
|
|
82 |
searchBox <EnterBox2> box to enter searchpattern
|
|
83 |
lineNumberBox <EnterBox> box to enter linenumber
|
|
84 |
selectStyle <Symbol> how words are selected
|
|
85 |
directoryForFileDialog <nil|pathName> directory where save dialog should start
|
|
86 |
contentsWasSaved <Boolean> set to true, whenever saved in a file
|
77
|
87 |
|
|
88 |
StyleSheet parameters:
|
|
89 |
|
120
|
90 |
textViewBackground defaults to viewBackground
|
|
91 |
textSelectionForegroundColor defaults to textBackgroundColor
|
|
92 |
textSelectionBackgroundColor defaults to textForegroundColor
|
|
93 |
textViewFont defaults to textFont
|
0
|
94 |
"
|
|
95 |
! !
|
|
96 |
|
|
97 |
!TextView class methodsFor:'startup'!
|
|
98 |
|
|
99 |
setupEmpty
|
59
|
100 |
"create a textview in a topview, with horizontal and
|
|
101 |
vertical scrollbars - a helper for #startWith: and #startOn:"
|
0
|
102 |
|
|
103 |
|top frame label|
|
|
104 |
|
|
105 |
label := 'unnamed'.
|
59
|
106 |
top := StandardSystemView
|
|
107 |
label:label
|
|
108 |
icon:(Form fromFile:'Editor.xbm' resolution:100).
|
0
|
109 |
|
59
|
110 |
frame := HVScrollableView
|
|
111 |
for:self
|
|
112 |
miniScrollerH:true miniScrollerV:false
|
|
113 |
in:top.
|
0
|
114 |
frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
115 |
^ frame scrolledView
|
|
116 |
!
|
|
117 |
|
38
|
118 |
open
|
0
|
119 |
"start an empty TextView"
|
|
120 |
|
38
|
121 |
^ self openWith:nil
|
0
|
122 |
!
|
|
123 |
|
38
|
124 |
openWith:aString
|
0
|
125 |
"start a textView with aString as initial contents"
|
|
126 |
|
|
127 |
|top textView|
|
|
128 |
|
|
129 |
textView := self setupEmpty.
|
|
130 |
top := textView topView.
|
|
131 |
aString notNil ifTrue:[
|
59
|
132 |
textView contents:aString
|
0
|
133 |
].
|
|
134 |
|
7
|
135 |
top open.
|
0
|
136 |
^ textView
|
|
137 |
|
59
|
138 |
"
|
|
139 |
TextView openWith:'some text'
|
|
140 |
EditTextView openWith:'some text'
|
|
141 |
"
|
0
|
142 |
!
|
|
143 |
|
38
|
144 |
openOn:aFileName
|
0
|
145 |
"start a textView on a file"
|
|
146 |
|
120
|
147 |
|top textView stream|
|
0
|
148 |
|
|
149 |
textView := self setupEmpty.
|
|
150 |
top := textView topView.
|
|
151 |
aFileName notNil ifTrue:[
|
59
|
152 |
top label:(OperatingSystem baseNameOf:aFileName).
|
120
|
153 |
stream := aFileName asFilename readStream.
|
|
154 |
stream notNil ifTrue:[
|
|
155 |
textView contents:(stream contents)
|
|
156 |
]
|
0
|
157 |
].
|
|
158 |
|
7
|
159 |
top open.
|
0
|
160 |
^ textView
|
|
161 |
|
59
|
162 |
"
|
|
163 |
TextView openOn:'../doc/info.doc'
|
|
164 |
EditTextView openOn:'../doc/info.doc'
|
|
165 |
"
|
38
|
166 |
! !
|
|
167 |
|
119
|
168 |
!TextView class methodsFor:'instance creation'!
|
|
169 |
|
|
170 |
on:aModel aspect:aspect change:change menu:menu initialSelection:initial
|
|
171 |
"for ST-80 compatibility"
|
|
172 |
|
120
|
173 |
^ (self new)
|
|
174 |
on:aModel
|
|
175 |
aspect:aspect
|
|
176 |
list:aspect
|
|
177 |
change:change
|
|
178 |
menu:menu
|
|
179 |
initialSelection:initial
|
119
|
180 |
! !
|
|
181 |
|
59
|
182 |
!TextView class methodsFor:'defaults'!
|
38
|
183 |
|
59
|
184 |
updateStyleCache
|
60
|
185 |
DefaultViewBackground := StyleSheet colorAt:'textViewBackground' default:White.
|
|
186 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelectionForegroundColor'.
|
|
187 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelectionBackgroundColor'.
|
77
|
188 |
DefaultFont := StyleSheet fontAt:'textViewFont'.
|
0
|
189 |
! !
|
|
190 |
|
|
191 |
!TextView methodsFor:'initialize & release'!
|
|
192 |
|
|
193 |
initialize
|
|
194 |
super initialize.
|
7
|
195 |
contentsWasSaved := false.
|
121
|
196 |
|
|
197 |
"
|
|
198 |
initialize menu to be provided and performed by myself.
|
|
199 |
This allows textViews without a model to provide a
|
|
200 |
reasonable menu AND allows models to provide their own menu.
|
|
201 |
"
|
|
202 |
menuHolder := menuPerformer := self.
|
|
203 |
menuMsg := #editMenu
|
0
|
204 |
!
|
|
205 |
|
|
206 |
initStyle
|
|
207 |
super initStyle.
|
|
208 |
|
59
|
209 |
DefaultFont notNil ifTrue:[
|
|
210 |
font := DefaultFont on:device
|
38
|
211 |
].
|
59
|
212 |
viewBackground := DefaultViewBackground.
|
38
|
213 |
selectionFgColor := DefaultSelectionForegroundColor.
|
59
|
214 |
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
|
38
|
215 |
selectionBgColor := DefaultSelectionBackgroundColor.
|
59
|
216 |
selectionBgColor isNil ifTrue:[
|
|
217 |
device hasColors ifTrue:[
|
|
218 |
DefaultSelectionForegroundColor isNil ifTrue:[
|
|
219 |
selectionFgColor := fgColor
|
|
220 |
].
|
|
221 |
selectionBgColor := Color green
|
|
222 |
] ifFalse:[
|
|
223 |
device hasGreyscales ifTrue:[
|
|
224 |
DefaultSelectionForegroundColor isNil ifTrue:[
|
|
225 |
selectionFgColor := fgColor
|
|
226 |
].
|
|
227 |
selectionBgColor := Color grey
|
|
228 |
] ifFalse:[
|
|
229 |
selectionBgColor := fgColor
|
|
230 |
]
|
|
231 |
]
|
|
232 |
].
|
0
|
233 |
!
|
|
234 |
|
|
235 |
destroy
|
|
236 |
fileBox notNil ifTrue:[
|
59
|
237 |
fileBox destroy.
|
|
238 |
fileBox := nil
|
0
|
239 |
].
|
|
240 |
searchBox notNil ifTrue:[
|
59
|
241 |
searchBox destroy.
|
|
242 |
searchBox := nil
|
0
|
243 |
].
|
|
244 |
lineNumberBox notNil ifTrue:[
|
59
|
245 |
lineNumberBox destroy.
|
|
246 |
lineNumberBox := nil
|
0
|
247 |
].
|
|
248 |
super destroy
|
|
249 |
! !
|
|
250 |
|
119
|
251 |
!TextView methodsFor:'accessing-mvc'!
|
|
252 |
|
120
|
253 |
on:aModel aspect:aspectSym list:listSym change:changeSym menu:menuSym initialSelection:initial
|
119
|
254 |
"ST-80 compatibility"
|
|
255 |
|
120
|
256 |
aspectSym notNil ifTrue:[aspectMsg := aspectSym. listMsg := aspectSym].
|
|
257 |
changeSym notNil ifTrue:[changeMsg := changeSym].
|
|
258 |
listSym notNil ifTrue:[listMsg := listSym].
|
|
259 |
menuSym notNil ifTrue:[menuMsg := menuSym].
|
119
|
260 |
"/ initial notNil ifTrue:[initialSelectionMsg := initial].
|
|
261 |
self model:aModel.
|
|
262 |
|
|
263 |
listMsg notNil ifTrue:[
|
|
264 |
self getListFromModel
|
|
265 |
].
|
|
266 |
! !
|
|
267 |
|
0
|
268 |
!TextView methodsFor:'accessing'!
|
|
269 |
|
|
270 |
selectionForegroundColor:color1 backgroundColor:color2
|
|
271 |
"set both selection-foreground and cursor background colors"
|
|
272 |
|
|
273 |
selectionFgColor := color1 on:device.
|
|
274 |
selectionBgColor := color2 on:device.
|
|
275 |
shown ifTrue:[
|
59
|
276 |
self redraw
|
0
|
277 |
]
|
|
278 |
!
|
|
279 |
|
|
280 |
setList:something
|
|
281 |
"set the displayed contents (a collection of strings)
|
|
282 |
without redraw.
|
|
283 |
Redefined since changing contents implies deselect"
|
|
284 |
|
|
285 |
self unselect.
|
|
286 |
super setList:something
|
|
287 |
!
|
|
288 |
|
|
289 |
list:something
|
|
290 |
"set the displayed contents (a collection of strings)
|
|
291 |
with redraw.
|
|
292 |
Redefined since changing contents implies deselect"
|
|
293 |
|
|
294 |
self unselect.
|
|
295 |
super list:something
|
|
296 |
!
|
|
297 |
|
|
298 |
characterAtLine:lineNr col:colNr
|
|
299 |
"return the character at physical line/col -
|
|
300 |
return space if nothing is there"
|
|
301 |
|
|
302 |
|line|
|
|
303 |
|
|
304 |
list notNil ifTrue:[
|
59
|
305 |
line := self listAt:lineNr.
|
|
306 |
line notNil ifTrue:[
|
|
307 |
(line size >= colNr) ifTrue:[
|
|
308 |
^ line at:colNr
|
|
309 |
]
|
|
310 |
]
|
0
|
311 |
].
|
|
312 |
^ Character space
|
|
313 |
!
|
|
314 |
|
|
315 |
characterPositionOfSelection
|
|
316 |
"return the character index of the first character in the selection"
|
|
317 |
|
|
318 |
selectionStartLine isNil ifTrue:[^ 1].
|
|
319 |
^ self characterPositionOfLine:selectionStartLine
|
59
|
320 |
col:selectionStartCol
|
0
|
321 |
!
|
|
322 |
|
|
323 |
directoryForFileDialog:aDirectory
|
|
324 |
"define the directory to use for save-box"
|
|
325 |
|
|
326 |
directoryForFileDialog := aDirectory
|
|
327 |
!
|
|
328 |
|
|
329 |
contentsWasSaved
|
|
330 |
"return true, if the contents was saved (by a save action),
|
|
331 |
false if not (or was modified again after the last save)."
|
|
332 |
|
|
333 |
^ contentsWasSaved
|
|
334 |
!
|
|
335 |
|
|
336 |
fromFile:aFileName
|
|
337 |
"take contents from a named file"
|
|
338 |
|
|
339 |
self directoryForFileDialog:(OperatingSystem directoryNameOf:aFileName).
|
|
340 |
self contents:(FileStream oldFileNamed:aFileName) contents
|
|
341 |
! !
|
|
342 |
|
|
343 |
!TextView methodsFor:'private'!
|
|
344 |
|
|
345 |
fileOutContentsOn:aStream
|
59
|
346 |
"save contents on a stream, replacing leading spaces by tab-characters."
|
|
347 |
|
|
348 |
self fileOutContentsOn:aStream compressTabs:true
|
|
349 |
!
|
|
350 |
|
|
351 |
fileOutContentsOn:aStream compressTabs:compressTabs
|
|
352 |
"save contents on a stream. If compressTabs is true,
|
|
353 |
leading spaces will be replaced by tab-characters in the output."
|
0
|
354 |
|
38
|
355 |
|startNr nLines string|
|
|
356 |
|
|
357 |
"on some systems, writing linewise is very slow (via NFS)
|
59
|
358 |
therefore we convert to a string and write it in big chunks.
|
|
359 |
To avoid creating huge strings, we do it in blocks of 1000 lines,
|
|
360 |
limiting temporary string creation to about 50-80k.
|
38
|
361 |
"
|
|
362 |
startNr := 1.
|
|
363 |
nLines := list size.
|
|
364 |
[startNr <= nLines] whileTrue:[
|
89
|
365 |
string := list asStringWithCRsFrom:startNr
|
97
|
366 |
to:((startNr + 1000) min:nLines)
|
|
367 |
compressTabs:compressTabs.
|
59
|
368 |
aStream nextPutAll:string.
|
|
369 |
startNr := startNr + 1000 + 1.
|
38
|
370 |
].
|
|
371 |
|
89
|
372 |
"/ "the old (obsolete) code:"
|
|
373 |
"/
|
|
374 |
"/ list do:[:aLine |
|
|
375 |
"/ aLine notNil ifTrue:[
|
97
|
376 |
"/ aStream nextPutAll:aLine.
|
89
|
377 |
"/ ].
|
|
378 |
"/ aStream cr
|
|
379 |
"/ ]
|
|
380 |
|
0
|
381 |
!
|
|
382 |
|
|
383 |
widthForScrollBetween:firstLine and:lastLine
|
|
384 |
"return the width in pixels for a scroll between firstLine and lastLine"
|
|
385 |
|
|
386 |
selectionStartLine notNil ifTrue:[
|
59
|
387 |
(lastLine < selectionStartLine) ifFalse:[
|
|
388 |
(firstLine > selectionEndLine) ifFalse:[
|
|
389 |
^ width
|
|
390 |
]
|
|
391 |
]
|
0
|
392 |
].
|
|
393 |
^ super widthForScrollBetween:firstLine and:lastLine
|
|
394 |
!
|
|
395 |
|
|
396 |
scrollSelectUp
|
|
397 |
"auto scroll action; scroll and reinstall timed-block"
|
|
398 |
|
22
|
399 |
|prevStartLine|
|
|
400 |
|
38
|
401 |
"just to make certain ..."
|
|
402 |
selectionStartLine isNil ifTrue:[^ self].
|
|
403 |
|
22
|
404 |
self scrollUp.
|
|
405 |
|
|
406 |
"make new selection immediately visible"
|
|
407 |
prevStartLine := selectionStartLine.
|
|
408 |
selectionStartLine := firstLineShown.
|
|
409 |
selectionStartCol := 1.
|
|
410 |
selectionStartLine to:prevStartLine do:[:lineNr |
|
59
|
411 |
self redrawLine:lineNr
|
22
|
412 |
].
|
38
|
413 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
414 |
!
|
|
415 |
|
|
416 |
scrollSelectDown
|
|
417 |
"auto scroll action; scroll and reinstall timed-block"
|
|
418 |
|
22
|
419 |
|prevEndLine|
|
|
420 |
|
38
|
421 |
"just to make certain ..."
|
|
422 |
selectionEndLine isNil ifTrue:[^ self].
|
|
423 |
|
22
|
424 |
self scrollDown.
|
|
425 |
|
|
426 |
"make new selection immediately visible"
|
|
427 |
prevEndLine := selectionEndLine.
|
|
428 |
selectionEndLine := firstLineShown + nFullLinesShown.
|
|
429 |
selectionEndCol := 0.
|
|
430 |
prevEndLine to:selectionEndLine do:[:lineNr |
|
59
|
431 |
self redrawLine:lineNr
|
22
|
432 |
].
|
38
|
433 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
434 |
!
|
|
435 |
|
|
436 |
stopScrollSelect
|
|
437 |
"stop auto scroll; deinstall timed-block"
|
|
438 |
|
|
439 |
autoScrollBlock notNil ifTrue:[
|
59
|
440 |
Processor removeTimedBlock:autoScrollBlock.
|
|
441 |
self compressMotionEvents:true.
|
|
442 |
autoScrollBlock := nil.
|
|
443 |
autoScrollDeltaT := nil
|
0
|
444 |
]
|
59
|
445 |
!
|
|
446 |
|
|
447 |
scrollSelectLeft
|
|
448 |
"auto scroll action; scroll and reinstall timed-block"
|
|
449 |
|
|
450 |
|prevStartLine|
|
|
451 |
|
|
452 |
"just to make certain ..."
|
|
453 |
selectionStartLine isNil ifTrue:[^ self].
|
|
454 |
selectionStartCol isNil ifTrue:[^ self].
|
|
455 |
|
|
456 |
"make new selection immediately visible"
|
|
457 |
prevStartLine := selectionStartLine.
|
|
458 |
selectionStartCol := selectionStartCol - 1 max:1.
|
|
459 |
self scrollLeft.
|
|
460 |
|
|
461 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
|
462 |
!
|
|
463 |
|
|
464 |
scrollSelectRight
|
|
465 |
"auto scroll action; scroll and reinstall timed-block"
|
|
466 |
|
|
467 |
|prevEndCol|
|
|
468 |
|
|
469 |
"just to make certain ..."
|
|
470 |
selectionEndCol isNil ifTrue:[^ self].
|
|
471 |
|
|
472 |
prevEndCol := selectionEndCol.
|
|
473 |
selectionEndCol := selectionEndCol + 1.
|
|
474 |
self scrollRight.
|
|
475 |
|
|
476 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
477 |
! !
|
|
478 |
|
59
|
479 |
|
0
|
480 |
!TextView methodsFor:'menu actions'!
|
|
481 |
|
97
|
482 |
editMenu
|
|
483 |
|labels selectors m|
|
|
484 |
|
|
485 |
labels := #(
|
|
486 |
'copy'
|
|
487 |
'-'
|
|
488 |
'font ...'
|
|
489 |
'-'
|
|
490 |
'search ...'
|
|
491 |
'goto ...'
|
|
492 |
'-'
|
|
493 |
'save as ...'
|
|
494 |
'print'
|
|
495 |
).
|
|
496 |
|
|
497 |
selectors := #(
|
|
498 |
copySelection
|
|
499 |
nil
|
|
500 |
changeFont
|
|
501 |
nil
|
|
502 |
search
|
|
503 |
gotoLine
|
|
504 |
nil
|
|
505 |
save
|
|
506 |
print
|
|
507 |
).
|
|
508 |
|
|
509 |
m := PopUpMenu
|
|
510 |
labels:(resources array:labels)
|
|
511 |
selectors:selectors.
|
|
512 |
|
|
513 |
self hasSelection ifFalse:[
|
|
514 |
m disable:#copySelection.
|
|
515 |
].
|
|
516 |
^ m
|
|
517 |
!
|
|
518 |
|
0
|
519 |
print
|
|
520 |
"print the contents on the printer"
|
|
521 |
|
|
522 |
|printStream|
|
|
523 |
|
|
524 |
list isNil ifTrue:[^ self].
|
|
525 |
printStream := Printer new.
|
|
526 |
printStream notNil ifTrue:[
|
59
|
527 |
self fileOutContentsOn:printStream.
|
|
528 |
printStream close
|
0
|
529 |
]
|
|
530 |
!
|
|
531 |
|
|
532 |
saveAs:fileName
|
|
533 |
"save contents into a file named fileName"
|
|
534 |
|
3
|
535 |
|aStream msg|
|
0
|
536 |
|
|
537 |
aStream := FileStream newFileNamed:fileName.
|
3
|
538 |
aStream isNil ifTrue:[
|
59
|
539 |
msg := resources string:'cannot write file %1 !!' with:fileName.
|
|
540 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
|
3
|
541 |
] ifFalse:[
|
59
|
542 |
self fileOutContentsOn:aStream.
|
|
543 |
aStream close.
|
|
544 |
contentsWasSaved := true
|
0
|
545 |
]
|
|
546 |
!
|
|
547 |
|
38
|
548 |
appendTo:fileName
|
|
549 |
"append contents to a file named fileName"
|
|
550 |
|
|
551 |
|aStream msg|
|
|
552 |
|
|
553 |
aStream := FileStream appendingOldFileNamed:fileName.
|
|
554 |
aStream isNil ifTrue:[
|
59
|
555 |
msg := resources string:'cannot append to file %1 !!' with:fileName.
|
|
556 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
|
38
|
557 |
] ifFalse:[
|
59
|
558 |
self fileOutContentsOn:aStream.
|
|
559 |
aStream close.
|
|
560 |
contentsWasSaved := true
|
38
|
561 |
]
|
|
562 |
!
|
|
563 |
|
0
|
564 |
save
|
|
565 |
"save contents into a file
|
|
566 |
- ask user for filename using a fileSelectionBox."
|
|
567 |
|
|
568 |
fileBox isNil ifTrue:[
|
59
|
569 |
fileBox := FileSaveBox
|
|
570 |
title:(resources string:'save contents in:')
|
|
571 |
okText:(resources string:'save')
|
|
572 |
abortText:(resources string:'cancel')
|
|
573 |
action:[:fileName | self saveAs:fileName].
|
|
574 |
fileBox appendAction:[:fileName | self appendTo:fileName].
|
0
|
575 |
].
|
|
576 |
directoryForFileDialog notNil ifTrue:[
|
59
|
577 |
fileBox directory:directoryForFileDialog
|
0
|
578 |
].
|
|
579 |
fileBox showAtPointer
|
|
580 |
!
|
|
581 |
|
|
582 |
copySelection
|
|
583 |
"copy contents into smalltalk copybuffer"
|
|
584 |
|
|
585 |
|text|
|
|
586 |
|
|
587 |
text := self selection.
|
|
588 |
text notNil ifTrue:[
|
77
|
589 |
self unselect.
|
|
590 |
self setTextSelection:text
|
0
|
591 |
]
|
|
592 |
!
|
|
593 |
|
|
594 |
changeFont
|
|
595 |
"pop up a fontPanel to change font"
|
|
596 |
|
77
|
597 |
|panel|
|
|
598 |
|
|
599 |
panel := FontPanel new.
|
|
600 |
panel action:[:family :face :style :size |
|
59
|
601 |
self font:(Font family:family
|
|
602 |
face:face
|
|
603 |
style:style
|
|
604 |
size:size)
|
0
|
605 |
].
|
77
|
606 |
panel initialFont:font.
|
|
607 |
panel showAtPointer
|
0
|
608 |
!
|
|
609 |
|
59
|
610 |
defaultForGotoLine
|
|
611 |
"return a default value to show in the gotoLine box"
|
|
612 |
|
|
613 |
^ nil
|
|
614 |
!
|
|
615 |
|
0
|
616 |
gotoLine
|
|
617 |
"show a box to enter lineNumber for positioning"
|
|
618 |
|
59
|
619 |
|l|
|
|
620 |
|
0
|
621 |
lineNumberBox isNil ifTrue:[
|
59
|
622 |
lineNumberBox :=
|
|
623 |
EnterBox
|
|
624 |
title:(resources string:'line number:')
|
120
|
625 |
okText:(resources string:'goto')
|
|
626 |
abortText:(resources string:'cancel')
|
|
627 |
action:[:l | |num|
|
|
628 |
num := Integer readFromString:l onError:nil.
|
|
629 |
num notNil ifTrue:[self gotoLine:num]
|
|
630 |
]
|
0
|
631 |
].
|
59
|
632 |
l := self defaultForGotoLine.
|
|
633 |
l notNil ifTrue:[
|
|
634 |
l := l printString
|
|
635 |
].
|
|
636 |
lineNumberBox initialText:l .
|
0
|
637 |
lineNumberBox showAtPointer
|
|
638 |
! !
|
|
639 |
|
|
640 |
!TextView methodsFor:'selections'!
|
|
641 |
|
|
642 |
unselectWithoutRedraw
|
|
643 |
"forget selection but do not redraw the selection area
|
120
|
644 |
- can be done when the selected area is redrawn anyway or
|
0
|
645 |
known to be invisible."
|
|
646 |
|
|
647 |
selectionStartLine := nil.
|
|
648 |
!
|
|
649 |
|
|
650 |
unselect
|
38
|
651 |
"unselect - if there was a selection redraw that area"
|
0
|
652 |
|
|
653 |
|startLine endLine startVisLine endVisLine|
|
|
654 |
|
|
655 |
selectionStartLine notNil ifTrue:[
|
59
|
656 |
startLine := selectionStartLine.
|
|
657 |
endLine := selectionEndLine.
|
|
658 |
selectionStartLine := nil.
|
0
|
659 |
|
59
|
660 |
"if selection is not visible, we are done"
|
|
661 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self].
|
|
662 |
endLine < firstLineShown ifTrue:[^ self].
|
0
|
663 |
|
59
|
664 |
startLine < firstLineShown ifTrue:[
|
|
665 |
startVisLine := 1
|
|
666 |
] ifFalse:[
|
|
667 |
startVisLine := self listLineToVisibleLine:startLine
|
|
668 |
].
|
|
669 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[
|
|
670 |
endVisLine := nLinesShown
|
|
671 |
] ifFalse:[
|
|
672 |
endVisLine := self listLineToVisibleLine:endLine
|
|
673 |
].
|
|
674 |
"if its only part of a line, just redraw what has to be"
|
|
675 |
(startVisLine == endVisLine) ifTrue:[
|
|
676 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol
|
|
677 |
] ifFalse:[
|
|
678 |
super redrawFromVisibleLine:startVisLine to:endVisLine
|
|
679 |
].
|
|
680 |
self unselectWithoutRedraw
|
0
|
681 |
].
|
38
|
682 |
selectStyle := nil
|
0
|
683 |
!
|
|
684 |
|
|
685 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol
|
38
|
686 |
"select a piece of text and redraw that area"
|
0
|
687 |
|
|
688 |
self unselect.
|
|
689 |
startLine notNil ifTrue:[
|
59
|
690 |
"new:"
|
|
691 |
endLine < startLine ifTrue:[
|
|
692 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
|
|
693 |
].
|
|
694 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[
|
|
695 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
|
|
696 |
].
|
7
|
697 |
|
|
698 |
" old:
|
59
|
699 |
endLine < startLine ifTrue:[^ self].
|
|
700 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
|
7
|
701 |
"
|
59
|
702 |
selectionStartLine := startLine.
|
|
703 |
selectionStartCol := startCol.
|
|
704 |
selectionEndLine := endLine.
|
|
705 |
selectionEndCol := endCol.
|
|
706 |
(startLine == endLine) ifTrue:[
|
|
707 |
self redrawLine:startLine from:startCol to:endCol
|
|
708 |
] ifFalse:[
|
|
709 |
startLine to:endLine do:[:lineNr |
|
|
710 |
self redrawLine:lineNr
|
|
711 |
]
|
|
712 |
].
|
|
713 |
selectStyle := nil.
|
0
|
714 |
]
|
|
715 |
!
|
|
716 |
|
|
717 |
selectLine:selectLine
|
38
|
718 |
"select one line and redraw it"
|
0
|
719 |
|
38
|
720 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0.
|
|
721 |
wordStartCol := selectionStartCol.
|
|
722 |
wordEndCol := selectionEndCol.
|
|
723 |
wordStartLine := selectionStartLine.
|
|
724 |
wordEndLine := selectionEndLine.
|
|
725 |
selectStyle := #line
|
0
|
726 |
!
|
|
727 |
|
|
728 |
selectLineWhereCharacterPosition:pos
|
|
729 |
"select the line, where characterPosition pos is living.
|
38
|
730 |
The argument pos starts at 1 from the start of the text
|
|
731 |
and counts characters (i.e. can be used to convert from
|
|
732 |
character position within a string to line-position in view)."
|
0
|
733 |
|
|
734 |
self selectLine:(self lineOfCharacterPosition:pos)
|
|
735 |
!
|
|
736 |
|
|
737 |
selectFromCharacterPosition:pos1 to:pos2
|
|
738 |
"compute line/col from character positions and select the text"
|
|
739 |
|
|
740 |
|line1 col1 line2 col2|
|
|
741 |
|
|
742 |
line1 := self lineOfCharacterPosition:pos1.
|
|
743 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
|
|
744 |
line2 := self lineOfCharacterPosition:pos2.
|
|
745 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1.
|
|
746 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2
|
|
747 |
!
|
|
748 |
|
59
|
749 |
wordAtLine:selectLine col:selectCol do:aFiveArgBlock
|
|
750 |
"find word boundaries, evaluate the block argument with those.
|
|
751 |
A helper for nextWord and selectWord functions."
|
0
|
752 |
|
60
|
753 |
|beginCol endCol endLine thisCharacter flag|
|
0
|
754 |
|
38
|
755 |
flag := #word.
|
0
|
756 |
beginCol := selectCol.
|
|
757 |
endCol := selectCol.
|
38
|
758 |
endLine := selectLine.
|
0
|
759 |
thisCharacter := self characterAtLine:selectLine col:beginCol.
|
7
|
760 |
|
38
|
761 |
beginCol := self findBeginOfWordAtLine:selectLine col:selectCol.
|
|
762 |
endCol := self findEndOfWordAtLine:selectLine col:selectCol.
|
|
763 |
endCol == 0 ifTrue:[
|
59
|
764 |
endLine := selectLine + 1
|
38
|
765 |
].
|
|
766 |
|
|
767 |
"is the initial acharacter within a word ?"
|
7
|
768 |
(wordCheck value:thisCharacter) ifTrue:[
|
59
|
769 |
"
|
|
770 |
try to catch a blank ...
|
|
771 |
"
|
|
772 |
((beginCol == 1)
|
|
773 |
or:[(self characterAtLine:selectLine col:(beginCol - 1))
|
|
774 |
~~ Character space]) ifTrue:[
|
|
775 |
((self characterAtLine:selectLine col:(endCol + 1))
|
|
776 |
== Character space) ifTrue:[
|
|
777 |
endCol := endCol + 1.
|
|
778 |
flag := #wordRight
|
|
779 |
]
|
|
780 |
] ifFalse:[
|
|
781 |
beginCol := beginCol - 1.
|
|
782 |
flag := #wordLeft
|
|
783 |
].
|
0
|
784 |
].
|
59
|
785 |
aFiveArgBlock value:selectLine
|
|
786 |
value:beginCol
|
|
787 |
value:endLine
|
|
788 |
value:endCol
|
|
789 |
value:flag
|
|
790 |
!
|
|
791 |
|
|
792 |
selectWordAtLine:line col:col
|
|
793 |
"select the word at given line/col"
|
|
794 |
|
|
795 |
self wordAtLine:line col:col do:[
|
|
796 |
:beginLine :beginCol :endLine :endCol :style |
|
|
797 |
|
|
798 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
|
|
799 |
selectStyle := style
|
|
800 |
]
|
0
|
801 |
!
|
|
802 |
|
|
803 |
selectWordAtX:x y:y
|
|
804 |
"select the word at given x/y-(view-)coordinate"
|
|
805 |
|
|
806 |
|selectVisibleLine selectLine selectCol|
|
|
807 |
|
38
|
808 |
selectStyle := nil.
|
0
|
809 |
selectVisibleLine := self visibleLineOfY:y.
|
|
810 |
selectLine := self visibleLineToListLine:selectVisibleLine.
|
|
811 |
selectLine notNil ifTrue:[
|
59
|
812 |
selectCol := self colOfX:x inVisibleLine:selectLine.
|
|
813 |
self selectWordAtLine:selectLine col:selectCol
|
0
|
814 |
]
|
|
815 |
!
|
|
816 |
|
|
817 |
selectLineAtY:y
|
|
818 |
"select the line at given y-(view-)coordinate"
|
|
819 |
|
|
820 |
|selectVisibleLine selectLine|
|
|
821 |
|
|
822 |
selectVisibleLine := self visibleLineOfY:y.
|
|
823 |
selectLine := self visibleLineToListLine:selectVisibleLine.
|
|
824 |
selectLine notNil ifTrue:[
|
59
|
825 |
self selectLine:selectLine
|
0
|
826 |
]
|
|
827 |
!
|
|
828 |
|
|
829 |
selectAll
|
|
830 |
"select the whole text"
|
|
831 |
|
|
832 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0
|
|
833 |
!
|
|
834 |
|
38
|
835 |
hasSelection
|
|
836 |
"return true, if there is a selection"
|
|
837 |
|
|
838 |
^ selectionStartLine notNil
|
|
839 |
!
|
|
840 |
|
0
|
841 |
selection
|
38
|
842 |
"return the selection as a collection of (line-)strings"
|
0
|
843 |
|
81
|
844 |
|text sz index
|
|
845 |
startLine "{ Class: SmallInteger }"
|
|
846 |
endLine "{ Class: SmallInteger }"|
|
0
|
847 |
|
|
848 |
selectionStartLine isNil ifTrue:[^ nil].
|
81
|
849 |
startLine := selectionStartLine.
|
|
850 |
endLine := selectionEndLine.
|
|
851 |
|
|
852 |
(startLine == endLine) ifTrue:[
|
59
|
853 |
"part of a line"
|
81
|
854 |
^ StringCollection with:(self listAt:startLine
|
|
855 |
from:selectionStartCol
|
|
856 |
to:selectionEndCol)
|
0
|
857 |
].
|
81
|
858 |
sz := endLine - startLine + 1.
|
|
859 |
text := StringCollection new:sz.
|
0
|
860 |
|
|
861 |
"get 1st and last (possibly) partial lines"
|
81
|
862 |
text at:1 put:(self listAt:startLine from:selectionStartCol).
|
|
863 |
selectionEndCol == 0 ifTrue:[
|
|
864 |
text at:sz put:''
|
|
865 |
] ifFalse:[
|
|
866 |
text at:sz put:(self listAt:selectionEndLine to:selectionEndCol).
|
|
867 |
].
|
0
|
868 |
|
|
869 |
"get bulk of text"
|
|
870 |
index := 2.
|
81
|
871 |
(startLine + 1) to:(endLine - 1) do:[:lineNr |
|
59
|
872 |
text at:index put:(self listAt:lineNr).
|
|
873 |
index := index + 1
|
0
|
874 |
].
|
|
875 |
^ text
|
|
876 |
!
|
|
877 |
|
|
878 |
makeSelectionVisible
|
120
|
879 |
"scroll to make the selection visible"
|
0
|
880 |
|
|
881 |
selectionStartLine notNil ifTrue:[
|
59
|
882 |
self makeLineVisible:selectionStartLine
|
0
|
883 |
]
|
|
884 |
! !
|
|
885 |
|
|
886 |
!TextView methodsFor:'searching'!
|
|
887 |
|
|
888 |
search
|
|
889 |
"show a box to enter searchpattern
|
|
890 |
- currently no regular expressions are handled."
|
|
891 |
|
63
|
892 |
"
|
|
893 |
cache the searchBox
|
|
894 |
Q: should we use one global searchBox for all textViews ?
|
|
895 |
(we could then preserve the last searchstring between views)
|
|
896 |
"
|
0
|
897 |
searchBox isNil ifTrue:[
|
59
|
898 |
searchBox :=
|
|
899 |
EnterBox2
|
|
900 |
title:(resources at:'searchPattern:')
|
|
901 |
okText1:(resources at:'prev')
|
|
902 |
okText2:(resources at:'next')
|
|
903 |
abortText:(resources at:'cancel')
|
|
904 |
action1:[:pattern | self searchBwd:(pattern withoutSeparators)]
|
|
905 |
action2:[:pattern | self searchFwd:(pattern withoutSeparators)]
|
0
|
906 |
].
|
|
907 |
searchPattern notNil ifTrue:[
|
59
|
908 |
searchBox initialText:searchPattern
|
0
|
909 |
].
|
63
|
910 |
self hasSelection ifTrue:[
|
|
911 |
selectionStartLine == selectionEndLine ifTrue:[
|
|
912 |
searchBox initialText:self selection
|
|
913 |
]
|
|
914 |
].
|
0
|
915 |
searchBox showAtPointer
|
|
916 |
!
|
|
917 |
|
63
|
918 |
setSearchPattern:aString
|
|
919 |
"set the searchpattern for future searches"
|
|
920 |
|
70
|
921 |
aString isNil ifTrue:[
|
|
922 |
searchPattern := aString
|
|
923 |
] ifFalse:[
|
|
924 |
searchPattern := aString withoutSeparators
|
|
925 |
]
|
63
|
926 |
!
|
|
927 |
|
0
|
928 |
setSearchPattern
|
|
929 |
"set the searchpattern from the selection if there is one"
|
|
930 |
|
|
931 |
|sel|
|
|
932 |
|
|
933 |
sel := self selection.
|
|
934 |
sel notNil ifTrue:[
|
59
|
935 |
searchPattern := sel asString withoutSeparators
|
0
|
936 |
]
|
|
937 |
!
|
|
938 |
|
63
|
939 |
searchPattern
|
|
940 |
"return the last search pattern"
|
|
941 |
|
|
942 |
^ searchPattern
|
|
943 |
!
|
|
944 |
|
0
|
945 |
showNotFound
|
|
946 |
"search not found - tell user by beeping and changing
|
|
947 |
cursor for a while (sometimes I work with a headset :-)
|
|
948 |
(used to be: tell user by changing cursor for a while)"
|
|
949 |
|
|
950 |
|savedCursor|
|
|
951 |
|
|
952 |
device beep.
|
77
|
953 |
|
0
|
954 |
"
|
|
955 |
uncomment if you want a CROSS cursor to be shown for a while ..
|
|
956 |
"
|
|
957 |
|
|
958 |
" "
|
|
959 |
savedCursor := cursor.
|
|
960 |
self cursor:(Cursor cross).
|
|
961 |
OperatingSystem millisecondDelay:300.
|
|
962 |
self cursor:savedCursor
|
|
963 |
" "
|
|
964 |
!
|
|
965 |
|
|
966 |
searchFwd
|
|
967 |
"search forward for pattern or selection"
|
|
968 |
|
63
|
969 |
selectStyle == #wordLeft ifTrue:[
|
|
970 |
"
|
|
971 |
remove the space from the selection
|
|
972 |
"
|
|
973 |
selectionStartCol := selectionStartCol + 1.
|
|
974 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
|
|
975 |
].
|
0
|
976 |
self setSearchPattern.
|
|
977 |
searchPattern notNil ifTrue:[
|
59
|
978 |
self searchFwd:searchPattern
|
0
|
979 |
]
|
|
980 |
!
|
|
981 |
|
|
982 |
searchBwd
|
|
983 |
"search backward and -if found- position cursor"
|
|
984 |
|
|
985 |
self setSearchPattern.
|
|
986 |
searchPattern notNil ifTrue:[
|
59
|
987 |
self searchBwd:searchPattern
|
0
|
988 |
]
|
|
989 |
!
|
|
990 |
|
|
991 |
searchFwd:pattern
|
63
|
992 |
"do a forward search"
|
|
993 |
|
|
994 |
self searchFwd:pattern ifAbsent:[self showNotFound].
|
|
995 |
searchPattern := pattern
|
|
996 |
!
|
|
997 |
|
|
998 |
searchBwd:pattern
|
|
999 |
"do a backward search"
|
|
1000 |
|
|
1001 |
self searchBwd:pattern ifAbsent:[self showNotFound].
|
|
1002 |
searchPattern := pattern
|
|
1003 |
|
|
1004 |
!
|
|
1005 |
|
|
1006 |
searchFwd:pattern ifAbsent:aBlock
|
|
1007 |
"do a forward search"
|
0
|
1008 |
|
|
1009 |
|startLine startCol|
|
|
1010 |
|
|
1011 |
selectionStartLine notNil ifTrue:[
|
59
|
1012 |
startLine := selectionStartLine.
|
|
1013 |
startCol := selectionStartCol
|
0
|
1014 |
] ifFalse:[
|
59
|
1015 |
startLine := 1.
|
|
1016 |
startCol := 1
|
0
|
1017 |
].
|
|
1018 |
self searchForwardFor:pattern startingAtLine:startLine col:startCol
|
|
1019 |
ifFound:[:line :col |
|
59
|
1020 |
self selectFromLine:line col:col
|
|
1021 |
toLine:line col:(col + pattern size - 1).
|
|
1022 |
self makeLineVisible:line
|
63
|
1023 |
] ifAbsent:aBlock
|
0
|
1024 |
!
|
|
1025 |
|
63
|
1026 |
searchBwd:pattern ifAbsent:aBlock
|
|
1027 |
"do a backward search"
|
0
|
1028 |
|
|
1029 |
|startLine startCol|
|
|
1030 |
|
|
1031 |
selectionStartLine notNil ifTrue:[
|
59
|
1032 |
startLine := selectionStartLine.
|
|
1033 |
startCol := selectionStartCol
|
0
|
1034 |
] ifFalse:[
|
59
|
1035 |
startLine := 1.
|
|
1036 |
startCol := 1
|
0
|
1037 |
].
|
|
1038 |
self searchBackwardFor:pattern startingAtLine:startLine col:startCol
|
|
1039 |
ifFound:[:line :col |
|
59
|
1040 |
self selectFromLine:line col:col
|
|
1041 |
toLine:line col:(col + pattern size - 1).
|
|
1042 |
self makeLineVisible:line
|
63
|
1043 |
] ifAbsent:aBlock
|
0
|
1044 |
! !
|
|
1045 |
|
|
1046 |
!TextView methodsFor:'redrawing'!
|
|
1047 |
|
|
1048 |
clearMarginOfVisible:visLine with:color
|
|
1049 |
"if there is a margin, clear it - a helper for selection drawing"
|
|
1050 |
|
|
1051 |
(leftMargin ~~ 0) ifTrue:[
|
59
|
1052 |
self paint:color.
|
|
1053 |
self fillRectangleX:margin
|
|
1054 |
y:(self yOfVisibleLine:visLine)
|
|
1055 |
width:leftMargin
|
|
1056 |
height:fontHeight
|
0
|
1057 |
]
|
|
1058 |
!
|
|
1059 |
|
|
1060 |
redrawVisibleLine:visLine col:col
|
|
1061 |
"redraw single character at col in visible line lineNr"
|
|
1062 |
|
|
1063 |
|line|
|
|
1064 |
|
|
1065 |
line := self visibleLineToAbsoluteLine:visLine.
|
|
1066 |
selectionStartLine notNil ifTrue:[
|
59
|
1067 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[
|
|
1068 |
((line == selectionStartLine)
|
|
1069 |
and: [col < selectionStartCol]) ifFalse:[
|
|
1070 |
((line == selectionEndLine)
|
|
1071 |
and: [col > selectionEndCol]) ifFalse:[
|
|
1072 |
"its in the selection"
|
|
1073 |
self drawVisibleLine:visLine col:col with:selectionFgColor
|
|
1074 |
and:selectionBgColor.
|
|
1075 |
^ self
|
|
1076 |
]
|
|
1077 |
]
|
|
1078 |
]
|
0
|
1079 |
].
|
|
1080 |
super redrawVisibleLine:visLine col:col
|
|
1081 |
!
|
|
1082 |
|
|
1083 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
|
|
1084 |
"redraw a visible line range"
|
|
1085 |
|
|
1086 |
|startLine endLine specialCare end selVisStart line1 line2|
|
|
1087 |
|
|
1088 |
shown ifFalse:[^ self].
|
|
1089 |
|
|
1090 |
end := endVisLineNr.
|
|
1091 |
(end > nLinesShown) ifTrue:[
|
59
|
1092 |
end := nLinesShown
|
0
|
1093 |
].
|
|
1094 |
|
|
1095 |
selectionStartLine isNil ifTrue:[
|
59
|
1096 |
specialCare := false
|
0
|
1097 |
] ifFalse:[
|
59
|
1098 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr.
|
|
1099 |
(startLine > selectionEndLine) ifTrue:[
|
|
1100 |
specialCare := false
|
|
1101 |
] ifFalse:[
|
|
1102 |
endLine := self visibleLineToAbsoluteLine:end.
|
|
1103 |
(endLine < selectionStartLine) ifTrue:[
|
|
1104 |
specialCare := false
|
|
1105 |
] ifFalse:[
|
|
1106 |
specialCare := true
|
|
1107 |
]
|
|
1108 |
]
|
0
|
1109 |
].
|
|
1110 |
|
|
1111 |
"easy: nothing is selected"
|
|
1112 |
specialCare ifFalse:[
|
59
|
1113 |
super redrawFromVisibleLine:startVisLineNr to:end.
|
|
1114 |
^ self
|
0
|
1115 |
].
|
|
1116 |
|
|
1117 |
"easy: all is selected"
|
|
1118 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[
|
59
|
1119 |
self drawFromVisibleLine:startVisLineNr to:end with:selectionFgColor
|
|
1120 |
and:selectionBgColor.
|
|
1121 |
^ self
|
0
|
1122 |
].
|
|
1123 |
|
|
1124 |
(selectionStartLine >= firstLineShown) ifTrue:[
|
59
|
1125 |
"draw unselected top part"
|
0
|
1126 |
|
59
|
1127 |
selVisStart := self listLineToVisibleLine:selectionStartLine.
|
|
1128 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1).
|
0
|
1129 |
|
59
|
1130 |
"and first partial selected line"
|
|
1131 |
self redrawVisibleLine:selVisStart.
|
0
|
1132 |
|
59
|
1133 |
"rest starts after this one"
|
|
1134 |
line1 := selVisStart + 1
|
0
|
1135 |
] ifFalse:[
|
59
|
1136 |
line1 := 1
|
0
|
1137 |
].
|
|
1138 |
|
|
1139 |
(line1 > end) ifTrue:[^ self].
|
|
1140 |
(line1 < startVisLineNr) ifTrue:[
|
59
|
1141 |
line1 := startVisLineNr
|
0
|
1142 |
].
|
|
1143 |
|
|
1144 |
"draw middle part of selection"
|
|
1145 |
|
|
1146 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[
|
59
|
1147 |
line2 := nLinesShown
|
0
|
1148 |
] ifFalse:[
|
59
|
1149 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1
|
0
|
1150 |
].
|
|
1151 |
(line2 > end) ifTrue:[
|
59
|
1152 |
line2 := end
|
0
|
1153 |
].
|
|
1154 |
|
|
1155 |
self drawFromVisibleLine:line1 to:line2 with:selectionFgColor
|
59
|
1156 |
and:selectionBgColor.
|
0
|
1157 |
|
|
1158 |
(line2 >= end) ifTrue:[^ self].
|
|
1159 |
|
|
1160 |
"last line of selection"
|
|
1161 |
self redrawVisibleLine:(line2 + 1).
|
|
1162 |
|
|
1163 |
((line2 + 2) <= end) ifTrue:[
|
59
|
1164 |
super redrawFromVisibleLine:(line2 + 2) to:end
|
0
|
1165 |
]
|
|
1166 |
!
|
|
1167 |
|
|
1168 |
redrawVisibleLine:visLine
|
|
1169 |
"redraw visible line lineNr"
|
|
1170 |
|
|
1171 |
|len line l|
|
|
1172 |
|
|
1173 |
selectionStartLine notNil ifTrue:[
|
59
|
1174 |
line := self visibleLineToAbsoluteLine:visLine.
|
|
1175 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[
|
|
1176 |
(line == selectionStartLine) ifTrue:[
|
|
1177 |
(line == selectionEndLine) ifTrue:[
|
|
1178 |
"its part-of-single-line selection"
|
|
1179 |
self clearMarginOfVisible:visLine with:bgColor.
|
|
1180 |
(selectionStartCol > 1) ifTrue:[
|
|
1181 |
super redrawVisibleLine:visLine
|
|
1182 |
from:1
|
|
1183 |
to:(selectionStartCol - 1)
|
|
1184 |
].
|
|
1185 |
self drawVisibleLine:visLine from:selectionStartCol
|
|
1186 |
to:selectionEndCol
|
|
1187 |
with:selectionFgColor
|
|
1188 |
and:selectionBgColor.
|
|
1189 |
super redrawVisibleLine:visLine
|
|
1190 |
from:(selectionEndCol + 1).
|
|
1191 |
^ self
|
|
1192 |
].
|
0
|
1193 |
|
59
|
1194 |
"its the first line of a multi-line selection"
|
|
1195 |
(selectionStartCol ~~ 1) ifTrue:[
|
|
1196 |
self clearMarginOfVisible:visLine with:bgColor.
|
|
1197 |
super redrawVisibleLine:visLine
|
|
1198 |
from:1
|
|
1199 |
to:(selectionStartCol - 1)
|
77
|
1200 |
] ifFalse:[
|
|
1201 |
leftOffset == 0 ifTrue:[
|
|
1202 |
self clearMarginOfVisible:visLine with:selectionBgColor.
|
|
1203 |
]
|
59
|
1204 |
].
|
|
1205 |
self drawVisibleLine:visLine from:selectionStartCol
|
|
1206 |
with:selectionFgColor and:selectionBgColor.
|
|
1207 |
^ self
|
|
1208 |
].
|
0
|
1209 |
|
59
|
1210 |
(line == selectionEndLine) ifTrue:[
|
|
1211 |
"its the last line of a multi-line selection"
|
|
1212 |
(selectionEndCol == 0) ifTrue:[
|
|
1213 |
^ super redrawVisibleLine:visLine
|
|
1214 |
].
|
|
1215 |
l := self visibleAt:selectionEndLine.
|
|
1216 |
len := l size.
|
0
|
1217 |
|
59
|
1218 |
self clearMarginOfVisible:visLine with:selectionBgColor.
|
|
1219 |
self drawVisibleLine:visLine from:1 to:selectionEndCol
|
|
1220 |
with:selectionFgColor and:selectionBgColor.
|
|
1221 |
super redrawVisibleLine:visLine from:(selectionEndCol + 1).
|
|
1222 |
^ self
|
|
1223 |
].
|
0
|
1224 |
|
59
|
1225 |
"its a full line in a multi-line selection"
|
|
1226 |
self clearMarginOfVisible:visLine with:selectionBgColor.
|
|
1227 |
self drawVisibleLine:visLine with:selectionFgColor and:selectionBgColor.
|
|
1228 |
^ self
|
|
1229 |
]
|
0
|
1230 |
].
|
7
|
1231 |
super redrawVisibleLine:visLine
|
0
|
1232 |
!
|
|
1233 |
|
|
1234 |
redrawVisibleLine:visLine from:startCol
|
|
1235 |
"redraw visible line lineNr from startCol to end of line"
|
|
1236 |
|
|
1237 |
|line|
|
|
1238 |
|
|
1239 |
line := self visibleLineToAbsoluteLine:visLine.
|
|
1240 |
selectionStartLine notNil ifTrue:[
|
59
|
1241 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[
|
|
1242 |
((line == selectionStartLine)
|
|
1243 |
or:[line == selectionEndLine]) ifTrue:[
|
|
1244 |
"since I'm lazy, redraw full line"
|
|
1245 |
self redrawVisibleLine:visLine.
|
|
1246 |
^ self
|
|
1247 |
].
|
|
1248 |
"the line is fully within the selection"
|
|
1249 |
self drawVisibleLine:visLine from:startCol with:selectionFgColor
|
|
1250 |
and:selectionBgColor.
|
|
1251 |
^ self
|
|
1252 |
]
|
0
|
1253 |
].
|
|
1254 |
super redrawVisibleLine:visLine from:startCol
|
|
1255 |
!
|
|
1256 |
|
|
1257 |
redrawVisibleLine:visLine from:startCol to:endCol
|
|
1258 |
"redraw visible line lineNr from startCol to endCol"
|
|
1259 |
|
|
1260 |
|line allOut allIn leftCol rightCol|
|
|
1261 |
|
|
1262 |
line := self visibleLineToAbsoluteLine:visLine.
|
|
1263 |
|
|
1264 |
allIn := false.
|
|
1265 |
allOut := false.
|
|
1266 |
selectionStartLine isNil ifTrue:[
|
59
|
1267 |
allOut := true
|
0
|
1268 |
] ifFalse:[
|
59
|
1269 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[
|
|
1270 |
allOut := true
|
|
1271 |
] ifTrue:[
|
|
1272 |
(selectionStartLine == selectionEndLine) ifTrue:[
|
|
1273 |
((endCol < selectionStartCol)
|
|
1274 |
or:[startCol > selectionEndCol]) ifTrue:[
|
|
1275 |
allOut := true
|
|
1276 |
] ifFalse:[
|
|
1277 |
((startCol >= selectionStartCol)
|
|
1278 |
and:[endCol <= selectionEndCol]) ifTrue:[
|
|
1279 |
allIn := true
|
|
1280 |
]
|
|
1281 |
]
|
|
1282 |
] ifFalse:[
|
|
1283 |
(line == selectionStartLine) ifTrue:[
|
|
1284 |
(endCol < selectionStartCol) ifTrue:[
|
|
1285 |
allOut := true
|
|
1286 |
] ifFalse:[
|
|
1287 |
(startCol >= selectionStartCol) ifTrue:[
|
|
1288 |
allIn := true
|
|
1289 |
]
|
|
1290 |
]
|
|
1291 |
] ifFalse:[
|
|
1292 |
(line == selectionEndLine) ifTrue:[
|
|
1293 |
(startCol > selectionEndCol) ifTrue:[
|
|
1294 |
allOut := true
|
|
1295 |
] ifFalse:[
|
|
1296 |
(endCol <= selectionEndCol) ifTrue:[
|
|
1297 |
allIn := true
|
|
1298 |
]
|
|
1299 |
]
|
|
1300 |
] ifFalse:[
|
|
1301 |
allIn := true
|
|
1302 |
]
|
|
1303 |
]
|
|
1304 |
]
|
|
1305 |
]
|
0
|
1306 |
].
|
|
1307 |
allOut ifTrue:[
|
59
|
1308 |
super redrawVisibleLine:visLine from:startCol to:endCol.
|
|
1309 |
^ self
|
0
|
1310 |
].
|
|
1311 |
|
|
1312 |
allIn ifTrue:[
|
59
|
1313 |
self drawVisibleLine:visLine from:startCol to:endCol
|
|
1314 |
with:selectionFgColor and:selectionBgColor
|
0
|
1315 |
] ifFalse:[
|
59
|
1316 |
"redraw part before selection"
|
|
1317 |
((line == selectionStartLine)
|
|
1318 |
and:[startCol <= selectionStartCol]) ifTrue:[
|
|
1319 |
super redrawVisibleLine:visLine from:startCol
|
|
1320 |
to:(selectionStartCol - 1).
|
|
1321 |
leftCol := selectionStartCol
|
|
1322 |
] ifFalse:[
|
|
1323 |
leftCol := startCol
|
|
1324 |
].
|
|
1325 |
"redraw selected part"
|
|
1326 |
(selectionEndLine > line) ifTrue:[
|
|
1327 |
rightCol := endCol
|
|
1328 |
] ifFalse:[
|
|
1329 |
rightCol := selectionEndCol min:endCol
|
|
1330 |
].
|
|
1331 |
self drawVisibleLine:visLine from:leftCol to:rightCol
|
|
1332 |
with:selectionFgColor and:selectionBgColor.
|
0
|
1333 |
|
59
|
1334 |
"redraw part after selection"
|
|
1335 |
(rightCol < endCol) ifTrue:[
|
|
1336 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
|
|
1337 |
]
|
0
|
1338 |
].
|
|
1339 |
|
|
1340 |
"special care for first and last line of selection:
|
|
1341 |
must handle margin also"
|
|
1342 |
|
|
1343 |
((line == selectionEndLine)
|
|
1344 |
and:[(startCol == 1)
|
|
1345 |
and:[selectionStartLine < selectionEndLine]])
|
|
1346 |
ifTrue:[
|
59
|
1347 |
self clearMarginOfVisible:visLine with:selectionBgColor.
|
0
|
1348 |
].
|
|
1349 |
|
|
1350 |
((line == selectionStartLine)
|
|
1351 |
and:[(startCol == 1)
|
|
1352 |
and:[selectionStartLine < selectionEndLine]])
|
|
1353 |
ifTrue:[
|
59
|
1354 |
self clearMarginOfVisible:visLine with:bgColor.
|
0
|
1355 |
]
|
|
1356 |
! !
|
|
1357 |
|
|
1358 |
!TextView methodsFor:'event processing'!
|
|
1359 |
|
45
|
1360 |
mapped
|
|
1361 |
super mapped.
|
|
1362 |
selectionFgColor := selectionFgColor on:device.
|
|
1363 |
selectionBgColor := selectionBgColor on:device.
|
|
1364 |
!
|
|
1365 |
|
0
|
1366 |
keyPress:key x:x y:y
|
|
1367 |
"handle some keyboard input (there is not much to be done here)"
|
|
1368 |
|
|
1369 |
(key == #Find) ifTrue:[self search. ^self].
|
|
1370 |
(key == #Copy) ifTrue:[self copySelection. ^self].
|
|
1371 |
|
|
1372 |
(key == #FindNext) ifTrue:[self searchFwd. ^self].
|
|
1373 |
(key == #FindPrev) ifTrue:[self searchBwd. ^self].
|
|
1374 |
|
|
1375 |
(key == #SelectAll) ifTrue:[self selectAll. ^self].
|
|
1376 |
|
38
|
1377 |
"
|
|
1378 |
shift-Fn defines a key-sequence
|
|
1379 |
Fn pastes that sequence
|
|
1380 |
cmd-Fn performs a 'doIt' on the sequence (Workspaces only)
|
|
1381 |
|
|
1382 |
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
|
|
1383 |
"
|
7
|
1384 |
(#(F1 F2 F3 F4 F5 F6 F7 F8 F9) includes:key) ifTrue:[
|
59
|
1385 |
device shiftDown ifTrue:[
|
|
1386 |
(Smalltalk at:#FunctionKeySequences) isNil ifTrue:[
|
|
1387 |
Smalltalk at:#FunctionKeySequences put:Dictionary new
|
|
1388 |
].
|
|
1389 |
(Smalltalk at:#FunctionKeySequences) at:key put:(self selection)
|
|
1390 |
].
|
|
1391 |
^ self
|
7
|
1392 |
].
|
|
1393 |
|
0
|
1394 |
super keyPress:key x:x y:y
|
|
1395 |
!
|
|
1396 |
|
|
1397 |
buttonPress:button x:x y:y
|
|
1398 |
"mouse-click - prepare for selection change"
|
|
1399 |
|
|
1400 |
|clickVisibleLine|
|
|
1401 |
|
38
|
1402 |
((button == 1) or:[button == #select]) ifTrue:[
|
59
|
1403 |
clickVisibleLine := self visibleLineOfY:y.
|
|
1404 |
clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
|
|
1405 |
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
|
|
1406 |
clickStartLine := clickLine.
|
|
1407 |
clickStartCol := clickCol.
|
|
1408 |
self unselect.
|
|
1409 |
clickCount := 1
|
0
|
1410 |
] ifFalse:[
|
59
|
1411 |
super buttonPress:button x:x y:y
|
0
|
1412 |
]
|
|
1413 |
!
|
|
1414 |
|
|
1415 |
buttonShiftPress:button x:x y:y
|
|
1416 |
"mouse-click with shift - adding to selection"
|
|
1417 |
|
|
1418 |
"very simple - just simulate a move"
|
53
|
1419 |
^ self buttonMotion:(device button1MotionMask) x:x y:y
|
0
|
1420 |
!
|
|
1421 |
|
|
1422 |
buttonMultiPress:button x:x y:y
|
|
1423 |
"multi-mouse-click - select word under pointer"
|
|
1424 |
|
38
|
1425 |
((button == 1) or:[button == #select]) ifTrue:[
|
59
|
1426 |
clickCount notNil ifTrue:[
|
|
1427 |
clickCount := clickCount + 1.
|
|
1428 |
(clickCount == 2) ifTrue:[
|
|
1429 |
self selectWordAtX:x y:y.
|
|
1430 |
"
|
|
1431 |
remember words position in case of a drag following
|
|
1432 |
"
|
|
1433 |
wordStartLine := selectionStartLine.
|
|
1434 |
wordEndLine := selectionEndLine.
|
|
1435 |
selectStyle == #wordLeft ifTrue:[
|
|
1436 |
wordStartCol := selectionStartCol + 1
|
|
1437 |
] ifFalse:[
|
|
1438 |
wordStartCol := selectionStartCol.
|
|
1439 |
].
|
|
1440 |
selectStyle == #wordRight ifTrue:[
|
|
1441 |
wordEndCol := selectionEndCol - 1
|
|
1442 |
] ifFalse:[
|
|
1443 |
wordEndCol := selectionEndCol
|
|
1444 |
]
|
|
1445 |
] ifFalse:[
|
|
1446 |
(clickCount == 3) ifTrue:[
|
|
1447 |
self selectLineAtY:y.
|
|
1448 |
selectStyle := #line
|
|
1449 |
] ifFalse:[
|
|
1450 |
(clickCount == 4) ifTrue:[
|
|
1451 |
self selectAll
|
|
1452 |
]
|
|
1453 |
]
|
|
1454 |
]
|
|
1455 |
]
|
0
|
1456 |
] ifFalse:[
|
59
|
1457 |
super buttonMultiPress:button x:x y:y
|
0
|
1458 |
]
|
|
1459 |
!
|
|
1460 |
|
53
|
1461 |
buttonMotion:buttonMask x:x y:y
|
0
|
1462 |
"mouse-move while button was pressed - handle selection changes"
|
|
1463 |
|
|
1464 |
|movedVisibleLine movedLine movedCol
|
|
1465 |
movedUp
|
|
1466 |
oldStartLine oldEndLine oldStartCol oldEndCol|
|
|
1467 |
|
|
1468 |
clickLine isNil ifTrue:[^ self].
|
|
1469 |
|
63
|
1470 |
"is it the select or 1-button ?"
|
|
1471 |
(device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
|
|
1472 |
(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
|
|
1473 |
^ self
|
|
1474 |
].
|
53
|
1475 |
].
|
|
1476 |
|
0
|
1477 |
"if moved outside of view, start autoscroll"
|
|
1478 |
(y < 0) ifTrue:[
|
59
|
1479 |
self compressMotionEvents:false.
|
|
1480 |
self startAutoScrollUp:y.
|
|
1481 |
^ self
|
0
|
1482 |
].
|
|
1483 |
(y > height) ifTrue:[
|
59
|
1484 |
self compressMotionEvents:false.
|
|
1485 |
self startAutoScrollDown:(y - height).
|
|
1486 |
^ self
|
|
1487 |
].
|
|
1488 |
((x < 0) and:[leftOffset ~~ 0]) ifTrue:[
|
|
1489 |
self compressMotionEvents:false.
|
|
1490 |
self startAutoScrollLeft:x.
|
|
1491 |
^ self
|
|
1492 |
].
|
|
1493 |
(x > width) ifTrue:[
|
|
1494 |
self compressMotionEvents:false.
|
|
1495 |
self startAutoScrollRight:(x - width).
|
|
1496 |
^ self
|
0
|
1497 |
].
|
|
1498 |
|
|
1499 |
"move inside - stop autoscroll if any"
|
|
1500 |
autoScrollBlock notNil ifTrue:[
|
59
|
1501 |
self stopScrollSelect
|
0
|
1502 |
].
|
|
1503 |
|
|
1504 |
movedVisibleLine := self visibleLineOfY:y.
|
|
1505 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
|
|
1506 |
(x < leftMargin) ifTrue:[
|
59
|
1507 |
movedCol := 0
|
0
|
1508 |
] ifFalse:[
|
59
|
1509 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine
|
0
|
1510 |
].
|
|
1511 |
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[^ self].
|
|
1512 |
|
|
1513 |
selectionStartLine isNil ifTrue:[
|
59
|
1514 |
selectionStartLine := clickLine.
|
|
1515 |
selectionStartCol := clickCol.
|
|
1516 |
selectionEndLine := selectionStartLine.
|
|
1517 |
selectionEndCol := selectionStartCol
|
0
|
1518 |
].
|
|
1519 |
oldStartLine := selectionStartLine.
|
|
1520 |
oldEndLine := selectionEndLine.
|
|
1521 |
oldStartCol := selectionStartCol.
|
|
1522 |
oldEndCol := selectionEndCol.
|
|
1523 |
|
|
1524 |
|
|
1525 |
"find out if we are before or after initial click"
|
|
1526 |
movedUp := false.
|
|
1527 |
(movedLine < clickStartLine) ifTrue:[
|
59
|
1528 |
movedUp := true
|
0
|
1529 |
] ifFalse:[
|
59
|
1530 |
(movedLine == clickStartLine) ifTrue:[
|
|
1531 |
(movedCol < clickStartCol) ifTrue:[
|
|
1532 |
movedUp := true
|
|
1533 |
]
|
|
1534 |
]
|
0
|
1535 |
].
|
|
1536 |
|
|
1537 |
movedUp ifTrue:[
|
59
|
1538 |
"change selectionStart"
|
|
1539 |
selectionStartCol := movedCol.
|
|
1540 |
selectionStartLine := movedLine.
|
|
1541 |
selectionEndCol := clickStartCol.
|
|
1542 |
selectionEndLine := clickStartLine.
|
|
1543 |
selectStyle notNil ifTrue:[
|
|
1544 |
selectionEndCol := wordEndCol.
|
|
1545 |
selectionEndLine := wordEndLine.
|
|
1546 |
]
|
0
|
1547 |
] ifFalse:[
|
59
|
1548 |
"change selectionEnd"
|
|
1549 |
selectionEndCol := movedCol.
|
|
1550 |
selectionEndLine := movedLine.
|
|
1551 |
selectionStartCol := clickStartCol.
|
|
1552 |
selectionStartLine := clickStartLine.
|
|
1553 |
selectStyle notNil ifTrue:[
|
|
1554 |
selectionStartCol := wordStartCol.
|
|
1555 |
selectionStartLine := wordStartLine.
|
|
1556 |
]
|
0
|
1557 |
].
|
|
1558 |
|
|
1559 |
(selectionStartCol == 0) ifTrue:[
|
59
|
1560 |
selectionStartCol := 1
|
0
|
1561 |
].
|
|
1562 |
|
38
|
1563 |
"
|
|
1564 |
if in word-select, just catch the rest of the word
|
|
1565 |
"
|
|
1566 |
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
|
59
|
1567 |
movedUp ifTrue:[
|
|
1568 |
selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
|
|
1569 |
] ifFalse:[
|
|
1570 |
selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
|
|
1571 |
selectionEndCol == 0 ifTrue:[
|
|
1572 |
selectionEndLine := selectionEndLine + 1
|
|
1573 |
]
|
|
1574 |
].
|
38
|
1575 |
].
|
|
1576 |
|
|
1577 |
selectStyle == #line ifTrue:[
|
59
|
1578 |
movedUp ifTrue:[
|
|
1579 |
selectionStartCol := 1.
|
|
1580 |
] ifFalse:[
|
|
1581 |
selectionEndCol := 0.
|
|
1582 |
selectionEndLine := selectionEndLine + 1
|
|
1583 |
]
|
38
|
1584 |
].
|
|
1585 |
|
0
|
1586 |
(oldStartLine == selectionStartLine) ifTrue:[
|
59
|
1587 |
(oldStartCol ~~ selectionStartCol) ifTrue:[
|
|
1588 |
self redrawLine:oldStartLine
|
|
1589 |
from:((selectionStartCol min:oldStartCol) max:1)
|
|
1590 |
to:((selectionStartCol max:oldStartCol) max:1)
|
|
1591 |
]
|
0
|
1592 |
] ifFalse:[
|
59
|
1593 |
self redrawFromLine:(oldStartLine min:selectionStartLine)
|
|
1594 |
to:(oldStartLine max:selectionStartLine)
|
0
|
1595 |
].
|
|
1596 |
|
|
1597 |
(oldEndLine == selectionEndLine) ifTrue:[
|
59
|
1598 |
(oldEndCol ~~ selectionEndCol) ifTrue:[
|
|
1599 |
self redrawLine:oldEndLine
|
|
1600 |
from:((selectionEndCol min:oldEndCol) max:1)
|
|
1601 |
to:((selectionEndCol max:oldEndCol) max:1)
|
|
1602 |
]
|
0
|
1603 |
] ifFalse:[
|
59
|
1604 |
self redrawFromLine:(oldEndLine min:selectionEndLine)
|
|
1605 |
to:(oldEndLine max:selectionEndLine)
|
0
|
1606 |
].
|
|
1607 |
clickLine := movedLine.
|
|
1608 |
clickCol := movedCol
|
|
1609 |
!
|
|
1610 |
|
|
1611 |
buttonRelease:button x:x y:y
|
|
1612 |
"mouse- button release - turn off autoScroll if any"
|
|
1613 |
|
38
|
1614 |
((button == 1) or:[button == #select]) ifTrue:[
|
59
|
1615 |
autoScrollBlock notNil ifTrue:[
|
|
1616 |
self stopScrollSelect
|
|
1617 |
].
|
0
|
1618 |
] ifFalse:[
|
59
|
1619 |
super buttonRelease:button x:x y:y
|
0
|
1620 |
]
|
|
1621 |
! !
|