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