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