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