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