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