author | Claus Gittinger <cg@exept.de> |
Wed, 05 Aug 2015 15:33:37 +0200 | |
changeset 5391 | 98080a3105ae |
parent 5378 | d64277a079c1 |
child 5395 | fc9336b15c5c |
child 5412 | d248d42bac05 |
permissions | -rw-r--r-- |
5391 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4500 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2191 | 14 |
"{ Package: 'stx:libwidg' }" |
15 |
||
5247 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
ListView subclass:#TextView |
3394 | 19 |
instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine |
20 |
selectionEndCol clickPos clickStartLine clickStartCol clickLine |
|
21 |
clickCol clickCount expandingTop wordStartCol wordStartLine |
|
22 |
wordEndCol wordEndLine selectionFgColor selectionBgColor |
|
23 |
selectStyle directoryForFileDialog defaultFileNameForFileDialog |
|
24 |
externalEncoding contentsWasSaved searchAction lastSearchPattern |
|
3964 | 25 |
lastSearchWasMatch lastSearchIgnoredCase lastSearchDirection |
4399 | 26 |
lastSearchWasVariableSearch parenthesisSpecification dropSource |
27 |
dragIsActive saveAction st80SelectMode searchBarActionBlock' |
|
3394 | 28 |
classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor |
29 |
DefaultSelectionBackgroundColor |
|
30 |
DefaultAlternativeSelectionForegroundColor |
|
31 |
DefaultAlternativeSelectionBackgroundColor MatchDelayTime |
|
32 |
WordSelectCatchesBlanks LastSearchPatterns |
|
33 |
NumRememberedSearchPatterns LastSearchIgnoredCase |
|
3577 | 34 |
LastSearchWasMatch DefaultParenthesisSpecification' |
3394 | 35 |
poolDictionaries:'' |
36 |
category:'Views-Text' |
|
0 | 37 |
! |
38 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
39 |
!TextView class methodsFor:'documentation'! |
0 | 40 |
|
38 | 41 |
copyright |
42 |
" |
|
43 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4500 | 44 |
All Rights Reserved |
38 | 45 |
|
46 |
This software is furnished under a license and may be used |
|
47 |
only in accordance with the terms of that license and with the |
|
48 |
inclusion of the above copyright notice. This software may not |
|
49 |
be provided or otherwise made available to, or used by, any |
|
50 |
other person. No title to or ownership of the software is |
|
51 |
hereby transferred. |
|
52 |
" |
|
53 |
! |
|
54 |
||
22 | 55 |
documentation |
0 | 56 |
" |
120 | 57 |
a view for readOnly text - this class adds selections to a simple list. |
38 | 58 |
The text is not editable and there is no cursor. |
120 | 59 |
Use TextViews for readonly text, EditTextView for editable text. |
0 | 60 |
|
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
|
61 |
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
|
62 |
|
586 | 63 |
[Instance variables:] |
0 | 64 |
|
120 | 65 |
selectionStartLine <Number> the line of the selection start (or nil) |
66 |
selectionStartCol <Number> the col of the selection start |
|
67 |
selectionEndLine <Number> the line of the selection end |
|
68 |
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
|
69 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
70 |
clickStartLine <Number> temporary - remember where select operation started |
120 | 71 |
clickStartCol <Number> temporary |
72 |
clickLine <Number> temporary |
|
73 |
clickCol <Number> temporary |
|
74 |
clickCount <Number> temporary |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
75 |
expandingTop <Boolean> temporary - for expandSelection |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
76 |
|
120 | 77 |
selectionFgColor <Color> color used to draw selections |
78 |
selectionBgColor <Color> color used to draw selections |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
79 |
|
120 | 80 |
selectStyle <Symbol> how words are selected |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
81 |
|
120 | 82 |
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
|
83 |
|
120 | 84 |
contentsWasSaved <Boolean> set to true, whenever saved in a file |
77 | 85 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
86 |
externalEncoding <Symbol|nil> external encoding, used when text is saved to |
4500 | 87 |
a file. Usually something like |
88 |
#jis7, #euc, #sjis etc. |
|
89 |
(currently only passed down from the |
|
90 |
fileBrowser) |
|
2588 | 91 |
|
92 |
dropSource <DropSource> drag operation descriptor or nil (dragging disabled) |
|
4500 | 93 |
dragIsActive <Boolean> true, drag operation is activated |
94 |
||
95 |
searchAction <Block> an autosearch action; typically set by the browser. |
|
96 |
Will be used as default when searchFwd/searchBwd is |
|
97 |
pressed. If the searchPattern is changed, no autosearch |
|
98 |
action will be executed. |
|
3981 | 99 |
|
100 |
searchBarActionBlock <Block> search action block for embedded search |
|
4500 | 101 |
panel. Used as second chance for searchFwd/bwd |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
102 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
103 |
[class variables:] |
4500 | 104 |
ST80Selections <Boolean> enables ST80 style doubleclick behavior |
105 |
(right after opening parenthesis, right before |
|
106 |
closing parenthesis, at begin of a line |
|
107 |
at begin of text) |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
108 |
|
586 | 109 |
[StyleSheet parameters:] |
77 | 110 |
|
2600 | 111 |
textView.background defaults to viewBackground |
112 |
textView.ViewFont defaults to textFont |
|
113 |
||
114 |
text.st80Selections st80 behavior (click on char after parent or quote) |
|
115 |
||
116 |
text.selectionForegroundColor defaults to textBackgroundColor |
|
117 |
text.selectionBackgroundColor defaults to textForegroundColor |
|
118 |
||
119 |
text.alternativeSelectionForegroundColor pasted text (i.e. paste will not replace) |
|
4500 | 120 |
defaults to selectionForegroundColor |
2600 | 121 |
text.alternativeSelectionBackgroundColor pasted text (i.e. paste will not replace) |
4500 | 122 |
defaults to selectionBackgroundColor |
586 | 123 |
[author:] |
4500 | 124 |
Claus Gittinger |
586 | 125 |
|
126 |
[see also:] |
|
4500 | 127 |
EditTextView CodeView Workspace |
0 | 128 |
" |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
129 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
130 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
131 |
examples |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
132 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
133 |
although textViews (and instances of subclasses) are mostly used |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
134 |
as components (in the fileBrowser, the browser, the launcher etc.), |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
135 |
they may also be opened as a textEditor; |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
136 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
137 |
open a (readonly) textView on some information text: |
4500 | 138 |
[exBegin] |
139 |
TextView |
|
140 |
openWith:'read this' |
|
141 |
title:'demonstration' |
|
142 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
143 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
144 |
the same, but open it modal: |
4500 | 145 |
[exBegin] |
146 |
TextView |
|
147 |
openModalWith:'read this first' |
|
148 |
title:'demonstration' |
|
149 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
150 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
151 |
|
1016 | 152 |
open it modal (but editable) on some text: |
153 |
(must accept before closing) |
|
154 |
This is somewhat kludgy - when closed, the view has already |
|
155 |
nilled its link to the model. Therefore, the accept must be |
|
156 |
done 'manually' below. |
|
157 |
However, usually an applicationModel is installed as the |
|
158 |
editor-topViews application. This would get a closeRequest, |
|
159 |
where it could handle things. |
|
4500 | 160 |
[exBegin] |
161 |
|m textView| |
|
162 |
||
163 |
m := 'read this first' asValue. |
|
164 |
textView := EditTextView openModalOnModel:m. |
|
165 |
textView modified ifTrue:[ |
|
166 |
(self confirm:'text was not accepted - do it now ?') |
|
167 |
ifTrue:[ |
|
168 |
m value:textView contents |
|
169 |
] |
|
170 |
]. |
|
171 |
||
172 |
Transcript showCR:m value. |
|
173 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
174 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
175 |
|
1016 | 176 |
open a textEditor on some file: |
4500 | 177 |
[exBegin] |
178 |
EditTextView openOn:'Makefile' |
|
179 |
[exEnd] |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
180 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
181 |
" |
1016 | 182 |
|
0 | 183 |
! ! |
184 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
185 |
!TextView class methodsFor:'instance creation'! |
119 | 186 |
|
187 |
on:aModel aspect:aspect change:change menu:menu initialSelection:initial |
|
188 |
"for ST-80 compatibility" |
|
189 |
||
4500 | 190 |
^ (self new) |
191 |
on:aModel |
|
192 |
aspect:aspect |
|
193 |
list:aspect |
|
194 |
change:change |
|
195 |
menu:menu |
|
196 |
initialSelection:initial |
|
3280 | 197 |
! |
198 |
||
199 |
with:someText |
|
4500 | 200 |
^ (self new) |
201 |
contents:someText |
|
119 | 202 |
! ! |
203 |
||
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
204 |
!TextView class methodsFor:'class initialization'! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
205 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
206 |
initialize |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
207 |
DefaultParenthesisSpecification isNil ifTrue:[ |
4500 | 208 |
DefaultParenthesisSpecification := IdentityDictionary new. |
209 |
DefaultParenthesisSpecification at:#open put:#( $( $[ ${ "$> $<") . |
|
210 |
DefaultParenthesisSpecification at:#close put:#( $) $] $} "$> $<"). |
|
211 |
DefaultParenthesisSpecification at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
|
212 |
DefaultParenthesisSpecification at:#eolComment put:'"/'. "/ sigh - must be 2 characters |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
213 |
]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
214 |
! ! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
215 |
|
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
216 |
!TextView class methodsFor:'defaults'! |
38 | 217 |
|
896 | 218 |
defaultIcon |
1195 | 219 |
"return the default icon if started as a topView" |
220 |
||
3496 | 221 |
<resource: #programImage> |
1195 | 222 |
<resource: #style (#ICON #ICON_FILE)> |
223 |
||
224 |
|nm i| |
|
1143 | 225 |
|
1146 | 226 |
i := self classResources at:'ICON' default:nil. |
1143 | 227 |
i isNil ifTrue:[ |
4500 | 228 |
nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'. |
229 |
i := Smalltalk imageFromFileNamed:nm forClass:self. |
|
1195 | 230 |
]. |
231 |
i notNil ifTrue:[ |
|
4500 | 232 |
i := i onDevice:Display |
1143 | 233 |
]. |
234 |
^ i |
|
235 |
||
3496 | 236 |
"Modified: / 17-09-2007 / 11:36:29 / cg" |
896 | 237 |
! |
238 |
||
910
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
239 |
defaultMenuMessage |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
240 |
"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
|
241 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
242 |
^ #editMenu |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
243 |
|
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
244 |
"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
|
245 |
! |
0446030ce647
Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents:
906
diff
changeset
|
246 |
|
4254
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
247 |
defaultParenthesisSpecification |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
248 |
^ DefaultParenthesisSpecification |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
249 |
|
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
250 |
"Created: / 14-06-2011 / 14:00:59 / cg" |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
251 |
! |
eaf0560ba269
added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents:
4234
diff
changeset
|
252 |
|
2306 | 253 |
defaultSelectionBackgroundColor |
254 |
"return the default selection background color" |
|
255 |
||
256 |
^DefaultSelectionBackgroundColor |
|
257 |
! |
|
258 |
||
259 |
defaultSelectionForegroundColor |
|
260 |
"return the default selection foreground color" |
|
261 |
||
262 |
^DefaultSelectionForegroundColor |
|
263 |
! |
|
264 |
||
1477
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
265 |
defaultViewBackgroundColor |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
266 |
"return the default view background" |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
267 |
|
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
268 |
^DefaultViewBackground |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
269 |
! |
2d4b6115e2c5
redefine #defaultViewBackgroundColor for the spec class
tz
parents:
1476
diff
changeset
|
270 |
|
3226 | 271 |
lastSearchIgnoredCase |
272 |
^ LastSearchIgnoredCase |
|
273 |
! |
|
274 |
||
3577 | 275 |
lastSearchWasMatch |
276 |
^ LastSearchWasMatch |
|
277 |
! |
|
278 |
||
1729 | 279 |
st80SelectMode |
3308 | 280 |
^ UserPreferences current st80SelectMode |
281 |
||
282 |
"Modified: / 03-07-2006 / 16:26:44 / cg" |
|
1729 | 283 |
! |
284 |
||
285 |
st80SelectMode:aBoolean |
|
3308 | 286 |
UserPreferences current st80SelectMode:aBoolean |
287 |
||
288 |
"Created: / 07-01-1999 / 13:35:24 / cg" |
|
289 |
"Modified: / 03-07-2006 / 16:27:01 / cg" |
|
1729 | 290 |
! |
291 |
||
59 | 292 |
updateStyleCache |
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
293 |
"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
|
294 |
|
1353 | 295 |
<resource: #style (#'textView.background' |
4500 | 296 |
#'text.selectionForegroundColor' |
297 |
#'text.selectionBackgroundColor' |
|
298 |
#'text.alternativeSelectionForegroundColor' |
|
299 |
#'text.alternativeSelectionBackgroundColor' |
|
300 |
#'textView.font' |
|
301 |
#'text.wordSelectCatchesBlanks' |
|
302 |
#'text.st80Selections')> |
|
441
e170bca66a78
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
303 |
|
1353 | 304 |
DefaultViewBackground := StyleSheet colorAt:'textView.background' default:White. |
1380 | 305 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'text.selectionForegroundColor'. |
306 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'text.selectionBackgroundColor'. |
|
2630
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
307 |
"/ DefaultAlternativeSelectionForegroundColor := StyleSheet colorAt:'text.alternativeSelectionForegroundColor' default:DefaultSelectionForegroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
308 |
"/ DefaultAlternativeSelectionBackgroundColor := StyleSheet colorAt:'text.alternativeSelectionBackgroundColor' default:DefaultSelectionBackgroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
309 |
DefaultAlternativeSelectionForegroundColor := DefaultSelectionForegroundColor. |
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
310 |
DefaultAlternativeSelectionBackgroundColor := DefaultSelectionBackgroundColor. |
1353 | 311 |
DefaultFont := StyleSheet fontAt:'textView.font'. |
504 | 312 |
MatchDelayTime := 0.6. |
1380 | 313 |
WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false. |
3308 | 314 |
|
315 |
"Modified: / 03-07-2006 / 16:29:42 / cg" |
|
0 | 316 |
! ! |
317 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
318 |
!TextView class methodsFor:'help specs'! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
319 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
320 |
flyByHelpSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
321 |
"This resource specification was automatically generated |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
322 |
by the UIHelpTool of ST/X." |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
323 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
324 |
"Do not manually edit this!! If it is corrupted, |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
325 |
the UIHelpTool may not be able to read the specification." |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
326 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
327 |
" |
4500 | 328 |
UIHelpTool openOnClass:TextView |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
329 |
" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
330 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
331 |
<resource: #help> |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
332 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
333 |
^ Dictionary new addPairsFrom:#( |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
334 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
335 |
#matchSearch |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
336 |
'Search for a pattern (glob) as opposed to a direct string search' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
337 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
338 |
#searchCaseSensitive |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
339 |
'Care for case differences' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
340 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
341 |
#searchFullWord |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
342 |
'Search only for full words (ignore occurrences as substring)' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
343 |
|
5078 | 344 |
#searchAtBeginOfLineOnly |
345 |
'Search only for the string at the beginning if a line' |
|
346 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
347 |
#searchPattern |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
348 |
'String or match-pattern to be searched' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
349 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
350 |
#searchVariable |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
351 |
'Search only for that variable name (ignore occurrences in other contexts)' |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
352 |
|
4485 | 353 |
#replaceText |
354 |
'If checked, matching text is replaced by this (everywhere)' |
|
355 |
||
356 |
#selectLines |
|
357 |
'If checked, lines containing the matched string are selected.' |
|
358 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
359 |
) |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
360 |
! ! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
361 |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
362 |
!TextView class methodsFor:'interface specs'! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
363 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
364 |
searchDialogSpec |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
365 |
"This resource specification was automatically generated |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
366 |
by the UIPainter of ST/X." |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
367 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
368 |
"Do not manually edit this!! If it is corrupted, |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
369 |
the UIPainter may not be able to read the specification." |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
370 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
371 |
" |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
372 |
UIPainter new openOnClass:TextView andSelector:#searchDialogSpec |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
373 |
" |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
374 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
375 |
<resource: #canvas> |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
376 |
|
4605 | 377 |
^ |
4767 | 378 |
#(FullSpec |
379 |
name: searchDialogSpec |
|
380 |
window: |
|
381 |
(WindowSpec |
|
382 |
label: 'String search' |
|
383 |
name: 'String search' |
|
384 |
min: (Point 10 10) |
|
385 |
max: (Point 1280 1024) |
|
5077 | 386 |
bounds: (Rectangle 0 0 319 266) |
4767 | 387 |
) |
388 |
component: |
|
389 |
(SpecCollection |
|
390 |
collection: ( |
|
391 |
(LabelSpec |
|
392 |
label: 'SearchPattern:' |
|
393 |
name: 'label' |
|
394 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
395 |
level: 0 |
|
396 |
translateLabel: true |
|
397 |
adjust: left |
|
398 |
) |
|
399 |
(ComboBoxSpec |
|
400 |
name: 'patternComboBox' |
|
401 |
layout: (LayoutFrame 2 0.0 26 0 -2 1.0 48 0) |
|
402 |
activeHelpKey: searchPattern |
|
403 |
tabable: true |
|
404 |
model: searchPattern |
|
405 |
immediateAccept: false |
|
406 |
acceptOnLeave: true |
|
407 |
acceptOnReturn: true |
|
408 |
acceptOnTab: true |
|
409 |
acceptOnLostFocus: true |
|
410 |
acceptOnPointerLeave: false |
|
411 |
autoSelectInitialText: true |
|
412 |
comboList: patternList |
|
413 |
) |
|
414 |
(VerticalPanelViewSpec |
|
415 |
name: 'VerticalPanel1' |
|
416 |
layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1) |
|
417 |
horizontalLayout: fit |
|
418 |
verticalLayout: top |
|
419 |
component: |
|
420 |
(SpecCollection |
|
421 |
collection: ( |
|
422 |
(CheckBoxSpec |
|
423 |
label: 'Case Sensitive' |
|
424 |
name: 'ignoreCaseCheckBox' |
|
425 |
activeHelpKey: searchCaseSensitive |
|
426 |
level: 0 |
|
427 |
tabable: true |
|
428 |
model: caseSensitive |
|
429 |
translateLabel: true |
|
5077 | 430 |
extent: (Point 319 24) |
4767 | 431 |
) |
432 |
(CheckBoxSpec |
|
433 |
label: 'Match (forward only)' |
|
434 |
name: 'matchCheckBox' |
|
435 |
activeHelpKey: matchSearch |
|
436 |
level: 0 |
|
437 |
tabable: true |
|
438 |
model: match |
|
439 |
translateLabel: true |
|
5077 | 440 |
extent: (Point 319 24) |
4767 | 441 |
) |
442 |
(CheckBoxSpec |
|
443 |
label: 'Search Full Words' |
|
444 |
name: 'CheckBox2' |
|
445 |
activeHelpKey: searchFullWord |
|
446 |
level: 0 |
|
447 |
enableChannel: searchFullWordEnabled |
|
448 |
tabable: true |
|
449 |
model: searchFullWord |
|
450 |
translateLabel: true |
|
5077 | 451 |
extent: (Point 319 24) |
452 |
) |
|
453 |
(CheckBoxSpec |
|
454 |
label: 'At Begin of Line Only' |
|
455 |
name: 'CheckBox5' |
|
5078 | 456 |
activeHelpKey: searchAtBeginOfLineOnly |
5077 | 457 |
level: 0 |
458 |
tabable: true |
|
459 |
model: searchAtBeginOfLineOnly |
|
460 |
translateLabel: true |
|
461 |
extent: (Point 319 24) |
|
4767 | 462 |
) |
463 |
(CheckBoxSpec |
|
464 |
label: 'Variable Only' |
|
465 |
name: 'CheckBox1' |
|
466 |
activeHelpKey: searchVariable |
|
467 |
level: 0 |
|
468 |
visibilityChannel: searchVariableVisible |
|
469 |
enableChannel: searchVariableEnabled |
|
470 |
tabable: true |
|
471 |
model: searchVariable |
|
472 |
translateLabel: true |
|
473 |
labelChannel: stringWithVariableUnderCursorHolder |
|
5077 | 474 |
extent: (Point 319 24) |
4767 | 475 |
) |
476 |
(CheckBoxSpec |
|
477 |
label: 'Select Lines' |
|
478 |
name: 'CheckBox3' |
|
479 |
activeHelpKey: selectLines |
|
480 |
level: 0 |
|
481 |
initiallyInvisible: true |
|
482 |
tabable: true |
|
483 |
model: selectLines |
|
484 |
translateLabel: true |
|
485 |
extent: (Point 302 24) |
|
486 |
) |
|
487 |
(ViewSpec |
|
488 |
name: 'Box1' |
|
489 |
component: |
|
490 |
(SpecCollection |
|
491 |
collection: ( |
|
492 |
(CheckBoxSpec |
|
493 |
label: 'Global Replace With:' |
|
494 |
name: 'CheckBox4' |
|
495 |
layout: (LayoutFrame 0 0 0 0 162 0 23 0) |
|
496 |
activeHelpKey: replaceText |
|
497 |
level: 0 |
|
498 |
enableChannel: replaceEnabled |
|
499 |
tabable: true |
|
500 |
model: replaceBoolean |
|
501 |
translateLabel: true |
|
4605 | 502 |
) |
4767 | 503 |
(InputFieldSpec |
5010 | 504 |
name: 'ReplaceEntryField' |
4767 | 505 |
layout: (LayoutFrame 164 0 0 0 -2 1 22 0) |
506 |
activeHelpKey: replaceText |
|
507 |
visibilityChannel: replaceBoolean |
|
508 |
enableChannel: replaceBoolean |
|
509 |
model: replaceTextHolder |
|
510 |
acceptOnReturn: true |
|
511 |
acceptOnTab: true |
|
512 |
acceptOnPointerLeave: true |
|
513 |
) |
|
514 |
) |
|
515 |
||
516 |
) |
|
5077 | 517 |
extent: (Point 319 24) |
4605 | 518 |
) |
4767 | 519 |
) |
520 |
||
521 |
) |
|
522 |
) |
|
523 |
(HorizontalPanelViewSpec |
|
524 |
name: 'horizontalPanelView' |
|
5276 | 525 |
layout: (LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0) |
4767 | 526 |
level: 0 |
527 |
horizontalLayout: fitSpace |
|
528 |
verticalLayout: center |
|
529 |
horizontalSpace: 3 |
|
530 |
verticalSpace: 3 |
|
531 |
ignoreInvisibleComponents: true |
|
532 |
reverseOrderIfOKAtLeft: true |
|
533 |
component: |
|
534 |
(SpecCollection |
|
535 |
collection: ( |
|
536 |
(ActionButtonSpec |
|
537 |
label: 'Cancel' |
|
538 |
name: 'cancelButton' |
|
539 |
level: 2 |
|
540 |
translateLabel: true |
|
541 |
tabable: true |
|
542 |
model: cancel |
|
5276 | 543 |
extent: (Point 101 21) |
4605 | 544 |
) |
4767 | 545 |
(ActionButtonSpec |
546 |
label: 'Prev' |
|
547 |
name: 'prevButton' |
|
548 |
level: 2 |
|
549 |
translateLabel: true |
|
550 |
tabable: true |
|
551 |
model: prevAction |
|
5276 | 552 |
extent: (Point 101 21) |
4767 | 553 |
) |
554 |
(ActionButtonSpec |
|
555 |
label: 'Next' |
|
556 |
name: 'nextButton' |
|
557 |
level: 2 |
|
558 |
borderWidth: 1 |
|
559 |
translateLabel: true |
|
560 |
tabable: true |
|
561 |
model: nextAction |
|
562 |
isDefault: true |
|
5276 | 563 |
extent: (Point 101 21) |
4767 | 564 |
) |
565 |
) |
|
566 |
||
567 |
) |
|
568 |
keepSpaceForOSXResizeHandleH: true |
|
4605 | 569 |
) |
4767 | 570 |
) |
571 |
||
572 |
) |
|
573 |
) |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
574 |
! ! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
575 |
|
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
576 |
!TextView class methodsFor:'startup'! |
121 | 577 |
|
248 | 578 |
open |
579 |
"start an empty TextView" |
|
580 |
||
581 |
^ self openWith:nil |
|
0 | 582 |
! |
583 |
||
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
584 |
openModalOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
585 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
586 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
587 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
588 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
589 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
590 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
591 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
592 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
593 |
"Created: 14.2.1997 / 15:24:12 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
594 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
595 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
596 |
openModalWith:aString |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
597 |
"start a textView with aString as initial contents" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
598 |
|
4500 | 599 |
^ self openModalWith:aString title:nil |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
600 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
601 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
602 |
TextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
603 |
EditTextView openModalWith:'some text' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
604 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
605 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
606 |
"Created: 14.2.1997 / 15:19:04 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
607 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
608 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
609 |
openModalWith:aString title:aTitle |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
610 |
"start a textView with aString as initial contents. Return the textView." |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
611 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
612 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
613 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
614 |
textView := self setupWith:aString title:aTitle. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
615 |
textView topView openModal. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
616 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
617 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
618 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
619 |
TextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
620 |
EditTextView openModalWith:'some text' title:'testing' |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
621 |
" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
622 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
623 |
"Modified: 9.9.1996 / 19:32:29 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
624 |
"Created: 14.2.1997 / 15:19:18 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
625 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
626 |
|
248 | 627 |
openOn:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
628 |
"start a textView on a file; return the textView" |
0 | 629 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
630 |
|textView| |
248 | 631 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
632 |
textView := self setupForFile:aFileName. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
633 |
textView topView open. |
248 | 634 |
^ textView |
635 |
||
636 |
" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
637 |
TextView openOn:'../../doc/overview.doc' |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
638 |
EditTextView openOn:'../../doc/overview.doc' |
248 | 639 |
" |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
640 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
641 |
"Modified: 14.2.1997 / 15:21:51 / cg" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
642 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
643 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
644 |
openOnModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
645 |
"start a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
646 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
647 |
|textView| |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
648 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
649 |
textView := self setupForModel:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
650 |
textView topView open. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
651 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
652 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
653 |
"Created: 14.2.1997 / 15:23:36 / cg" |
0 | 654 |
! |
655 |
||
1100 | 656 |
openWith:aStringOrStringCollection |
657 |
"start a textView with aStringOrStringCollection as initial contents" |
|
658 |
||
4500 | 659 |
^ self openWith:aStringOrStringCollection selected:false |
0 | 660 |
|
248 | 661 |
" |
662 |
TextView openWith:'some text' |
|
663 |
EditTextView openWith:'some text' |
|
2794 | 664 |
Workspace openWith:'some text' |
248 | 665 |
" |
119 | 666 |
|
248 | 667 |
"Created: 10.12.1995 / 17:41:32 / cg" |
1100 | 668 |
"Modified: 5.3.1997 / 15:37:19 / cg" |
126 | 669 |
! |
670 |
||
2793 | 671 |
openWith:aStringOrStringCollection selected:selectedBoolean |
4500 | 672 |
"start a textView with aStringOrStringCollection as initial (optionally selected) contents. |
2793 | 673 |
Return the textView." |
674 |
||
675 |
|textView| |
|
676 |
||
677 |
textView := self setupEmpty. |
|
678 |
textView contents:aStringOrStringCollection selected:selectedBoolean. |
|
679 |
textView topView open. |
|
680 |
^ textView |
|
681 |
||
682 |
" |
|
683 |
TextView openWith:'some text' selected:true |
|
684 |
EditTextView openWith:'some text' selected:false |
|
685 |
" |
|
686 |
! |
|
687 |
||
1100 | 688 |
openWith:aStringOrStringCollection title:aTitle |
689 |
"start a textView with aStringOrStringCollection as initial contents. Return the textView." |
|
248 | 690 |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
691 |
|textView| |
248 | 692 |
|
1100 | 693 |
textView := self setupWith:aStringOrStringCollection title:aTitle. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
694 |
textView topView open. |
248 | 695 |
^ textView |
696 |
||
697 |
" |
|
698 |
TextView openWith:'some text' title:'testing' |
|
699 |
EditTextView openWith:'some text' title:'testing' |
|
700 |
" |
|
126 | 701 |
|
248 | 702 |
"Created: 10.12.1995 / 17:40:02 / cg" |
1100 | 703 |
"Modified: 5.3.1997 / 15:37:26 / cg" |
248 | 704 |
! |
705 |
||
706 |
setupEmpty |
|
707 |
"create a textview in a topview, with horizontal and |
|
708 |
vertical scrollbars - a helper for #startWith: and #startOn:" |
|
709 |
||
710 |
|top frame label| |
|
711 |
||
712 |
label := 'unnamed'. |
|
896 | 713 |
top := StandardSystemView label:label icon:self defaultIcon. |
248 | 714 |
|
4500 | 715 |
frame := HVScrollableView |
716 |
for:self |
|
717 |
miniScrollerH:true miniScrollerV:false |
|
718 |
in:top. |
|
248 | 719 |
frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
720 |
^ frame scrolledView |
|
896 | 721 |
|
722 |
"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
|
723 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
724 |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
725 |
setupForFile:aFileName |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
726 |
"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
|
727 |
|
3417 | 728 |
|textView f| |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
729 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
730 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
731 |
aFileName notNil ifTrue:[ |
4500 | 732 |
textView setupForFile:aFileName. |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
733 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
734 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
735 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
736 |
|
3417 | 737 |
"Created: / 14-02-1997 / 15:21:43 / cg" |
738 |
"Modified: / 25-10-2006 / 14:46:54 / cg" |
|
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
739 |
! |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
740 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
741 |
setupForModel:aModel |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
742 |
"setup a textView on a model; return the textView" |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
743 |
|
2793 | 744 |
|textView| |
1014
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
745 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
746 |
textView := self setupEmpty. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
747 |
textView model:aModel. |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
748 |
^ textView |
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
749 |
|
d70cad164cd0
more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents:
1003
diff
changeset
|
750 |
"Created: 14.2.1997 / 15:22:42 / cg" |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
751 |
! |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
752 |
|
1100 | 753 |
setupWith:aStringOrStringCollection title:aTitle |
754 |
"setup a textView with aStringOrStringCollection as initial contents in a topView" |
|
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
755 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
756 |
|top textView| |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
757 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
758 |
textView := self setupEmpty. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
759 |
top := textView topView. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
760 |
aTitle notNil ifTrue:[top label:aTitle]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
761 |
|
1100 | 762 |
aStringOrStringCollection notNil ifTrue:[ |
4500 | 763 |
textView contents:aStringOrStringCollection |
830
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
764 |
]. |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
765 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
766 |
^ textView |
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
767 |
|
0441903116d6
separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
768 |
"Created: 9.9.1996 / 19:31:22 / cg" |
1100 | 769 |
"Modified: 5.3.1997 / 15:37:37 / cg" |
119 | 770 |
! ! |
771 |
||
2744 | 772 |
!TextView methodsFor:'Compatibility-ST80'! |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
773 |
|
2291 | 774 |
displaySelection:aBoolean |
775 |
"ST-80 compatibility: ignored here." |
|
776 |
||
777 |
! |
|
778 |
||
2118
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
779 |
editText:someText |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
780 |
"ST-80 compatibility: set the edited text." |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
781 |
|
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
782 |
self contents:someText |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
783 |
|
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
784 |
"Created: / 5.2.2000 / 17:06:18 / cg" |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
785 |
! |
f9d8bfb35b03
added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2109
diff
changeset
|
786 |
|
2291 | 787 |
selectAndScroll |
788 |
"ST-80 compatibility: ignored here." |
|
789 |
||
790 |
! |
|
791 |
||
4554 | 792 |
selectFrom:startPos to:endPos |
793 |
"change the selection given two character positions." |
|
794 |
||
795 |
self selectFromCharacterPosition:startPos to:endPos |
|
796 |
! |
|
797 |
||
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
798 |
selectionStartIndex |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
799 |
"ST-80 compatibility: return the selections start character position." |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
800 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
801 |
^ self characterPositionOfSelection |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
802 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
803 |
"Created: / 19.6.1998 / 00:21:44 / cg" |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
804 |
! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
805 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
806 |
selectionStopIndex |
2052 | 807 |
"ST-80 compatibility: return the character position of |
808 |
the character right after the selection." |
|
809 |
||
2109
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
810 |
|idx| |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
811 |
|
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
812 |
idx := self characterPositionOfSelectionEnd. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
813 |
idx == 0 ifTrue:[^ 0]. |
ccad6daad477
selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents:
2100
diff
changeset
|
814 |
^ idx + 1 |
1584
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
815 |
|
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
816 |
"Created: / 19.6.1998 / 00:22:08 / cg" |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
817 |
! ! |
9f3875dc341e
added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents:
1545
diff
changeset
|
818 |
|
0 | 819 |
!TextView methodsFor:'accessing'! |
820 |
||
2916 | 821 |
characterEncoding:encodingArg |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
822 |
"define how the contents is encoded internally. |
2916 | 823 |
This should normally never be required, as ST/X now assumes |
824 |
unicode (of which iso8859-1 is a subset) encoding. |
|
825 |
The possibility to change the characterEncoding is provided as |
|
826 |
a backward compatibility hook for programs which want to use |
|
827 |
another encoding internally." |
|
828 |
||
829 |
|encodingSymOrNil| |
|
830 |
||
4500 | 831 |
encodingSymOrNil := encodingArg isNil |
5070 | 832 |
ifTrue:[#'iso10646-1'] |
833 |
ifFalse:[encodingArg asSymbol]. |
|
2916 | 834 |
|
835 |
characterEncoding ~~ encodingSymOrNil ifTrue:[ |
|
5070 | 836 |
"/ TODO: reencode contents if required. |
837 |
(list size ~~ 0 |
|
838 |
and:[ list contains:[:line | line size > 0]]) ifTrue:[ |
|
839 |
(self confirm:(resources stringWithCRs:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?')) |
|
840 |
ifFalse:[^ self]. |
|
841 |
]. |
|
842 |
characterEncoding := encodingSymOrNil. |
|
2916 | 843 |
]. |
4361
646cd7c5513e
comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
844 |
|
646cd7c5513e
comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
845 |
"Modified (format): / 25-01-2012 / 00:28:27 / cg" |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
846 |
! |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
847 |
|
0 | 848 |
characterPositionOfSelection |
1303 | 849 |
"return the character index of the first character in the selection. |
850 |
Returns 0 if there is no selection." |
|
851 |
||
852 |
selectionStartLine isNil ifTrue:[^ 0]. |
|
0 | 853 |
^ self characterPositionOfLine:selectionStartLine |
4500 | 854 |
col:selectionStartCol |
1303 | 855 |
|
856 |
"Modified: 14.8.1997 / 16:35:37 / cg" |
|
857 |
! |
|
858 |
||
859 |
characterPositionOfSelectionEnd |
|
860 |
"return the character index of the last character in the selection. |
|
861 |
Returns 0 if there is no selection." |
|
862 |
||
863 |
selectionStartLine isNil ifTrue:[^ 0]. |
|
864 |
^ self characterPositionOfLine:selectionEndLine |
|
4500 | 865 |
col:selectionEndCol |
1303 | 866 |
|
867 |
"Created: 14.8.1997 / 16:35:24 / cg" |
|
868 |
"Modified: 14.8.1997 / 16:35:45 / cg" |
|
0 | 869 |
! |
870 |
||
871 |
contentsWasSaved |
|
872 |
"return true, if the contents was saved (by a save action), |
|
873 |
false if not (or was modified again after the last save)." |
|
874 |
||
875 |
^ contentsWasSaved |
|
876 |
! |
|
877 |
||
3214 | 878 |
contentsWasSaved:aBoolean |
879 |
contentsWasSaved := aBoolean |
|
880 |
! |
|
881 |
||
3212
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
882 |
defaultFileNameForFileDialog |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
883 |
"return the default fileName to use for the save-box" |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
884 |
|
4500 | 885 |
^ defaultFileNameForFileDialog |
3212
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
886 |
! |
c14cadfd6752
remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents:
3202
diff
changeset
|
887 |
|
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
888 |
defaultFileNameForFileDialog:aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
889 |
"define the default fileName to use for the save-box" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
890 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
891 |
defaultFileNameForFileDialog := aBaseName |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
892 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
893 |
"Created: 13.2.1997 / 18:29:53 / cg" |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
894 |
! |
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
895 |
|
248 | 896 |
directoryForFileDialog:aDirectory |
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
897 |
"define the default directory to use for save-box" |
248 | 898 |
|
899 |
directoryForFileDialog := aDirectory |
|
1003
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
900 |
|
b1affa654489
added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
901 |
"Modified: 13.2.1997 / 18:30:01 / cg" |
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
902 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
903 |
|
2941 | 904 |
externalEncoding |
905 |
"return the encoding used when the contents is saved via the 'save / save as' dialog. |
|
906 |
This is (currently only) passed down from the fileBrowser, |
|
907 |
and required when utf8/japanese/chinese/korean text is edited. |
|
908 |
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc). |
|
909 |
Notice: this only affects the external representation of the text." |
|
910 |
||
911 |
^ externalEncoding |
|
912 |
! |
|
913 |
||
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
914 |
externalEncoding:encodingSymOrNil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
915 |
"define how the contents should be encoded when saved |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
916 |
via the 'save / save as' dialog. |
2916 | 917 |
This is (currently only) passed down from the fileBrowser, |
918 |
and required when utf8/japanese/chinese/korean text is edited. |
|
919 |
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc). |
|
920 |
Notice: this only affects the external representation of the text." |
|
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
921 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
922 |
externalEncoding := encodingSymOrNil |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
923 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
924 |
|
2581 | 925 |
parenthesisSpecification |
926 |
"return the value of the instance variable 'parenthesisSpecification' (automatically generated)" |
|
927 |
||
928 |
^ parenthesisSpecification |
|
929 |
! |
|
930 |
||
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
931 |
parenthesisSpecification:aDictionary |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
932 |
"set the dictionary which specifies which characters are opening, which are closing |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
933 |
and which are ignored characters w.r.t. parenthesis matching. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
934 |
See the classes initialize method for a useful value." |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
935 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
936 |
parenthesisSpecification := aDictionary |
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
937 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
938 |
|
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
939 |
saveAction:something |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
940 |
saveAction := something. |
3581 | 941 |
! |
942 |
||
3981 | 943 |
searchBarActionBlock |
944 |
^ searchBarActionBlock |
|
3581 | 945 |
! |
946 |
||
3981 | 947 |
searchBarActionBlock:something |
948 |
searchBarActionBlock := something. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
949 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
950 |
|
3787 | 951 |
!TextView methodsFor:'accessing-behavior'! |
952 |
||
4485 | 953 |
isReadOnly |
954 |
^ true |
|
955 |
! |
|
956 |
||
3787 | 957 |
readOnly:aBoolean |
958 |
"for protocol compatibility with editTextViews, |
|
959 |
but actually ignored" |
|
960 |
! ! |
|
961 |
||
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
962 |
!TextView methodsFor:'accessing-contents'! |
248 | 963 |
|
2791 | 964 |
contents:newContents selected:selectedBoolean |
965 |
self contents:newContents. |
|
966 |
selectedBoolean ifTrue:[ |
|
4500 | 967 |
list size == 1 ifTrue:[ |
968 |
self selectFromLine:1 col:1 toLine:1 col:(list at:1) size |
|
969 |
] ifFalse:[ |
|
970 |
self selectAll |
|
971 |
] |
|
2791 | 972 |
] |
973 |
||
974 |
" |
|
975 |
|w| |
|
976 |
||
977 |
w := Workspace new open. |
|
978 |
w contents:'Hello world' selected:true. |
|
979 |
" |
|
980 |
! |
|
981 |
||
0 | 982 |
fromFile:aFileName |
983 |
"take contents from a named file" |
|
3724 | 984 |
<resource: #obsolete> |
0 | 985 |
|
3417 | 986 |
self obsoleteMethodWarning. |
987 |
^ self loadTextFile:aFileName. |
|
988 |
||
989 |
"Modified: / 25-10-2006 / 14:47:35 / cg" |
|
0 | 990 |
! |
991 |
||
4755 | 992 |
list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
993 |
"set the displayed contents (a collection of strings) with redraw. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
994 |
Redefined since changing the contents implies deselect" |
0 | 995 |
|
996 |
self unselect. |
|
4755 | 997 |
super list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw |
0 | 998 |
! |
999 |
||
3417 | 1000 |
loadTextFile:aFileName |
1001 |
"take contents from a named file" |
|
1002 |
||
1003 |
|f| |
|
1004 |
||
1005 |
f := aFileName asFilename. |
|
1006 |
self directoryForFileDialog:(f directoryName). |
|
1007 |
self contents:(f contents) |
|
1008 |
||
1009 |
"Created: / 25-10-2006 / 14:44:01 / cg" |
|
1010 |
! |
|
1011 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1012 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1013 |
"set the contents (either a string or a Collection of strings) |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1014 |
dont change the position (i.e. do not scroll) or the selection." |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1015 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1016 |
|selStartLine selStartCol selEndLine selEndCol selStyle| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1017 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1018 |
selStartLine := selectionStartLine. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1019 |
selStartCol := selectionStartCol. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1020 |
selEndLine := selectionEndLine. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1021 |
selEndCol := selectionEndCol. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1022 |
selStyle := selectStyle. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1023 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1024 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1025 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1026 |
selStartLine notNil ifTrue:[ |
4500 | 1027 |
self |
1028 |
selectFromLine:selStartLine col:selStartCol |
|
1029 |
toLine:selEndLine col:selEndCol. |
|
1030 |
selectStyle := selStyle |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1031 |
]. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1032 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1033 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1034 |
"Modified: / 31.3.1998 / 23:33:21 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1035 |
! |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1036 |
|
248 | 1037 |
setList:something |
1038 |
"set the displayed contents (a collection of strings) |
|
1039 |
without redraw. |
|
1040 |
Redefined since changing contents implies deselect" |
|
0 | 1041 |
|
248 | 1042 |
self unselect. |
1043 |
super setList:something |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1044 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1045 |
|
3417 | 1046 |
setupForFile:aFileName |
1047 |
"take contents from a named file" |
|
1048 |
||
1049 |
|baseName| |
|
1050 |
||
1051 |
self loadTextFile:aFileName. |
|
1052 |
aFileName notNil ifTrue:[ |
|
4500 | 1053 |
baseName := aFileName asFilename baseName. |
1054 |
self topView label:baseName. |
|
1055 |
self defaultFileNameForFileDialog:baseName. |
|
3417 | 1056 |
]. |
1057 |
||
1058 |
"Created: / 25-10-2006 / 14:47:13 / cg" |
|
1059 |
! |
|
1060 |
||
1487
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1061 |
text |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1062 |
"for ST80 compatibility" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1063 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1064 |
^ self contents |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1065 |
|
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1066 |
"Created: / 19.4.1998 / 12:53:10 / cg" |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1067 |
! |
4a9bfda28991
added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1477
diff
changeset
|
1068 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1069 |
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
|
1070 |
"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
|
1071 |
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
|
1072 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1073 |
|beginCol endCol endLine thisCharacter flag| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1074 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1075 |
flag := #word. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1076 |
beginCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1077 |
endCol := selectCol. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1078 |
endLine := selectLine. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1079 |
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
|
1080 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1081 |
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
|
1082 |
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
|
1083 |
endCol == 0 ifTrue:[ |
4500 | 1084 |
endLine := selectLine + 1 |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1085 |
]. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1086 |
|
1750 | 1087 |
"is the initial character within a word ?" |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1088 |
(wordCheck value:thisCharacter) ifTrue:[ |
4500 | 1089 |
" |
1090 |
try to catch a blank ... |
|
1091 |
" |
|
1092 |
||
1093 |
WordSelectCatchesBlanks ifTrue:[ |
|
1094 |
((beginCol == 1) |
|
1095 |
or:[(self characterAtLine:selectLine col:(beginCol - 1)) |
|
1096 |
~~ Character space]) ifTrue:[ |
|
1097 |
((self characterAtLine:selectLine col:(endCol + 1)) |
|
1098 |
== Character space) ifTrue:[ |
|
1099 |
endCol := endCol + 1. |
|
1100 |
flag := #wordRight |
|
1101 |
] |
|
1102 |
] ifFalse:[ |
|
1103 |
beginCol := beginCol - 1. |
|
1104 |
flag := #wordLeft |
|
1105 |
]. |
|
1106 |
]. |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1107 |
]. |
4500 | 1108 |
aFiveArgBlock value:selectLine |
1109 |
value:beginCol |
|
1110 |
value:endLine |
|
1111 |
value:endCol |
|
1112 |
value:flag |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1113 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1114 |
"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
|
1115 |
! ! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1116 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1117 |
!TextView methodsFor:'accessing-look'! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1118 |
|
2027
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1119 |
selectionBackgroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1120 |
"return the selection-background color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1121 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1122 |
^ selectionBgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1123 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1124 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1125 |
selectionForegroundColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1126 |
"return the selection-foreground color." |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1127 |
|
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1128 |
^ selectionFgColor |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1129 |
! |
0bde8408361a
accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
1130 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1131 |
selectionForegroundColor:color1 backgroundColor:color2 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1132 |
"set both the selection-foreground and cursor background colors. |
4500 | 1133 |
The default is defined by the styleSheet; |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1134 |
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
|
1135 |
|
1987 | 1136 |
selectionFgColor := color1 onDevice:device. |
1137 |
selectionBgColor := color2 onDevice:device. |
|
2913
bdf4fb09cfc0
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
1138 |
self hasSelection ifTrue:[ |
4500 | 1139 |
self invalidate |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1140 |
] |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
1141 |
|
722
3f297a438fec
use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents:
715
diff
changeset
|
1142 |
"Modified: 29.5.1996 / 16:22:15 / cg" |
0 | 1143 |
! ! |
1144 |
||
248 | 1145 |
!TextView methodsFor:'accessing-mvc'! |
0 | 1146 |
|
248 | 1147 |
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
|
1148 |
"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
|
1149 |
and selection. Added for ST-80 compatibility" |
0 | 1150 |
|
4500 | 1151 |
aspectSym notNil ifTrue:[aspectMsg := aspectSym. |
1152 |
listMsg isNil ifTrue:[listMsg := aspectSym]]. |
|
248 | 1153 |
changeSym notNil ifTrue:[changeMsg := changeSym]. |
1154 |
listSym notNil ifTrue:[listMsg := listSym]. |
|
1155 |
menuSym notNil ifTrue:[menuMsg := menuSym]. |
|
1156 |
"/ initial notNil ifTrue:[initialSelectionMsg := initial]. |
|
1157 |
self model:aModel. |
|
0 | 1158 |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1159 |
"Modified: 15.8.1996 / 12:52:54 / stefan" |
906 | 1160 |
"Modified: 2.1.1997 / 16:11:28 / cg" |
0 | 1161 |
! ! |
1162 |
||
2588 | 1163 |
!TextView methodsFor:'drag & drop'! |
1164 |
||
1165 |
allowDrag:aBoolean |
|
1166 |
"enable/disable dragging support |
|
1167 |
" |
|
1168 |
aBoolean ifFalse:[ |
|
4500 | 1169 |
dropSource := nil. |
2588 | 1170 |
] ifTrue:[ |
4500 | 1171 |
dropSource isNil ifTrue:[ |
1172 |
dropSource := DropSource |
|
1173 |
receiver:self |
|
1174 |
argument:nil |
|
1175 |
dropObjectSelector:#collectionOfDragObjects |
|
1176 |
displayObjectSelector:nil |
|
1177 |
] |
|
2588 | 1178 |
]. |
1179 |
! |
|
1180 |
||
1181 |
canDrag |
|
4368 | 1182 |
"returns true if dragging is enabled" |
1183 |
||
1184 |
^ dropSource notNil and:[ self hasSelection ] |
|
1185 |
||
1186 |
"Modified (comment): / 12-02-2012 / 08:37:21 / cg" |
|
2588 | 1187 |
! |
1188 |
||
1189 |
collectionOfDragObjects |
|
1190 |
"returns collection of dragable objects assigned to selection |
|
1191 |
Here, by default, a collection of text-dragObjects is generated; |
|
1192 |
however, if a dragObjectConverter is defined, that one gets a chance |
|
1193 |
to convert as appropriate. |
|
1194 |
" |
|
1195 |
|selection| |
|
1196 |
||
1197 |
selection := self selection. |
|
1198 |
||
1199 |
selection size == 0 ifTrue:[^ nil]. |
|
5249 | 1200 |
^ Array with:(DropObject newText:selection). |
2588 | 1201 |
! |
1202 |
||
1203 |
dropSource |
|
3245 | 1204 |
"returns the dropSource or nil" |
4500 | 1205 |
|
2588 | 1206 |
^ dropSource |
1207 |
! |
|
1208 |
||
4500 | 1209 |
dropSource:aDropSourceOrNil |
3245 | 1210 |
"set the dropSource or nil" |
4500 | 1211 |
|
2588 | 1212 |
dropSource := aDropSourceOrNil. |
1213 |
! ! |
|
1214 |
||
2881 | 1215 |
!TextView methodsFor:'encoding'! |
1216 |
||
1217 |
validateFontEncodingFor:newEncoding ask:ask |
|
1218 |
"if required, query user if he/she wants to change to another font, |
|
1219 |
which is able to display text encoded as specified by newEncoding" |
|
1220 |
||
4500 | 1221 |
|fontsEncoding msg filter f defaultFont pref matchingFonts |
2881 | 1222 |
matchingFamilyFonts matchingFamilyFaceFonts matchingFamilyFaceStyleFonts |
1223 |
matchingFamilyFaceStyleSizeFonts| |
|
1224 |
||
1225 |
fontsEncoding := font encoding. |
|
1226 |
||
1227 |
pref := FontDescription preferredFontEncodingFor:newEncoding. |
|
1228 |
||
1229 |
(pref match:fontsEncoding) ifTrue:[ |
|
4500 | 1230 |
^ self |
2881 | 1231 |
]. |
1232 |
(CharacterEncoder isEncoding:pref subSetOf:fontsEncoding) ifTrue:[ |
|
4500 | 1233 |
^ self |
2881 | 1234 |
]. |
1235 |
||
1236 |
filter := [:f | |coding| |
|
4500 | 1237 |
(coding := f encoding) notNil |
1238 |
and:[pref match:coding]]. |
|
2881 | 1239 |
|
1240 |
device flushListOfAvailableFonts. |
|
1241 |
matchingFonts := device listOfAvailableFonts select:filter. |
|
1242 |
matchingFamilyFonts := matchingFonts select:[:f | f family = font family]. |
|
1243 |
matchingFamilyFaceFonts := matchingFamilyFonts select:[:f | f face = font face]. |
|
1244 |
matchingFamilyFaceStyleFonts := matchingFamilyFaceFonts select:[:f | f style = font style]. |
|
1245 |
matchingFamilyFaceStyleSizeFonts := matchingFamilyFaceStyleFonts select:[:f | f size = font size]. |
|
1246 |
matchingFamilyFaceStyleSizeFonts size > 0 ifTrue:[ |
|
4500 | 1247 |
defaultFont := matchingFamilyFaceStyleSizeFonts first |
2881 | 1248 |
] ifFalse:[ |
4500 | 1249 |
matchingFamilyFaceStyleFonts size > 0 ifTrue:[ |
1250 |
defaultFont := matchingFamilyFaceStyleFonts first |
|
1251 |
] ifFalse:[ |
|
1252 |
matchingFamilyFaceFonts size > 0 ifTrue:[ |
|
1253 |
defaultFont := matchingFamilyFaceFonts first |
|
1254 |
] ifFalse:[ |
|
1255 |
matchingFamilyFonts size > 0 ifTrue:[ |
|
1256 |
defaultFont := matchingFamilyFonts first |
|
1257 |
] ifFalse:[ |
|
1258 |
matchingFonts size > 0 ifTrue:[ |
|
1259 |
defaultFont := matchingFonts first |
|
1260 |
]. |
|
1261 |
]. |
|
1262 |
]. |
|
1263 |
]. |
|
2881 | 1264 |
]. |
1265 |
||
1266 |
defaultFont isNil ifTrue:[ |
|
4500 | 1267 |
defaultFont isNil ifTrue:[ |
1268 |
self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'. |
|
1269 |
pref := #'iso10646-1'. |
|
1270 |
] |
|
2881 | 1271 |
]. |
1272 |
||
2916 | 1273 |
msg := 'Switch to a %1 encoded font ?'. |
3189 | 1274 |
(ask not or:[self confirm:(resources stringWithCRs:msg with:pref)]) |
2881 | 1275 |
ifTrue:[ |
4500 | 1276 |
self withWaitCursorDo:[ |
1277 |
f := FontPanel |
|
1278 |
fontFromUserInitial:defaultFont |
|
1279 |
title:(resources string:'Font selection') |
|
1280 |
filter:filter |
|
1281 |
encoding:pref. |
|
1282 |
||
1283 |
f notNil ifTrue:[ |
|
1284 |
self font:f. |
|
1285 |
] |
|
1286 |
] |
|
2881 | 1287 |
] |
1288 |
||
1289 |
"Created: 26.10.1996 / 12:06:54 / cg" |
|
1290 |
"Modified: 30.6.1997 / 17:46:46 / cg" |
|
1291 |
! ! |
|
1292 |
||
2752 | 1293 |
!TextView methodsFor:'event handling'! |
0 | 1294 |
|
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1295 |
buttonMotion:buttonState x:x y:y |
0 | 1296 |
"mouse-move while button was pressed - handle selection changes" |
1297 |
||
3219
e8c7679a8a94
buttonrelease behavior, when released in another view
Claus Gittinger <cg@exept.de>
parents:
3214
diff
changeset
|
1298 |
(clickLine isNil or:[clickPos isNil]) ifTrue:[ |
4885 | 1299 |
dragIsActive := false. |
1300 |
^ self |
|
2588 | 1301 |
]. |
1302 |
||
1303 |
dragIsActive ifTrue:[ |
|
4885 | 1304 |
(clickPos dist:(x@y)) >= 5.0 ifTrue:[ |
1305 |
dragIsActive := false. |
|
1306 |
||
1307 |
self hasSelection ifTrue:[ |
|
1308 |
dropSource startDragIn:self at:(x@y) |
|
1309 |
] |
|
1310 |
]. |
|
1311 |
^ self |
|
2588 | 1312 |
]. |
0 | 1313 |
|
63 | 1314 |
"is it the select or 1-button ?" |
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1315 |
buttonState == 0 ifTrue:[^ self]. |
4885 | 1316 |
self sensor leftButtonPressed ifFalse:[ |
1317 |
"/ self setPrimarySelection. |
|
1318 |
"/ self selectionChanged. |
|
1319 |
^ self |
|
1320 |
]. |
|
3040
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1321 |
"/ (device buttonMotionMask:buttonState includesButton:#select) ifFalse:[ |
f5e9092f3312
buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents:
3001
diff
changeset
|
1322 |
"/ (device buttonMotionMask:buttonState includesButton:1) ifFalse:[ |
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1323 |
"/ ^ self |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1324 |
"/ ]. |
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1325 |
"/ ]. |
53 | 1326 |
|
0 | 1327 |
"if moved outside of view, start autoscroll" |
3202
8217b0acc9f2
select from beginning (in editField
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
1328 |
|
4160 | 1329 |
((y < 0) and:[firstLineShown ~~ 0]) ifTrue:[ |
4885 | 1330 |
self compressMotionEvents:false. |
5094 | 1331 |
(self startAutoScrollUp:y negated) ifTrue:[ |
1332 |
^ self |
|
1333 |
]. |
|
0 | 1334 |
]. |
1335 |
(y > height) ifTrue:[ |
|
4885 | 1336 |
self compressMotionEvents:false. |
5094 | 1337 |
(self startAutoScrollDown:(y - height)) ifTrue:[ |
1338 |
^ self |
|
1339 |
]. |
|
59 | 1340 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1341 |
((x < 0) and:[viewOrigin x ~~ 0]) ifTrue:[ |
4885 | 1342 |
self compressMotionEvents:false. |
5094 | 1343 |
(self startAutoScrollLeft:x) ifTrue:[ |
1344 |
^ self |
|
1345 |
]. |
|
59 | 1346 |
]. |
1347 |
(x > width) ifTrue:[ |
|
4885 | 1348 |
self compressMotionEvents:false. |
5094 | 1349 |
(self startAutoScrollRight:(x - width)) ifTrue:[ |
1350 |
^ self |
|
1351 |
]. |
|
0 | 1352 |
]. |
1353 |
||
1354 |
"move inside - stop autoscroll if any" |
|
1355 |
autoScrollBlock notNil ifTrue:[ |
|
4885 | 1356 |
self stopScrollSelect |
0 | 1357 |
]. |
3220 | 1358 |
|
4885 | 1359 |
self extendSelectionToX:x y:y setPrimarySelection:false. |
1619
f600c27c2c47
ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents:
1584
diff
changeset
|
1360 |
|
4160 | 1361 |
"Modified: / 08-08-2010 / 11:20:54 / cg" |
0 | 1362 |
! |
1363 |
||
248 | 1364 |
buttonMultiPress:button x:x y:y |
1365 |
"multi-mouse-click - select word under pointer" |
|
1366 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1367 |
(button == 1) ifTrue:[ |
4500 | 1368 |
clickPos := x @ y. |
1369 |
||
1370 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
|
4063 | 1371 |
"/ self clearSearchAction. |
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
1372 |
|
4500 | 1373 |
clickCount notNil ifTrue:[ |
1374 |
clickCount := clickCount + 1. |
|
1375 |
(clickCount == 2) ifTrue:[ |
|
1376 |
self doubleClickX:x y:y |
|
1377 |
] ifFalse:[ |
|
1378 |
(clickCount == 3) ifTrue:[ |
|
1379 |
self tripleClickX:x y:y |
|
1380 |
] ifFalse:[ |
|
1381 |
(clickCount == 4) ifTrue:[ |
|
1382 |
self quadClickX:x y:y |
|
1383 |
] |
|
1384 |
] |
|
1385 |
] |
|
1386 |
] |
|
248 | 1387 |
] ifFalse:[ |
4500 | 1388 |
super buttonMultiPress:button x:x y:y |
248 | 1389 |
] |
1390 |
||
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1391 |
"Modified: 11.9.1997 / 04:15:35 / cg" |
248 | 1392 |
! |
1393 |
||
1394 |
buttonPress:button x:x y:y |
|
1395 |
"mouse-click - prepare for selection change" |
|
1396 |
||
1308 | 1397 |
|sensor clickVisibleLine| |
1398 |
||
2588 | 1399 |
dragIsActive := false. |
1400 |
sensor := self sensor. |
|
1401 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1402 |
(button == 1) ifTrue:[ |
4500 | 1403 |
sensor shiftDown ifTrue:[ |
1404 |
"mouse-click with shift - adding to selection" |
|
1405 |
self extendSelectionToX:x y:y. |
|
1406 |
^ self |
|
1407 |
]. |
|
1408 |
||
1409 |
clickVisibleLine := self visibleLineOfY:y. |
|
1410 |
clickPos := x @ y. |
|
1411 |
clickCol := self colOfX:x inVisibleLine:clickVisibleLine. |
|
1412 |
clickLine := self visibleLineToAbsoluteLine:clickVisibleLine. |
|
1413 |
clickStartLine := clickLine. |
|
1414 |
clickStartCol := clickCol. |
|
1415 |
||
1416 |
(self canDrag |
|
1417 |
and:[(self isInSelection:clickLine col:clickCol) |
|
1418 |
and:[UserPreferences current startTextDragWithControl not |
|
1419 |
or:[sensor ctrlDown]]]) ifTrue:[ |
|
1420 |
dragIsActive := true |
|
1421 |
] ifFalse:[ |
|
1422 |
self unselect. |
|
1423 |
]. |
|
1424 |
clickCount := 1 |
|
248 | 1425 |
] ifFalse:[ |
4500 | 1426 |
super buttonPress:button x:x y:y |
248 | 1427 |
] |
813
7168eda47e3b
Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents:
770
diff
changeset
|
1428 |
|
1909 | 1429 |
"Modified: / 20.5.1999 / 17:02:45 / cg" |
248 | 1430 |
! |
1431 |
||
0 | 1432 |
buttonRelease:button x:x y:y |
1433 |
"mouse- button release - turn off autoScroll if any" |
|
1434 |
||
3914
ceb85ec53629
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3909
diff
changeset
|
1435 |
(button == 1) ifTrue:[ |
4885 | 1436 |
self hasSelection ifTrue:[ |
1437 |
self setPrimarySelection. |
|
1438 |
self selectionChanged. |
|
1439 |
]. |
|
1440 |
||
1441 |
autoScrollBlock notNil ifTrue:[ |
|
1442 |
self stopScrollSelect |
|
1443 |
]. |
|
1444 |
dragIsActive ifTrue:[ |
|
1445 |
self unselect |
|
1446 |
]. |
|
1447 |
clickPos := nil. |
|
0 | 1448 |
] ifFalse:[ |
4885 | 1449 |
super buttonRelease:button x:x y:y |
1909 | 1450 |
]. |
2588 | 1451 |
dragIsActive := false. |
1452 |
||
1909 | 1453 |
"/ clickPos := clickLine := clickCol := nil. |
1454 |
||
1455 |
"Modified: / 20.5.1999 / 17:14:23 / cg" |
|
824
f62922fcfa5d
Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents:
813
diff
changeset
|
1456 |
! |
248 | 1457 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1458 |
doubleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1459 |
"double-click - select word under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1460 |
|
3588
a70267e5b501
st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents:
3587
diff
changeset
|
1461 |
|sel ch scanCh matchCol scanCol fwdScan fwdSelect| |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1462 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1463 |
self selectWordAtX:x y:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1464 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1465 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1466 |
special - if clicked on a parenthesis, select to matching |
4702 | 1467 |
(must de before doing the ST80 stuff below) |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1468 |
" |
4500 | 1469 |
((sel := self selection) size == 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1470 |
and:[(sel := sel at:1) size == 1]) ifTrue:[ |
4702 | 1471 |
ch := sel at:1. |
1472 |
||
1473 |
((self isOpeningParenthesis:ch) |
|
1474 |
or:[ (self isClosingParenthesis:ch) ]) ifTrue:[ |
|
1475 |
self |
|
1476 |
searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol |
|
1477 |
ifFound:[:line :col | |
|
1478 |
|prevLine prevCol moveBack pos1| |
|
1479 |
||
1480 |
prevLine := firstLineShown. |
|
1481 |
prevCol := viewOrigin x. |
|
1482 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1483 |
toLine:line col:col. |
|
1484 |
||
1485 |
self sensor ctrlDown ifFalse:[ |
|
1486 |
"/ undo scroll operation ... |
|
1487 |
self withCursor:Cursor eye do:[ |
|
1488 |
|delayCount| |
|
1489 |
||
1490 |
moveBack := false. |
|
1491 |
(self isClosingParenthesis:ch) ifTrue:[ |
|
1492 |
(firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[ |
|
1493 |
moveBack := true |
|
1494 |
] |
|
1495 |
] ifFalse:[ |
|
1496 |
selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[ |
|
1497 |
self makeLineVisible:selectionEndLine. |
|
1498 |
moveBack := true |
|
1499 |
] |
|
1500 |
]. |
|
1501 |
moveBack ifTrue:[ |
|
1502 |
delayCount := 0. |
|
1503 |
pos1 := x@y. |
|
1504 |
self invalidateRepairNow:true. |
|
1505 |
Delay waitForSeconds:MatchDelayTime. |
|
1506 |
delayCount := delayCount + MatchDelayTime. |
|
1507 |
[self sensor hasUserEventFor:self] whileFalse:[ |
|
1508 |
Delay waitForSeconds:MatchDelayTime / 2. |
|
1509 |
delayCount := delayCount + (MatchDelayTime / 2). |
|
1510 |
delayCount > 2 ifTrue:[ |
|
1511 |
self cursor:Cursor eyeClosed. |
|
1512 |
]. |
|
1513 |
delayCount >= 2.3 ifTrue:[ |
|
1514 |
self cursor:Cursor eye. |
|
1515 |
delayCount := 0. |
|
1516 |
] |
|
1517 |
]. |
|
1518 |
self scrollToLine:prevLine; scrollToCol:prevCol. |
|
1519 |
]. |
|
1520 |
] |
|
1521 |
]. |
|
1522 |
^ self. |
|
1523 |
] |
|
1524 |
ifNotFound:[self showNotFound] |
|
1525 |
onError:[self beep] |
|
1526 |
openingCharacters:((parenthesisSpecification at:#open) ", '([{'") |
|
1527 |
closingCharacters:((parenthesisSpecification at:#close) ", ')]}'"). |
|
1528 |
selectStyle := nil |
|
1529 |
] |
|
1530 |
]. |
|
1531 |
||
1532 |
(self st80SelectMode or:[ self sensor ctrlDown]) ifTrue:[ |
|
1533 |
"/ st80 selects: |
|
1534 |
"/ - if clicked right after a parenthesis -> select to matching parenthesis |
|
1535 |
"/ - if clicked right after a quote -> select to matching quote (unless escaped ;-) |
|
1536 |
"/ - if clicked at beginning of the line -> select that line |
|
1537 |
"/ - if clicked at the top of the text -> select all |
|
1538 |
"/ however, do none of the above, if clicked on a parenthesis |
|
1539 |
clickCol == 1 ifTrue:[ |
|
1540 |
clickLine == 1 ifTrue:[ |
|
1541 |
self selectAll. |
|
1542 |
^ self. |
|
1543 |
]. |
|
1544 |
self selectLineAtY:y. |
|
1545 |
selectStyle := #line. |
|
1546 |
^ self |
|
1547 |
]. |
|
1548 |
||
1549 |
matchCol := nil. |
|
1550 |
"/ see what is to the left of that character ... |
|
1551 |
clickCol > 1 ifTrue:[ |
|
1552 |
ch := self characterAtLine:clickLine col:clickCol-1. |
|
1553 |
(self isOpeningParenthesis:ch) ifTrue:[ |
|
1554 |
matchCol := clickCol - 1 |
|
1555 |
] ifFalse:[ |
|
1556 |
('"''|' includes:ch) ifTrue:[ |
|
1557 |
scanCol := clickCol - 1. |
|
1558 |
fwdScan := true. |
|
1559 |
scanCh := ch. |
|
1560 |
] |
|
1561 |
] |
|
1562 |
]. |
|
1563 |
fwdSelect := true. |
|
1564 |
(matchCol isNil and:[scanCol isNil]) ifTrue:[ |
|
1565 |
clickCol < (self listAt:clickLine) size ifTrue:[ |
|
1566 |
ch := self characterAtLine:clickLine col:clickCol+1. |
|
1567 |
(self isClosingParenthesis:ch) ifTrue:[ |
|
1568 |
matchCol := clickCol + 1. |
|
1569 |
fwdSelect := false. |
|
1570 |
] ifFalse:[ |
|
1571 |
('"''|' includes:ch) ifTrue:[ |
|
1572 |
scanCol := clickCol + 1. |
|
1573 |
fwdScan := false. |
|
1574 |
scanCh := ch. |
|
1575 |
] |
|
1576 |
] |
|
1577 |
]. |
|
1578 |
]. |
|
1579 |
matchCol notNil ifTrue:[ |
|
1580 |
self |
|
1581 |
searchForMatchingParenthesisFromLine:clickLine col:matchCol |
|
1582 |
ifFound:[:line :col | |
|
1583 |
self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1) |
|
1584 |
toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)] |
|
1585 |
ifNotFound:[self showNotFound] |
|
1586 |
onError:[self beep] |
|
1587 |
openingCharacters:((parenthesisSpecification at:#open) , '([{') |
|
1588 |
closingCharacters:((parenthesisSpecification at:#close) , ')]}'). |
|
1589 |
^ self |
|
1590 |
]. |
|
1591 |
scanCol notNil ifTrue:[ |
|
1592 |
"/ if its an EOL comment, do it differently |
|
1593 |
ch := self characterAtLine:clickLine col:clickCol. |
|
1594 |
ch == $/ ifTrue:[ |
|
1595 |
self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0. |
|
1596 |
^ self |
|
1597 |
]. |
|
1598 |
||
1599 |
self |
|
1600 |
scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan |
|
1601 |
ifFound:[:line :col | |
|
1602 |
|selStart selEnd| |
|
1603 |
||
1604 |
fwdScan ifTrue:[ |
|
1605 |
selStart := scanCol+1. |
|
1606 |
selEnd := col-1. |
|
1607 |
] ifFalse:[ |
|
1608 |
selStart := scanCol-1. |
|
1609 |
selEnd := col+1. |
|
1610 |
]. |
|
1611 |
self selectFromLine:clickLine col:selStart |
|
1612 |
toLine:line col:selEnd. |
|
1613 |
^ self |
|
1614 |
] |
|
1615 |
ifNotFound:[self showNotFound]. |
|
1616 |
^ self |
|
1617 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1618 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1619 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1620 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1621 |
remember words position in case of a drag following |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1622 |
" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1623 |
wordStartLine := selectionStartLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1624 |
wordEndLine := selectionEndLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1625 |
selectStyle == #wordLeft ifTrue:[ |
4702 | 1626 |
wordStartCol := selectionStartCol + 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1627 |
] ifFalse:[ |
4702 | 1628 |
wordStartCol := selectionStartCol. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1629 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1630 |
selectStyle == #wordRight ifTrue:[ |
4702 | 1631 |
wordEndCol := selectionEndCol - 1 |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1632 |
] ifFalse:[ |
4702 | 1633 |
wordEndCol := selectionEndCol |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1634 |
] |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1635 |
|
3308 | 1636 |
"Created: / 11-09-1997 / 04:12:55 / cg" |
4255 | 1637 |
"Modified: / 14-06-2011 / 14:04:59 / cg" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1638 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1639 |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1640 |
extendSelectionToX:x y:y |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1641 |
"mouse-move while button was pressed - handle selection changes" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1642 |
|
4885 | 1643 |
self extendSelectionToX:x y:y setPrimarySelection:true |
1644 |
! |
|
1645 |
||
1646 |
extendSelectionToX:x y:y setPrimarySelection:aBoolean |
|
1647 |
"mouse-move while button was pressed - handle selection changes" |
|
1648 |
||
4500 | 1649 |
|movedVisibleLine movedLine movedCol |
1650 |
movedUp |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1651 |
oldStartLine oldEndLine oldStartCol oldEndCol| |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1652 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1653 |
movedVisibleLine := self visibleLineOfY:y. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1654 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1655 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1656 |
(x < leftMargin) ifTrue:[ |
4636 | 1657 |
movedCol := 0 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1658 |
] ifFalse:[ |
4636 | 1659 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1660 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1661 |
y < 0 ifTrue:[ |
4636 | 1662 |
movedCol := 0 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1663 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1664 |
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[ |
4636 | 1665 |
selectionStartLine notNil ifTrue:[ |
1666 |
^ self |
|
1667 |
]. |
|
1668 |
(clickPos isNil |
|
1669 |
or:[(clickPos x - x) abs < 3 |
|
1670 |
and:[(clickPos y - y) abs < 3]]) ifTrue:[ |
|
1671 |
^ self |
|
1672 |
]. |
|
1673 |
selectionStartLine := clickLine. |
|
1674 |
selectionStartCol := clickCol. |
|
1675 |
selectionEndLine := selectionStartLine. |
|
1676 |
selectionEndCol := selectionStartCol. |
|
1677 |
||
1678 |
oldStartLine := selectionStartLine. |
|
1679 |
oldEndLine := selectionEndLine. |
|
1680 |
oldStartCol := selectionStartCol. |
|
1681 |
oldEndCol := selectionEndCol-1. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1682 |
] ifFalse:[ |
4636 | 1683 |
selectionStartLine isNil ifTrue:[ |
1684 |
selectionStartLine := selectionEndLine := clickLine. |
|
1685 |
selectionStartCol := selectionEndCol := clickCol. |
|
1686 |
]. |
|
1687 |
oldStartLine := selectionStartLine. |
|
1688 |
oldEndLine := selectionEndLine. |
|
1689 |
oldStartCol := selectionStartCol. |
|
1690 |
oldEndCol := selectionEndCol. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1691 |
]. |
3692 | 1692 |
oldEndLine isNil ifTrue:[ |
4636 | 1693 |
oldEndLine := selectionEndLine ? clickLine ? movedLine. |
3692 | 1694 |
]. |
1695 |
oldEndCol isNil ifTrue:[ |
|
4636 | 1696 |
oldEndCol := selectionEndCol ? clickCol. |
3692 | 1697 |
]. |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1698 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1699 |
"find out if we are before or after initial click" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1700 |
movedUp := false. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1701 |
clickStartLine isNil ifTrue:[ |
4636 | 1702 |
clickStartLine := movedLine. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1703 |
]. |
3505 | 1704 |
clickStartCol isNil ifTrue:[ |
4636 | 1705 |
clickStartCol := movedCol. |
3505 | 1706 |
]. |
3443
09a7671630a9
changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
3438
diff
changeset
|
1707 |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1708 |
(movedLine < clickStartLine) ifTrue:[ |
4636 | 1709 |
movedUp := true |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1710 |
] ifFalse:[ |
4636 | 1711 |
(movedLine == clickStartLine) ifTrue:[ |
1712 |
(movedCol < clickStartCol) ifTrue:[ |
|
1713 |
movedUp := true |
|
1714 |
] |
|
1715 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1716 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1717 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1718 |
movedUp ifTrue:[ |
4636 | 1719 |
"change selectionStart" |
1720 |
selectionStartCol := movedCol. |
|
1721 |
selectionStartLine := movedLine. |
|
1722 |
selectionEndCol := clickStartCol. |
|
1723 |
selectionEndLine := clickStartLine. |
|
1724 |
selectStyle notNil ifTrue:[ |
|
1725 |
selectionEndCol := wordEndCol. |
|
1726 |
selectionEndLine := wordEndLine. |
|
1727 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1728 |
] ifFalse:[ |
4636 | 1729 |
"change selectionEnd" |
1730 |
selectionEndCol := movedCol. |
|
1731 |
selectionEndLine := movedLine. |
|
1732 |
selectionStartCol := clickStartCol. |
|
1733 |
selectionStartLine := clickStartLine. |
|
1734 |
selectStyle notNil ifTrue:[ |
|
1735 |
selectionStartCol := wordStartCol. |
|
1736 |
selectionStartLine := wordStartLine. |
|
1737 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1738 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1739 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1740 |
selectionStartLine isNil ifTrue:[^ self]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1741 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1742 |
(selectionStartCol == 0) ifTrue:[ |
4636 | 1743 |
selectionStartCol := 1 |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1744 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1745 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1746 |
" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1747 |
if in word-select, just catch the rest of the word |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1748 |
" |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1749 |
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[ |
4636 | 1750 |
movedUp ifTrue:[ |
1751 |
selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol |
|
1752 |
] ifFalse:[ |
|
1753 |
selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol. |
|
1754 |
selectionEndCol == 0 ifTrue:[ |
|
1755 |
selectionEndLine := selectionEndLine + 1 |
|
1756 |
] |
|
1757 |
]. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1758 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1759 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1760 |
selectStyle == #line ifTrue:[ |
4636 | 1761 |
movedUp ifTrue:[ |
1762 |
selectionStartCol := 1. |
|
1763 |
] ifFalse:[ |
|
1764 |
selectionEndCol := 0. |
|
1765 |
selectionEndLine := selectionEndLine + 1 |
|
1766 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1767 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1768 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1769 |
self validateNewSelection. |
4885 | 1770 |
aBoolean ifTrue:[ |
1771 |
self setPrimarySelection. |
|
1772 |
self selectionChanged. |
|
1773 |
]. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1774 |
|
4063 | 1775 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
1776 |
"/ self clearSearchAction. |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1777 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1778 |
(oldStartLine == selectionStartLine) ifTrue:[ |
4636 | 1779 |
(oldStartCol ~~ selectionStartCol) ifTrue:[ |
1780 |
self |
|
1781 |
redrawLine:oldStartLine |
|
1782 |
from:((selectionStartCol min:oldStartCol) max:1) |
|
1783 |
to:((selectionStartCol max:oldStartCol) max:1) |
|
1784 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1785 |
] ifFalse:[ |
4636 | 1786 |
self |
1787 |
redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine) |
|
1788 |
to:(oldStartLine?selectionStartLine max:selectionStartLine) |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1789 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1790 |
|
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1791 |
(oldEndLine == selectionEndLine) ifTrue:[ |
4636 | 1792 |
(oldEndCol notNil and:[oldEndCol ~~ selectionEndCol]) ifTrue:[ |
1793 |
self redrawLine:oldEndLine |
|
1794 |
from:((selectionEndCol min:oldEndCol) max:1) |
|
1795 |
to:((selectionEndCol max:oldEndCol) max:1) |
|
1796 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1797 |
] ifFalse:[ |
4636 | 1798 |
selectionEndLine isNil ifTrue:[ |
1799 |
selectionStartLine := nil. |
|
1800 |
self redraw. |
|
1801 |
] ifFalse:[ |
|
1802 |
(selectionStartLine notNil) ifTrue:[ |
|
1803 |
self redrawFromLine:(oldEndLine min:selectionEndLine) |
|
1804 |
to:(oldEndLine max:selectionEndLine) |
|
1805 |
] |
|
1806 |
] |
|
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1807 |
]. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1808 |
clickLine := movedLine. |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1809 |
clickCol := movedCol |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1810 |
|
4234
65f202270d2c
changed: #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents:
4178
diff
changeset
|
1811 |
"Modified: / 05-04-2011 / 17:13:35 / cg" |
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
1812 |
"Modified: / 17-04-2012 / 21:00:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3251
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1813 |
! |
156d3ee6a6c1
fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
1814 |
|
248 | 1815 |
keyPress:key x:x y:y |
1816 |
"handle some keyboard input (there is not much to be done here)" |
|
1817 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1818 |
<resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain |
4500 | 1819 |
#GotoLine #SelectAll #SaveAs #Print |
1820 |
#'F*' #'f*' #ZoomIn #ZoomOut)> |
|
248 | 1821 |
|
1822 |
(key == #Find) ifTrue:[self search. ^self]. |
|
1823 |
(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
|
1824 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
248 | 1825 |
|
1826 |
(key == #FindNext) ifTrue:[self searchFwd. ^self]. |
|
1827 |
(key == #FindPrev) ifTrue:[self searchBwd. ^self]. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
1828 |
(key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self]. |
248 | 1829 |
|
1830 |
(key == #SelectAll) ifTrue:[self selectAll. ^self]. |
|
1831 |
||
614 | 1832 |
(key == #SaveAs) ifTrue:[self save. ^self]. |
1833 |
(key == #Print) ifTrue:[self doPrint. ^self]. |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
1834 |
|
4409 | 1835 |
(key == #ZoomIn or:[key == #ZoomOut]) ifTrue:[ self fontLargerOrSmaller:(key == #ZoomIn) ]. |
1836 |
||
248 | 1837 |
" |
4500 | 1838 |
shift-Fn defines a key-sequence |
248 | 1839 |
Fn pastes that sequence |
1840 |
cmd-Fn performs a 'doIt' on the sequence (Workspaces only) |
|
1841 |
||
1842 |
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y) |
|
1843 |
" |
|
1193
811135bbd017
Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents:
1188
diff
changeset
|
1844 |
(key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[ |
4500 | 1845 |
(('[fF][0-9]' match:key) |
1846 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
1847 |
self sensor shiftDown ifTrue:[ |
|
1848 |
UserPreferences current functionKeySequences |
|
1849 |
at:key put:(self selection) |
|
1850 |
]. |
|
1851 |
^ self |
|
1852 |
]. |
|
248 | 1853 |
]. |
1854 |
||
1855 |
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
|
1856 |
|
4409 | 1857 |
"Modified: / 18-04-1997 / 12:12:27 / stefan" |
1858 |
"Modified: / 10-03-2012 / 09:40:01 / cg" |
|
248 | 1859 |
! |
1860 |
||
4500 | 1861 |
mapped |
248 | 1862 |
super mapped. |
1987 | 1863 |
selectionFgColor := selectionFgColor onDevice:device. |
1864 |
selectionBgColor := selectionBgColor onDevice:device. |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1865 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1866 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1867 |
quadClickX:x y:y |
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1868 |
"quadrupleClick-click - select all" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1869 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1870 |
self selectAll |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1871 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1872 |
"Created: / 11.9.1997 / 04:15:24 / cg" |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1475
diff
changeset
|
1873 |
"Modified: / 31.3.1998 / 14:21:13 / cg" |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1874 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1875 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1876 |
tripleClickX:x y:y |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1877 |
"triple-click - select line under pointer" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1878 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1879 |
self selectLineAtY:y. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1880 |
selectStyle := #line |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1881 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
1882 |
"Created: 11.9.1997 / 04:13:37 / cg" |
0 | 1883 |
! ! |
248 | 1884 |
|
2120 | 1885 |
!TextView methodsFor:'initialization & release'! |
248 | 1886 |
|
941 | 1887 |
fetchDeviceResources |
1888 |
"fetch device colors, to avoid reallocation at redraw time" |
|
1889 |
||
1890 |
super fetchDeviceResources. |
|
1891 |
||
1987 | 1892 |
selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor onDevice:device]. |
1893 |
selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor onDevice:device]. |
|
941 | 1894 |
|
1895 |
"Created: 14.1.1997 / 00:14:33 / cg" |
|
1896 |
! |
|
1897 |
||
248 | 1898 |
initStyle |
966 | 1899 |
"setup viewStyle specifics" |
1900 |
||
248 | 1901 |
super initStyle. |
1902 |
||
1903 |
viewBackground := DefaultViewBackground. |
|
1904 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
1905 |
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor]. |
|
1906 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
1907 |
selectionBgColor isNil ifTrue:[ |
|
5099 | 1908 |
device hasColors ifTrue:[ |
1909 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
1910 |
selectionFgColor := fgColor |
|
1911 |
]. |
|
1912 |
selectionBgColor := Color green |
|
1913 |
] ifFalse:[ |
|
1914 |
device hasGrayscales ifTrue:[ |
|
1915 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
1916 |
selectionFgColor := fgColor |
|
1917 |
]. |
|
1918 |
selectionBgColor := Color gray |
|
1919 |
] ifFalse:[ |
|
1920 |
selectionBgColor := fgColor |
|
1921 |
] |
|
1922 |
] |
|
248 | 1923 |
]. |
708 | 1924 |
|
4321 | 1925 |
"Modified: / 22-01-1997 / 11:57:53 / cg" |
1926 |
"Modified (comment): / 05-10-2011 / 15:50:45 / az" |
|
248 | 1927 |
! |
1928 |
||
1929 |
initialize |
|
1930 |
super initialize. |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1931 |
self initializeSaveAction. |
248 | 1932 |
contentsWasSaved := false. |
2588 | 1933 |
dragIsActive := false. |
4864 | 1934 |
lastSearchWasMatch := lastSearchWasVariableSearch := false. |
1935 |
lastSearchIgnoredCase := true. |
|
248 | 1936 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1937 |
parenthesisSpecification isNil ifTrue:[ |
4748 | 1938 |
parenthesisSpecification := DefaultParenthesisSpecification. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1939 |
]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
1940 |
|
911 | 1941 |
"I handle menus myself" |
1942 |
menuHolder := menuPerformer := self. |
|
1943 |
||
2588 | 1944 |
"/ on default allow drag |
1945 |
self allowDrag:true. |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1946 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1947 |
|
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1948 |
initializeSaveAction |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
1949 |
saveAction := [ self openSaveDialog ] |
248 | 1950 |
! ! |
1951 |
||
4450 | 1952 |
!TextView methodsFor:'menu & menu actions'! |
248 | 1953 |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1954 |
appendTo:aFileName |
248 | 1955 |
"append contents to a file named fileName" |
1956 |
||
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1957 |
|aStream msg filename| |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1958 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1959 |
filename := aFileName asFilename. |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1960 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1961 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[ |
4500 | 1962 |
msg := resources string:'Refused to append to file ''%1'' !!' with:filename name. |
1963 |
self warn:(msg , '\\(ST/X internal permission check)' ) withCRs. |
|
1964 |
^ self |
|
2036
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1965 |
]. |
83ac940a9fc6
allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents:
2027
diff
changeset
|
1966 |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1967 |
[ |
4500 | 1968 |
aStream := filename appendingWriteStream. |
1969 |
[ |
|
1970 |
self fileOutContentsOn:aStream compressTabs:true encoding:externalEncoding. |
|
1971 |
] ensure:[ |
|
1972 |
aStream close. |
|
1973 |
]. |
|
1974 |
contentsWasSaved := true |
|
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
1975 |
] on:FileStream openErrorSignal do:[:ex| |
4500 | 1976 |
msg := resources string:'cannot append to file %1 !!' with:filename name. |
1977 |
self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs |
|
248 | 1978 |
] |
4437 | 1979 |
|
1980 |
"Modified: / 27-07-2012 / 09:41:18 / cg" |
|
248 | 1981 |
! |
1982 |
||
1983 |
changeFont |
|
1984 |
"pop up a fontPanel to change font" |
|
1985 |
||
411 | 1986 |
|newFont| |
248 | 1987 |
|
5005 | 1988 |
self withWaitCursorDo:[ |
1989 |
newFont := FontPanel fontFromUserInitial:font. |
|
1990 |
]. |
|
411 | 1991 |
newFont notNil ifTrue:[ |
5005 | 1992 |
self font:newFont. |
411 | 1993 |
] |
1994 |
||
1995 |
"Modified: 27.2.1996 / 00:53:51 / cg" |
|
248 | 1996 |
! |
1997 |
||
1998 |
copySelection |
|
1999 |
"copy contents into smalltalk copybuffer" |
|
2000 |
||
863 | 2001 |
|text| |
248 | 2002 |
|
2003 |
text := self selection. |
|
2004 |
text notNil ifTrue:[ |
|
4500 | 2005 |
self unselect. |
2006 |
||
2007 |
"/ forget any emphasis ... |
|
2008 |
text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]]. |
|
2009 |
self setClipboardText:text. |
|
248 | 2010 |
] |
649
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
2011 |
|
097c69ce9599
forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents:
633
diff
changeset
|
2012 |
"Modified: 17.5.1996 / 08:57:54 / cg" |
248 | 2013 |
! |
2014 |
||
2015 |
defaultForGotoLine |
|
2016 |
"return a default value to show in the gotoLine box" |
|
2017 |
||
447
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
2018 |
^ selectionStartLine |
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
2019 |
|
ed41e1bbd9a1
also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
2020 |
"Modified: 1.3.1996 / 18:44:36 / cg" |
248 | 2021 |
! |
2022 |
||
614 | 2023 |
doPrint |
2024 |
"print the contents on the printer" |
|
2025 |
||
2026 |
|printStream| |
|
2027 |
||
2028 |
list isNil ifTrue:[^ self]. |
|
2029 |
||
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2030 |
self withWaitCursorDo:[ |
4500 | 2031 |
printStream := Printer new. |
2032 |
printStream supportsContext ifTrue:[ |
|
2033 |
printStream printerContext font:(self font). |
|
2034 |
]. |
|
2035 |
||
2036 |
Printer writeErrorSignal handle:[:ex | |
|
2037 |
self warn:('error while printing:\\' |
|
2038 |
, ex description |
|
2039 |
, '\\(printing with: ' , (Printer printCommand) , ')') withCRs |
|
2040 |
] do:[ |
|
2041 |
self fileOutContentsOn:printStream. |
|
2042 |
]. |
|
2043 |
printStream close |
|
829
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2044 |
]. |
fd15ef9c598a
show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents:
824
diff
changeset
|
2045 |
|
4363 | 2046 |
"Created: / 06-05-1996 / 16:11:26 / cg" |
2047 |
"Modified: / 31-01-2012 / 18:16:39 / cg" |
|
614 | 2048 |
! |
2049 |
||
248 | 2050 |
editMenu |
1109 | 2051 |
"return my popUpMenu" |
2052 |
||
489 | 2053 |
<resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1255
diff
changeset
|
2054 |
<resource: #programMenu> |
489 | 2055 |
|
1545 | 2056 |
|items m| |
2057 |
||
2058 |
items := #( |
|
4500 | 2059 |
('Copy' copySelection Copy) |
2060 |
('-' nil ) |
|
2061 |
('Search...' search Find) |
|
2062 |
('Goto Line...' gotoLine GotoLine) |
|
2063 |
('-' nil ) |
|
2064 |
('Font...' changeFont ) |
|
2065 |
('-' nil ) |
|
2066 |
('Save As...' save SaveAs) |
|
2067 |
('Print' doPrint Print) |
|
2068 |
). |
|
248 | 2069 |
|
1545 | 2070 |
m := PopUpMenu itemList:items resources:resources. |
248 | 2071 |
|
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
2072 |
self hasSelectionForCopy ifFalse:[ |
4500 | 2073 |
m disable:#copySelection. |
248 | 2074 |
]. |
2075 |
^ m |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
411
diff
changeset
|
2076 |
|
2458 | 2077 |
"Modified: / 12.11.2001 / 13:43:56 / cg" |
248 | 2078 |
! |
2079 |
||
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2080 |
find |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2081 |
"same as search - for VW compatibility" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2082 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2083 |
self search |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2084 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2085 |
"Created: 31.7.1997 / 19:13:58 / cg" |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2086 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2087 |
|
4409 | 2088 |
fontLargerOrSmaller:largerBoolean |
2089 |
|newFont| |
|
2090 |
||
4785 | 2091 |
newFont := font asSize:(largerBoolean |
2092 |
ifTrue:[font size + 1] |
|
2093 |
ifFalse:[(font size-1) max:4]). |
|
4409 | 2094 |
self font:newFont. |
2095 |
||
2096 |
"Modified: / 27-02-1996 / 00:53:51 / cg" |
|
2097 |
"Created: / 10-03-2012 / 09:38:32 / cg" |
|
2098 |
! |
|
2099 |
||
248 | 2100 |
gotoLine |
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
2101 |
"show a box to enter lineNumber for positioning; |
4500 | 2102 |
The entered number may be prefixed by a + or -; |
1926 | 2103 |
in this case, the linenumber is taken relative to the current position." |
2104 |
||
2105 |
|l lineNumberBox input lineToGo relative| |
|
248 | 2106 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2107 |
lineNumberBox := |
4500 | 2108 |
EnterBox |
2109 |
title:(resources string:'Line number (or +/- relativeNr):') |
|
2110 |
okText:(resources string:'Goto') |
|
2111 |
abortText:(resources string:'Cancel') |
|
2112 |
action:[:l | input := l]. |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2113 |
|
248 | 2114 |
l := self defaultForGotoLine. |
2115 |
l notNil ifTrue:[ |
|
4500 | 2116 |
l := l printString |
248 | 2117 |
]. |
2118 |
lineNumberBox initialText:l . |
|
3394 | 2119 |
lineNumberBox label:(resources string:'Goto Line'). |
1380 | 2120 |
lineNumberBox showAtPointer. |
2121 |
||
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
2122 |
input size > 0 ifTrue:[ |
4500 | 2123 |
input := input withoutSpaces. |
2124 |
input size > 0 ifTrue:[ |
|
2125 |
(input startsWith:$+) ifTrue:[ |
|
2126 |
relative := 1. |
|
2127 |
] ifFalse:[ |
|
2128 |
(input startsWith:$-) ifTrue:[ |
|
2129 |
relative := -1. |
|
2130 |
]. |
|
2131 |
]. |
|
2132 |
relative notNil ifTrue:[ |
|
2133 |
input := input copyFrom:2. |
|
2134 |
]. |
|
2135 |
lineToGo := Integer readFromString:input onError:nil. |
|
2136 |
lineToGo notNil ifTrue:[ |
|
2137 |
relative notNil ifTrue:[ |
|
2138 |
lineToGo := self currentLine + (lineToGo * relative) |
|
2139 |
]. |
|
2140 |
self gotoLine:lineToGo |
|
2141 |
] |
|
2142 |
] |
|
1380 | 2143 |
]. |
2144 |
||
1524
60582bfee9ce
allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
2145 |
"Modified: / 17.5.1998 / 20:07:59 / cg" |
248 | 2146 |
! |
2147 |
||
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2148 |
openSaveDialog |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2149 |
"Ask user for filename using a fileSelectionBox |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2150 |
and save contents into that file." |
248 | 2151 |
|
2695
7e13db2802df
better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents:
2693
diff
changeset
|
2152 |
Dialog |
4500 | 2153 |
requestSaveFileName:(resources string:'Save contents in:') |
2154 |
default:defaultFileNameForFileDialog |
|
2155 |
fromDirectory:directoryForFileDialog |
|
2156 |
action:[:fileName | self saveAs:fileName] |
|
2157 |
appendAction:[:fileName | self appendTo:fileName] |
|
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2158 |
! |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2159 |
|
4399 | 2160 |
openSearchBoxAndSearch |
4500 | 2161 |
"search for a string - show a box to enter searchpattern |
4399 | 2162 |
- currently no regular expressions are handled." |
2163 |
||
2164 |
" |
|
4985 | 2165 |
Q: is it a good idea to preserve the last searchstring between views? |
2166 |
cg: yes - turns out to be useful and less confusing than keeping last per view |
|
4399 | 2167 |
" |
2168 |
|searchBox patternHolder caseHolder matchHolder fwd ign match initialString |
|
4485 | 2169 |
bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder |
5077 | 2170 |
replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder |
2171 |
searchAtBeginOfLineOnlyHolder| |
|
4399 | 2172 |
|
2173 |
searchBarActionBlock notNil ifTrue:[ |
|
4864 | 2174 |
self resetVariablesBeforeNewSearch. |
2175 |
searchBarActionBlock value:#search value:self. |
|
2176 |
^ self |
|
4399 | 2177 |
]. |
2178 |
||
2179 |
modal := (UserPreferences current searchDialogIsModal). "/ thats experimental |
|
2180 |
||
4864 | 2181 |
ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true. |
4399 | 2182 |
caseHolder := ign not asValue. |
2183 |
||
2184 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
|
2185 |
matchHolder := match asValue. |
|
2186 |
searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2187 |
searchFullWordHolder := false asValue. |
5077 | 2188 |
searchAtBeginOfLineOnlyHolder := false asValue. |
4485 | 2189 |
replaceBooleanHolder := false asValue. |
2190 |
replaceTextHolder := '' asValue. |
|
2191 |
replaceBooleanEnabledHolder := self isReadOnly not asValue. |
|
4399 | 2192 |
|
2193 |
patternHolder := '' asValue. |
|
2194 |
||
2195 |
self setSearchPatternWithMatchEscapes: match. |
|
2196 |
||
2197 |
lastSearchPattern notNil ifTrue:[ |
|
4864 | 2198 |
initialString := lastSearchPattern. |
4399 | 2199 |
]. |
2200 |
"/ No longer force the current selection to be the initialString |
|
2201 |
"/ self hasSelectionWithinSingleLine ifTrue:[ |
|
2202 |
"/ initialString := self selection asString. |
|
2203 |
"/ ]. |
|
2204 |
initialString isNil ifTrue:[ |
|
4864 | 2205 |
LastSearchPatterns size > 0 ifTrue:[ |
2206 |
initialString := LastSearchPatterns first. |
|
2207 |
] |
|
4399 | 2208 |
]. |
2209 |
||
2210 |
initialString notNil ifTrue:[ |
|
4864 | 2211 |
patternHolder value:initialString. |
4399 | 2212 |
]. |
2213 |
||
4500 | 2214 |
fwd := true. |
4399 | 2215 |
|
2216 |
doSearch := [:fwd | |
|
4864 | 2217 |
|isVariableSearch pattern searchAction| |
2218 |
||
2219 |
self resetVariablesBeforeNewSearch. |
|
2220 |
||
2221 |
isVariableSearch := self searchVariableVisible |
|
2222 |
and:[searchVariableHolder value |
|
2223 |
and:[selectedVariable notNil]]. |
|
2224 |
||
2225 |
isVariableSearch ifTrue:[ |
|
2226 |
searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd]. |
|
2227 |
] ifFalse:[ |
|
2228 |
lastSearchWasVariableSearch := false. |
|
2229 |
LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not). |
|
2230 |
LastSearchWasMatch := lastSearchWasMatch := matchHolder value. |
|
2231 |
pattern := patternHolder value. |
|
2232 |
pattern notEmptyOrNil ifTrue:[ |
|
2233 |
searchAction := [ |
|
2234 |
self searchUsingSpec:( |
|
2235 |
ListView::SearchSpec new |
|
2236 |
pattern:pattern |
|
2237 |
ignoreCase:lastSearchIgnoredCase |
|
2238 |
match: lastSearchWasMatch |
|
2239 |
variable: searchVariableHolder value |
|
2240 |
fullWord: searchFullWordHolder value |
|
5077 | 2241 |
forward:fwd |
2242 |
atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value). |
|
4864 | 2243 |
] |
2244 |
] |
|
2245 |
]. |
|
2246 |
||
2247 |
replaceBooleanHolder value ifTrue:[ |
|
2248 |
|selStart| |
|
2249 |
||
2250 |
isVariableSearch ifTrue:[ |
|
2251 |
"/ must replace from the end towards beginning, |
|
2252 |
"/ because syntax-elements do not update their position, when |
|
2253 |
"/ the text is changed (in replace). |
|
2254 |
||
2255 |
selectedVariable := selectedVariable lastElementInChain. |
|
2256 |
self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop. |
|
2257 |
searchAction := [selectedVariable := selectedVariable previousElement. |
|
2258 |
selectedVariable notNil ifTrue:[ |
|
2259 |
self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop. |
|
2260 |
]. |
|
2261 |
"/ self searchVariableWithSyntaxElement:selectedVariable forward:false |
|
2262 |
]. |
|
2263 |
]. |
|
2264 |
||
2265 |
selStart := self characterPositionOfSelection. |
|
2266 |
self replace:(replaceTextHolder value). |
|
2267 |
||
2268 |
searchAction value. |
|
2269 |
[self characterPositionOfSelection ~= selStart] whileTrue:[ |
|
2270 |
selStart := self characterPositionOfSelection. |
|
2271 |
self replace:(replaceTextHolder value). |
|
2272 |
searchAction value. |
|
2273 |
] |
|
2274 |
] ifFalse:[ |
|
2275 |
searchAction value. |
|
2276 |
]. |
|
4399 | 2277 |
]. |
2278 |
||
2279 |
bindings := IdentityDictionary new. |
|
2280 |
bindings at:#searchPattern put:patternHolder. |
|
2281 |
modal ifTrue:[ |
|
4864 | 2282 |
bindings at:#nextAction put:[searchBox doAccept.]. |
2283 |
bindings at:#prevAction put:[fwd := false. searchBox doAccept.]. |
|
4399 | 2284 |
] ifFalse:[ |
4864 | 2285 |
bindings at:#nextAction put:[doSearch value:true. "searchBox doAccept."]. |
2286 |
bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."]. |
|
4399 | 2287 |
]. |
2288 |
bindings at:#caseSensitive put:caseHolder. |
|
2289 |
bindings at:#match put:matchHolder. |
|
2290 |
bindings at:#patternList put:LastSearchPatterns. |
|
2291 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2292 |
self supportsSyntaxElements ifFalse:[ |
4864 | 2293 |
bindings at:#searchVariableVisible put:false. |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2294 |
] ifTrue:[ |
4864 | 2295 |
bindings at:#searchVariableVisible put:true. |
2296 |
selectedVariable := self syntaxElementForSelectedVariable. |
|
2297 |
bindings at:#searchVariableEnabled put:(selectedVariable notNil). |
|
2298 |
selectedVariable notNil ifTrue:[ |
|
2299 |
bindings |
|
2300 |
at:#stringWithVariableUnderCursorHolder |
|
5280 | 2301 |
put:(resources string:'Variable ("%1")' with:selectedVariable name). |
4864 | 2302 |
searchVariableHolder value:true. |
2303 |
] ifFalse:[ |
|
2304 |
bindings |
|
2305 |
at:#stringWithVariableUnderCursorHolder |
|
5262 | 2306 |
put:(resources string:'Variable (none selected)'). |
4864 | 2307 |
]. |
4399 | 2308 |
]. |
2309 |
bindings at:#searchVariable put:searchVariableHolder. |
|
4485 | 2310 |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2311 |
bindings at:#searchFullWord put:searchFullWordHolder. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2312 |
bindings at:#searchFullWordEnabled put:true. |
5077 | 2313 |
bindings at:#searchAtBeginOfLineOnly put:searchAtBeginOfLineOnlyHolder. |
4399 | 2314 |
|
4485 | 2315 |
bindings at:#replaceEnabled put:replaceBooleanEnabledHolder. |
2316 |
bindings at:#replaceBoolean put:replaceBooleanHolder. |
|
2317 |
bindings at:#replaceTextHolder put:replaceTextHolder. |
|
5010 | 2318 |
replaceBooleanHolder onChangeEvaluate: |
2319 |
[ |
|
2320 |
replaceBooleanHolder value ifTrue:[ |
|
2321 |
(bldr componentAt:#ReplaceEntryField) requestFocus |
|
2322 |
] ifFalse:[ |
|
2323 |
(bldr componentAt:#patternComboBox) requestFocus |
|
2324 |
]. |
|
2325 |
]. |
|
4399 | 2326 |
modal ifTrue:[ |
4864 | 2327 |
searchBox := SimpleDialog new. |
4399 | 2328 |
] ifFalse:[ |
4864 | 2329 |
searchBox := ApplicationModel new. |
2330 |
searchBox createBuilder. |
|
4399 | 2331 |
]. |
2332 |
searchBox resources:(self resources). |
|
2333 |
||
2334 |
bldr := searchBox builder. |
|
2335 |
bldr addBindings:bindings. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2336 |
bldr aspectAt:#flyByHelpSpec put:(self class flyByHelpSpec). |
4399 | 2337 |
searchBox allButOpenFrom:(self class searchDialogSpec). |
2338 |
||
2339 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
2340 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
2341 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
2342 |
||
2343 |
modal ifTrue:[ |
|
4864 | 2344 |
searchBox openDialog. |
2345 |
searchBox accepted ifTrue:[ doSearch value:fwd ]. |
|
4399 | 2346 |
] ifFalse:[ |
4864 | 2347 |
(bldr componentAt:#nextButton) isReturnButton:false. |
2348 |
(bldr componentAt:#cancelButton) |
|
2349 |
label:(resources string:'Close'); |
|
2350 |
action:[searchBox closeRequest]. |
|
2351 |
"/ searchBox masterApplication:self application. |
|
2352 |
self topView beMaster. |
|
2353 |
searchBox window |
|
2354 |
beSlave; |
|
2355 |
openInGroup:(self windowGroup). |
|
2356 |
||
2357 |
"/ searchBox window open. |
|
5284 | 2358 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
4399 | 2359 |
] |
2360 |
||
2361 |
"Modified: / 11-07-2006 / 11:18:38 / fm" |
|
2362 |
"Created: / 08-03-2012 / 14:02:59 / cg" |
|
2363 |
! |
|
2364 |
||
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2365 |
save |
4500 | 2366 |
"save contents into a file |
2836
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2367 |
- ask user for filename using a fileSelectionBox." |
de07d386cfe8
allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2368 |
|
3201 | 2369 |
saveAction value |
248 | 2370 |
! |
2371 |
||
2372 |
saveAs:fileName |
|
5113 | 2373 |
"save the contents into a file named fileName. |
2374 |
On error return false otherwise return true" |
|
4500 | 2375 |
|
2488 | 2376 |
^ self saveAs:fileName doAppend:false |
2377 |
! |
|
2378 |
||
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2379 |
saveAs:aFilename doAppend:doAppend |
2488 | 2380 |
"save the contents into a file named fileName; |
5113 | 2381 |
if doAppend is true, the view's contents is appended to the existing |
2834 | 2382 |
contents - otherwise, it overwrites any previous file contents. |
5113 | 2383 |
On error return false otherwise return true" |
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2384 |
|
4534 | 2385 |
^ self saveAs:aFilename doAppend:doAppend compressTabs:true |
2386 |
! |
|
2387 |
||
2388 |
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs |
|
2389 |
"save the contents into a file named fileName; |
|
5113 | 2390 |
if doAppend is true, the view's contents is appended to the existing |
4534 | 2391 |
contents - otherwise, it overwrites any previous file contents. |
5113 | 2392 |
On error return false otherwise return true" |
2393 |
||
2394 |
^ self saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:nil |
|
2395 |
! |
|
2396 |
||
2397 |
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:eolMode |
|
2398 |
"save the contents into a file named fileName; |
|
2399 |
if doAppend is true, the view's contents is appended to the existing |
|
2400 |
contents - otherwise, it overwrites any previous file contents. |
|
2401 |
eolMode is one of #cr, #nl or #crlf. |
|
2402 |
On error return false otherwise return true." |
|
4534 | 2403 |
|
3426 | 2404 |
|filename msg| |
2701
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2405 |
|
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2406 |
filename := aFilename asFilename. |
b77cc7cf3818
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
2695
diff
changeset
|
2407 |
|
4437 | 2408 |
self withWriteCursorDo:[ |
4534 | 2409 |
|aStream| |
2410 |
||
2411 |
(FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[ |
|
2412 |
msg := resources |
|
2413 |
stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)' |
|
2414 |
with:filename name. |
|
2415 |
] ifTrue:[ |
|
2416 |
[ |
|
2417 |
doAppend ifTrue:[ |
|
2418 |
aStream := filename appendingWriteStream. |
|
2419 |
] ifFalse:[ |
|
2420 |
aStream := filename newReadWriteStream. |
|
2421 |
]. |
|
5113 | 2422 |
aStream eolMode:eolMode. |
4534 | 2423 |
self fileOutContentsOn:aStream compressTabs:compressTabs encoding:externalEncoding. |
4648 | 2424 |
aStream syncData; close. |
4534 | 2425 |
contentsWasSaved := true. |
2426 |
defaultFileNameForFileDialog := filename. |
|
2427 |
] on:FileStream openErrorSignal do:[:ex| |
|
2428 |
msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)' |
|
2429 |
with:filename name |
|
2430 |
with:FileStream lastErrorString. |
|
2431 |
]. |
|
2432 |
]. |
|
2834 | 2433 |
]. |
3426 | 2434 |
|
2435 |
msg notNil ifTrue:[ |
|
4534 | 2436 |
Dialog warn:msg. |
2437 |
^ false |
|
3426 | 2438 |
]. |
2834 | 2439 |
^ true |
916
4201c9c2a4f0
show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
2440 |
|
4437 | 2441 |
"Modified: / 27-07-2012 / 09:45:13 / cg" |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2442 |
! |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2443 |
|
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2444 |
search |
4500 | 2445 |
"search for a string - show a box to enter searchpattern |
1288
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2446 |
- currently no regular expressions are handled." |
19eee9e48131
added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
2447 |
|
4399 | 2448 |
self openSearchBoxAndSearch |
3318 | 2449 |
|
2450 |
"Modified: / 11-07-2006 / 11:18:38 / fm" |
|
4399 | 2451 |
"Modified: / 08-03-2012 / 14:03:10 / cg" |
3318 | 2452 |
! |
2453 |
||
4500 | 2454 |
search:patternArg ignoreCase:ign forward:fwd |
3577 | 2455 |
"search for a string without matching" |
2456 |
||
4500 | 2457 |
self search:patternArg ignoreCase:ign match: false forward:fwd |
3577 | 2458 |
! |
2459 |
||
4500 | 2460 |
search:patternArg ignoreCase:ign match: match forward:fwd |
3318 | 2461 |
|pattern| |
2462 |
||
2463 |
pattern := patternArg string. |
|
2464 |
pattern notEmpty ifTrue:[ |
|
4500 | 2465 |
self rememberSearchPattern:pattern. |
2466 |
"/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign. |
|
2467 |
"/ LastSearchWasMatch := match. |
|
2468 |
fwd ifFalse:[ |
|
2469 |
lastSearchDirection := #backward. |
|
2470 |
self searchBwd:pattern ignoreCase:ign match: match. " backward search with match is not yet available " |
|
2471 |
] ifTrue:[ |
|
2472 |
lastSearchDirection := #forward. |
|
2473 |
self searchFwd:pattern ignoreCase:ign match: match. |
|
2474 |
] |
|
3318 | 2475 |
] |
2476 |
||
2477 |
"Created: / 11-07-2006 / 11:18:04 / fm" |
|
4408 | 2478 |
"Modified: / 23-03-2012 / 12:12:07 / cg" |
4399 | 2479 |
! |
2480 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2481 |
searchUsingSpec:aSearchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2482 |
self rememberSearchPattern:(aSearchSpec pattern). |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2483 |
"/ LastSearchIgnoredCase := lastSearchIgnoredCase := ign. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2484 |
"/ LastSearchWasMatch := match. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2485 |
aSearchSpec forward ifFalse:[ |
4500 | 2486 |
lastSearchDirection := #backward. |
2487 |
self searchBwdUsingSpec:aSearchSpec |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2488 |
] ifTrue:[ |
4500 | 2489 |
lastSearchDirection := #forward. |
2490 |
self searchFwdUsingSpec:aSearchSpec |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2491 |
] |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2492 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2493 |
"Created: / 11-07-2006 / 11:18:04 / fm" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2494 |
"Modified: / 23-03-2012 / 12:12:07 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2495 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2496 |
|
4399 | 2497 |
searchVariableVisible |
2498 |
"search variable option in searchbox visible? |
|
2499 |
(only true for codeview2's textview)" |
|
2500 |
||
2501 |
^ false |
|
2502 |
||
2503 |
"Created: / 08-03-2012 / 14:01:24 / cg" |
|
2504 |
! |
|
2505 |
||
2506 |
searchVariableWithSyntaxElement:syntaxElementForVariable forward:fwd |
|
4485 | 2507 |
"this only works for CodeView2::TextView, which supports syntaxElements. |
2508 |
Finds the next occurrence of a syntax element (typically, a variable)" |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
2509 |
|
4409 | 2510 |
|el el2| |
4399 | 2511 |
|
2512 |
lastSearchWasVariableSearch := true. |
|
4500 | 2513 |
el := fwd |
2514 |
ifTrue:[syntaxElementForVariable nextElement] |
|
2515 |
ifFalse:[syntaxElementForVariable previousElement]. |
|
4399 | 2516 |
|
2517 |
el notNil ifTrue:[ |
|
4500 | 2518 |
"bug workaround" |
2519 |
(el start = syntaxElementForVariable start) ifTrue:[ |
|
2520 |
el2 := fwd |
|
2521 |
ifTrue:[el nextElement] |
|
2522 |
ifFalse:[el previousElement]. |
|
2523 |
el2 notNil ifTrue:[ |
|
2524 |
el := el2 |
|
2525 |
] |
|
2526 |
]. |
|
4399 | 2527 |
]. |
2528 |
el notNil ifTrue:[ |
|
4500 | 2529 |
self selectFromCharacterPosition:el start to:el stop. |
2530 |
self makeLineVisible:(self lineOfCharacterPosition:el start). |
|
4399 | 2531 |
] ifFalse:[ |
4500 | 2532 |
self showNotFound |
4399 | 2533 |
]. |
2534 |
||
2535 |
"Created: / 08-03-2012 / 14:08:20 / cg" |
|
2536 |
! |
|
2537 |
||
2538 |
syntaxElementForSelectedVariable |
|
2539 |
"for a better search; ignored here, but redefined in CodeView2" |
|
2540 |
||
2541 |
^ nil |
|
2542 |
||
2543 |
"Created: / 08-03-2012 / 14:20:27 / cg" |
|
2544 |
! |
|
2545 |
||
2546 |
syntaxElementForVariableUnderCursor |
|
2547 |
"for a better search; ignored here, but redefined in CodeView2" |
|
2548 |
||
2549 |
^ nil |
|
2550 |
||
2551 |
"Created: / 08-03-2012 / 12:45:26 / cg" |
|
248 | 2552 |
! ! |
2553 |
||
5120 | 2554 |
!TextView methodsFor:'native widget support'! |
2555 |
||
2556 |
nativeWindowType |
|
2557 |
"return a symbol describing my native window type |
|
2558 |
(may be used internally by the device as a native window creation hint)" |
|
2559 |
||
2560 |
^ #TextView |
|
2561 |
||
2562 |
"Created: 2.5.1997 / 14:41:00 / cg" |
|
2563 |
! ! |
|
2564 |
||
248 | 2565 |
!TextView methodsFor:'private'! |
2566 |
||
2596 | 2567 |
currentSelectionBgColor |
2568 |
^ selectionBgColor |
|
2569 |
! |
|
2570 |
||
2571 |
currentSelectionFgColor |
|
2572 |
^ selectionFgColor |
|
2573 |
! |
|
2574 |
||
248 | 2575 |
fileOutContentsOn:aStream |
2576 |
"save contents on a stream, replacing leading spaces by tab-characters." |
|
2577 |
||
4500 | 2578 |
self |
2579 |
fileOutContentsOn:aStream |
|
2580 |
compressTabs:true |
|
248 | 2581 |
! |
2582 |
||
2583 |
fileOutContentsOn:aStream compressTabs:compressTabs |
|
2584 |
"save contents on a stream. If compressTabs is true, |
|
2585 |
leading spaces will be replaced by tab-characters in the output." |
|
2586 |
||
4500 | 2587 |
self |
2588 |
fileOutContentsOn:aStream |
|
2589 |
compressTabs:compressTabs |
|
2590 |
encoding:nil |
|
1255
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2591 |
! |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2592 |
|
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2593 |
fileOutContentsOn:aStream compressTabs:compressTabs encoding:encodingSymOrNil |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2594 |
"save contents on a stream. If compressTabs is true, |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2595 |
leading spaces will be replaced by tab-characters in the output." |
c1bf6a3dbb78
allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2596 |
|
2877 | 2597 |
|startNr nLines string encoder| |
2598 |
||
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2599 |
self removeTrailingWhitespace. |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2600 |
|
2877 | 2601 |
encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil. |
4455
febe97112d50
changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents:
4450
diff
changeset
|
2602 |
encoder isNullEncoder ifTrue:[ |
4534 | 2603 |
(list contains:[:lineOrNil| |
2604 |
|s| |
|
2605 |
lineOrNil notNil |
|
2606 |
and:[(s := lineOrNil string string) isWideString |
|
2607 |
and:[s asSingleByteStringIfPossible isWideString]] |
|
2608 |
] |
|
2609 |
) ifTrue:[ |
|
2610 |
(Dialog confirm:'The text contains non-8bit characters. Encode as UTF8?') ifFalse:[ |
|
2611 |
^ self |
|
2612 |
] |
|
2613 |
]. |
|
2614 |
encoder := CharacterEncoder encoderToEncodeFrom:#unicode into:#utf8 |
|
4455
febe97112d50
changed: #fileOutContentsOn:compressTabs:encoding:
Claus Gittinger <cg@exept.de>
parents:
4450
diff
changeset
|
2615 |
]. |
2916 | 2616 |
|
758 | 2617 |
aStream isFileStream ifTrue:[ |
4534 | 2618 |
"on some systems, writing linewise is very slow (via NFS) |
2619 |
therefore we convert to a string and write it in big chunks. |
|
2620 |
To avoid creating huge strings, we do it in blocks of 1000 lines, |
|
2621 |
limiting temporary string creation to about 50-80k. |
|
2622 |
" |
|
2623 |
startNr := 1. |
|
2624 |
nLines := list size. |
|
5113 | 2625 |
(aStream eolMode notNil |
2626 |
and:[aStream eolMode ~= #nl]) ifTrue:[ |
|
2627 |
"/ must do it lineWise ... |
|
2628 |
list do:[:line | |
|
2629 |
line notNil ifTrue:[ |
|
5326 | 2630 |
encoder encodeString:line withTabs on:aStream |
5113 | 2631 |
]. |
2632 |
aStream cr |
|
2633 |
]. |
|
2634 |
] ifFalse:[ |
|
2635 |
[startNr <= nLines] whileTrue:[ |
|
2636 |
string := list |
|
2637 |
asStringWithCRsFrom:startNr |
|
2638 |
to:((startNr + 1000) min:nLines) |
|
2639 |
compressTabs:compressTabs. |
|
5326 | 2640 |
encoder encodeString:string string on:aStream. |
5113 | 2641 |
startNr := startNr + 1000 + 1. |
2642 |
]. |
|
4534 | 2643 |
]. |
758 | 2644 |
] ifFalse:[ |
4534 | 2645 |
list do:[:aLine | |
2646 |
aLine notNil ifTrue:[ |
|
5326 | 2647 |
encoder encodeString:aLine on:aStream. |
2648 |
]. |
|
2649 |
aStream cr. |
|
4534 | 2650 |
] |
758 | 2651 |
] |
248 | 2652 |
|
758 | 2653 |
"Modified: 8.6.1996 / 11:50:46 / cg" |
248 | 2654 |
! |
2655 |
||
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2656 |
getFontParameters |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2657 |
"get some info of the used font. They are cached since we use them often .. |
4779 | 2658 |
This is redefined here, to use the font's maxHeight/maxAscent for |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2659 |
line separation. This is required, to allow for proper handling of |
4779 | 2660 |
national characters, such as A-diaresis ..." |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2661 |
|
4569 | 2662 |
|italicFont boldFont fA iA bA| |
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
2663 |
|
1987 | 2664 |
font := font onDevice:device. |
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
2665 |
italicFont := font asItalic onDevice:device. |
3304
bd0991615b04
When computing font parameters, now consider the bold font, too.
Stefan Vogel <sv@exept.de>
parents:
3298
diff
changeset
|
2666 |
boldFont := font asBold onDevice:device. |
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
2667 |
|
4779 | 2668 |
fontHeight := font height max:(italicFont height max:(boldFont height)). |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2669 |
includesNonStrings == true ifTrue:[ |
4569 | 2670 |
"/ for now, we do not support variable height entries ... |
4779 | 2671 |
fontHeight := fontHeight max:(list first heightOn:self). |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2672 |
]. |
4579 | 2673 |
fontHeight := fontHeight + lineSpacing. |
2674 |
fA := font ascent. |
|
2675 |
"/ fA := font maxAscent. |
|
2676 |
iA := italicFont ascent. |
|
2677 |
"/ iA := italicFont maxAscent. |
|
2678 |
bA := boldFont ascent. |
|
2679 |
"/ bA := boldFont maxAscent. |
|
4569 | 2680 |
fontAscent := fA max:(iA max:bA). |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2681 |
fontWidth := font width. |
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
2682 |
fontIsFixedWidth := font isFixedWidth and:[ italicFont isFixedWidth and:[ boldFont isFixedWidth ]]. |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2683 |
|
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2684 |
"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
|
2685 |
"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
|
2686 |
! |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2687 |
|
5374 | 2688 |
highlightLineSpacing |
2689 |
"true if the spacing between lines is to be drawn with selected color, |
|
2690 |
false if it remains white. |
|
2691 |
false for selection in list views; true for edit/text views" |
|
2692 |
||
2693 |
^ true |
|
2694 |
! |
|
2695 |
||
3605 | 2696 |
isClosingParenthesis:ch |
2697 |
((parenthesisSpecification at:#close) includes:ch) ifTrue:[^ true]. |
|
4368 | 2698 |
^ ')]}' includes:ch |
2699 |
||
2700 |
"Modified: / 12-02-2012 / 08:37:01 / cg" |
|
3605 | 2701 |
! |
2702 |
||
2703 |
isOpeningParenthesis:ch |
|
2704 |
((parenthesisSpecification at:#open) includes:ch) ifTrue:[^ true]. |
|
4368 | 2705 |
^ '([{' includes:ch |
2706 |
||
2707 |
"Modified: / 12-02-2012 / 08:37:11 / cg" |
|
3605 | 2708 |
! |
2709 |
||
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2710 |
rememberSearchPattern:pattern |
2691 | 2711 |
|nRemembered patternString| |
2712 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
2713 |
self clearSearchAction. |
2813
ec8e83691849
forget searchAction, when a new pattern-search is done
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
2714 |
|
2691 | 2715 |
patternString := pattern string. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2716 |
|
3270
e3ed37e15f9d
oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents:
3258
diff
changeset
|
2717 |
nRemembered := NumRememberedSearchPatterns ? 20. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2718 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2719 |
LastSearchPatterns isNil ifTrue:[ |
4500 | 2720 |
LastSearchPatterns := OrderedCollection new. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2721 |
]. |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2722 |
"/ move to top or addFirst |
4409 | 2723 |
(LastSearchPatterns includes:patternString) ifTrue:[ |
4500 | 2724 |
LastSearchPatterns remove:patternString. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2725 |
] ifFalse:[ |
4500 | 2726 |
LastSearchPatterns size > nRemembered ifTrue:[ |
2727 |
LastSearchPatterns removeLast |
|
2728 |
] |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2729 |
]. |
4409 | 2730 |
LastSearchPatterns addFirst:patternString. |
2731 |
||
2732 |
"Modified: / 23-03-2012 / 13:59:09 / cg" |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2733 |
! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2734 |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2735 |
removeTrailingWhitespace |
3001 | 2736 |
list isNil ifTrue:[^self]. |
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2737 |
list keysAndValuesDo:[:lineNR :line | |
4500 | 2738 |
|l| |
2739 |
||
2740 |
line notNil ifTrue:[ |
|
2741 |
l := line withoutTrailingSeparators. |
|
2742 |
list at:lineNR put:l. |
|
2743 |
] |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2744 |
]. |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2745 |
! |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2746 |
|
4009 | 2747 |
resetVariablesBeforeNewSearch |
2748 |
"clear the autosearch action, when the first pattern is searched for" |
|
2749 |
||
2750 |
searchAction := nil. |
|
2751 |
! |
|
2752 |
||
248 | 2753 |
scrollSelectDown |
2754 |
"auto scroll action; scroll and reinstall timed-block" |
|
2755 |
||
2756 |
|prevEndLine| |
|
2757 |
||
2758 |
"just to make certain ..." |
|
2759 |
selectionEndLine isNil ifTrue:[^ self]. |
|
2760 |
||
2761 |
self scrollDown. |
|
2762 |
||
2763 |
"make new selection immediately visible" |
|
2764 |
prevEndLine := selectionEndLine. |
|
2765 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
2766 |
selectionEndCol := 0. |
|
2767 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
5235 | 2768 |
self redrawLine:lineNr |
248 | 2769 |
]. |
5235 | 2770 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2771 |
self selectionChanged. |
248 | 2772 |
! |
2773 |
||
2774 |
scrollSelectLeft |
|
2775 |
"auto scroll action; scroll and reinstall timed-block" |
|
2776 |
||
2777 |
|prevStartLine| |
|
2778 |
||
2779 |
"just to make certain ..." |
|
2780 |
selectionStartLine isNil ifTrue:[^ self]. |
|
2781 |
selectionStartCol isNil ifTrue:[^ self]. |
|
2782 |
||
2783 |
"make new selection immediately visible" |
|
2784 |
prevStartLine := selectionStartLine. |
|
2785 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
2786 |
self scrollLeft. |
|
2787 |
||
5236 | 2788 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2789 |
self selectionChanged. |
248 | 2790 |
! |
2791 |
||
2792 |
scrollSelectRight |
|
2793 |
"auto scroll action; scroll and reinstall timed-block" |
|
2794 |
||
4156 | 2795 |
|prevEndCol firstVisibleCol endLine| |
248 | 2796 |
|
2797 |
"just to make certain ..." |
|
2798 |
selectionEndCol isNil ifTrue:[^ self]. |
|
4169 | 2799 |
selectionEndLine isNil ifTrue:[^ self]. |
248 | 2800 |
|
2801 |
prevEndCol := selectionEndCol. |
|
4156 | 2802 |
selectionEndCol := (selectionEndCol + 1) min:(self listAt:selectionEndLine) size. |
2803 |
||
2804 |
endLine := self listLineToVisibleLine:selectionEndLine. |
|
2805 |
endLine notNil ifTrue:[ |
|
5236 | 2806 |
firstVisibleCol := self colOfX:1 inVisibleLine:endLine. |
2807 |
selectionEndCol < firstVisibleCol ifTrue:[ |
|
2808 |
"/ scrolling faster than selection advances... |
|
2809 |
selectionEndCol := firstVisibleCol |
|
2810 |
]. |
|
4156 | 2811 |
]. |
2812 |
||
2813 |
self selectionChanged. |
|
248 | 2814 |
self scrollRight. |
4156 | 2815 |
"/ self repairDamage. |
248 | 2816 |
|
5236 | 2817 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4156 | 2818 |
|
2819 |
"Modified: / 05-08-2010 / 21:25:56 / cg" |
|
248 | 2820 |
! |
2821 |
||
2822 |
scrollSelectUp |
|
2823 |
"auto scroll action; scroll and reinstall timed-block" |
|
2824 |
||
2825 |
|prevStartLine| |
|
2826 |
||
2827 |
"just to make certain ..." |
|
2828 |
selectionStartLine isNil ifTrue:[^ self]. |
|
2829 |
||
2830 |
self scrollUp. |
|
2831 |
||
2832 |
"make new selection immediately visible" |
|
2833 |
prevStartLine := selectionStartLine. |
|
2834 |
selectionStartLine := firstLineShown. |
|
2835 |
selectionStartCol := 1. |
|
2836 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
5236 | 2837 |
self redrawLine:lineNr |
248 | 2838 |
]. |
5236 | 2839 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2840 |
self selectionChanged. |
248 | 2841 |
! |
2842 |
||
2843 |
stopScrollSelect |
|
2844 |
"stop auto scroll; deinstall timed-block" |
|
2845 |
||
2846 |
autoScrollBlock notNil ifTrue:[ |
|
4500 | 2847 |
Processor removeTimedBlock:autoScrollBlock. |
2848 |
self compressMotionEvents:true. |
|
2849 |
autoScrollBlock := nil. |
|
2850 |
autoScrollDeltaT := nil |
|
248 | 2851 |
] |
2852 |
! |
|
2853 |
||
5120 | 2854 |
textChanged |
2855 |
self isNativeWidget ifTrue:[ |
|
2856 |
drawableId notNil ifTrue:[ |
|
2857 |
device changeText:self contents in:drawableId |
|
2858 |
] |
|
2859 |
]. |
|
2860 |
super textChanged |
|
2861 |
! |
|
2862 |
||
248 | 2863 |
widthForScrollBetween:firstLine and:lastLine |
2864 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
2865 |
||
2866 |
selectionStartLine notNil ifTrue:[ |
|
4500 | 2867 |
"/ if there is a selection which covers multiple lines, |
2868 |
"/ we have to scroll the whole width (to include the selection-rectangle) |
|
2869 |
||
2870 |
(lastLine < selectionStartLine) ifFalse:[ |
|
2871 |
(firstLine > selectionEndLine) ifFalse:[ |
|
2872 |
^ width |
|
2873 |
] |
|
2874 |
]. |
|
248 | 2875 |
]. |
2876 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
2877 |
! ! |
|
2878 |
||
997 | 2879 |
!TextView methodsFor:'queries'! |
2880 |
||
4063 | 2881 |
hasSearchActionSelection |
2882 |
"Here we fake the use of typeOfSelection which is really in EditTextView" |
|
2883 |
||
2884 |
^ false |
|
2885 |
! |
|
2886 |
||
997 | 2887 |
specClass |
1380 | 2888 |
"redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)" |
2889 |
||
997 | 2890 |
self class == TextView ifTrue:[^ TextEditorSpec]. |
1046 | 2891 |
^ super specClass |
997 | 2892 |
|
1380 | 2893 |
"Modified: / 31.10.1997 / 19:48:35 / cg" |
997 | 2894 |
! ! |
2895 |
||
248 | 2896 |
!TextView methodsFor:'redrawing'! |
2897 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2898 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2899 |
"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
|
2900 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2901 |
(leftMargin ~~ 0) ifTrue:[ |
4602 | 2902 |
viewOrigin x <= margin ifTrue:[ |
2903 |
self paint:color. |
|
2904 |
self fillRectangleX:margin-viewOrigin x |
|
4667 | 2905 |
y:(self yOfVisibleLine:visLine)- (lineSpacing//2) |
4602 | 2906 |
width:leftMargin |
2907 |
height:fontHeight |
|
2908 |
] |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2909 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2910 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2911 |
"Created: 6.3.1996 / 14:22:55 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2912 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2913 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2914 |
drawSelectedFromVisibleLine:startVisLineNr to:endVisLineNr |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2915 |
startVisLineNr to:endVisLineNr do:[:visLine | |
4500 | 2916 |
self drawVisibleLineSelected:visLine |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2917 |
] |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2918 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2919 |
|
4500 | 2920 |
drawVisibleLineSelected:visLineNr |
2921 |
self |
|
2922 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2923 |
inVisible:visLineNr |
|
2924 |
with:self currentSelectionFgColor and:self currentSelectionBgColor |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2925 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2926 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2927 |
drawVisibleLineSelected:visLineNr col:col |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2928 |
self |
4500 | 2929 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
2930 |
inVisible:visLineNr |
|
2931 |
col:col |
|
2932 |
with:self currentSelectionFgColor and:self currentSelectionBgColor |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2933 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2934 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2935 |
drawVisibleLineSelected:visLineNr from:selectionStartCol |
4500 | 2936 |
self |
2937 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2938 |
inVisible:visLineNr |
|
2939 |
from:selectionStartCol |
|
2940 |
with:self currentSelectionFgColor and:self currentSelectionBgColor. |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2941 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2942 |
|
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
2943 |
drawVisibleLineSelected:visLineNr from:startCol to:endCol |
4500 | 2944 |
self |
2945 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2946 |
inVisible:visLineNr |
|
2947 |
from:startCol to:endCol |
|
2948 |
with:self currentSelectionFgColor and:self currentSelectionBgColor. |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2949 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2950 |
|
248 | 2951 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
2952 |
"redraw a visible line range" |
|
2953 |
||
2954 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
2955 |
||
2956 |
shown ifFalse:[^ self]. |
|
2957 |
||
2958 |
end := endVisLineNr. |
|
2959 |
(end > nLinesShown) ifTrue:[ |
|
4500 | 2960 |
end := nLinesShown |
248 | 2961 |
]. |
2962 |
||
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
2963 |
selectionEndLine isNil ifTrue:[ |
4500 | 2964 |
selectionStartLine := nil |
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
2965 |
]. |
2735 | 2966 |
|
248 | 2967 |
selectionStartLine isNil ifTrue:[ |
4500 | 2968 |
specialCare := false |
248 | 2969 |
] ifFalse:[ |
4500 | 2970 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
2971 |
(startLine > selectionEndLine) ifTrue:[ |
|
2972 |
specialCare := false |
|
2973 |
] ifFalse:[ |
|
2974 |
endLine := self visibleLineToAbsoluteLine:end. |
|
2975 |
(endLine < selectionStartLine) ifTrue:[ |
|
2976 |
specialCare := false |
|
2977 |
] ifFalse:[ |
|
2978 |
specialCare := true |
|
2979 |
] |
|
2980 |
] |
|
248 | 2981 |
]. |
2982 |
||
2983 |
"easy: nothing is selected" |
|
2984 |
specialCare ifFalse:[ |
|
4500 | 2985 |
super redrawFromVisibleLine:startVisLineNr to:end. |
2986 |
^ self |
|
248 | 2987 |
]. |
2988 |
||
2989 |
"easy: all is selected" |
|
2990 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
4500 | 2991 |
self drawSelectedFromVisibleLine:startVisLineNr to:end. |
2992 |
^ self |
|
248 | 2993 |
]. |
2994 |
||
2995 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
4500 | 2996 |
"draw unselected top part" |
2997 |
||
2998 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
2999 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
3000 |
||
3001 |
"and first partial selected line" |
|
3002 |
self redrawVisibleLine:selVisStart. |
|
3003 |
||
3004 |
"rest starts after this one" |
|
3005 |
line1 := selVisStart + 1 |
|
248 | 3006 |
] ifFalse:[ |
4500 | 3007 |
line1 := 1 |
248 | 3008 |
]. |
3009 |
||
3010 |
(line1 > end) ifTrue:[^ self]. |
|
3011 |
(line1 < startVisLineNr) ifTrue:[ |
|
4500 | 3012 |
line1 := startVisLineNr |
248 | 3013 |
]. |
3014 |
||
3015 |
"draw middle part of selection" |
|
3016 |
||
3017 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
4500 | 3018 |
line2 := nLinesShown |
248 | 3019 |
] ifFalse:[ |
4500 | 3020 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
248 | 3021 |
]. |
3022 |
(line2 > end) ifTrue:[ |
|
4500 | 3023 |
line2 := end |
248 | 3024 |
]. |
3025 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3026 |
self drawSelectedFromVisibleLine:line1 to:line2. |
248 | 3027 |
|
3028 |
(line2 >= end) ifTrue:[^ self]. |
|
3029 |
||
3030 |
"last line of selection" |
|
3031 |
self redrawVisibleLine:(line2 + 1). |
|
3032 |
||
3033 |
((line2 + 2) <= end) ifTrue:[ |
|
4500 | 3034 |
super redrawFromVisibleLine:(line2 + 2) to:end |
248 | 3035 |
] |
3036 |
! |
|
3037 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3038 |
redrawVisibleLine:visLineNr |
248 | 3039 |
"redraw visible line lineNr" |
3040 |
||
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
3041 |
|line| |
248 | 3042 |
|
4528 | 3043 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3044 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
3045 |
line := self visibleLineToAbsoluteLine:visLineNr. |
|
3046 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3047 |
(line == selectionStartLine) ifTrue:[ |
|
3048 |
(line == selectionEndLine) ifTrue:[ |
|
3049 |
"it's part-of-single-line selection" |
|
3050 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3051 |
(selectionStartCol > 1) ifTrue:[ |
|
3052 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3053 |
]. |
|
3054 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol. |
|
3055 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3056 |
^ self |
|
3057 |
]. |
|
3058 |
||
3059 |
"it's the first line of a multi-line selection" |
|
3060 |
(selectionStartCol ~~ 1) ifTrue:[ |
|
3061 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3062 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3063 |
] ifFalse:[ |
|
3064 |
viewOrigin x == 0 ifTrue:[ |
|
3065 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3066 |
] |
|
3067 |
]. |
|
3068 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol. |
|
3069 |
^ self |
|
3070 |
]. |
|
3071 |
||
3072 |
(line == selectionEndLine) ifTrue:[ |
|
3073 |
"it's the last line of a multi-line selection" |
|
3074 |
(selectionEndCol == 0) ifTrue:[ |
|
3075 |
^ super redrawVisibleLine:visLineNr |
|
3076 |
]. |
|
3077 |
||
3078 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3079 |
self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol. |
|
3080 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3081 |
^ self |
|
3082 |
]. |
|
3083 |
||
3084 |
"it's a full line in a multi-line selection" |
|
3085 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3086 |
self drawVisibleLineSelected:visLineNr. |
|
3087 |
^ self |
|
3088 |
] |
|
248 | 3089 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3090 |
super redrawVisibleLine:visLineNr |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3091 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3092 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 3093 |
! |
3094 |
||
3095 |
redrawVisibleLine:visLine col:col |
|
633 | 3096 |
"redraw single character at col in visible line lineNr." |
248 | 3097 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3098 |
|line| |
633 | 3099 |
|
3100 |
"/ |
|
3101 |
"/ care for selection |
|
3102 |
"/ |
|
4528 | 3103 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3104 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
3105 |
line := self visibleLineToAbsoluteLine:visLine. |
|
3106 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3107 |
((line == selectionStartLine) |
|
3108 |
and: [col < selectionStartCol]) ifFalse:[ |
|
3109 |
((line == selectionEndLine) |
|
3110 |
and: [col > selectionEndCol]) ifFalse:[ |
|
3111 |
"its in the selection" |
|
3112 |
self drawVisibleLineSelected:visLine col:col. |
|
3113 |
^ self. |
|
3114 |
] |
|
3115 |
] |
|
3116 |
] |
|
248 | 3117 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3118 |
self drawVisibleLine:visLine col:col with:fgColor and:bgColor |
1496 | 3119 |
|
3120 |
"Modified: / 22.4.1998 / 08:53:05 / cg" |
|
248 | 3121 |
! |
3122 |
||
3123 |
redrawVisibleLine:visLine from:startCol |
|
3124 |
"redraw visible line lineNr from startCol to end of line" |
|
3125 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3126 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3127 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3128 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3129 |
col == 0 ifTrue:[ |
4500 | 3130 |
col := 1. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3131 |
]. |
248 | 3132 |
|
2778
223915a2d6a4
kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
3133 |
(selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[ |
4500 | 3134 |
line := self visibleLineToAbsoluteLine:visLine. |
3135 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3136 |
((line == selectionStartLine) |
|
3137 |
or:[line == selectionEndLine]) ifTrue:[ |
|
3138 |
"since I'm lazy, redraw full line" |
|
3139 |
self redrawVisibleLine:visLine. |
|
3140 |
^ self |
|
3141 |
]. |
|
3142 |
"the line is fully within the selection" |
|
3143 |
self drawVisibleLineSelected:visLine from:col. |
|
3144 |
^ self |
|
3145 |
] |
|
248 | 3146 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3147 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3148 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3149 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 3150 |
! |
3151 |
||
3152 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
3153 |
"redraw visible line lineNr from startCol to endCol" |
|
3154 |
||
3155 |
|line allOut allIn leftCol rightCol| |
|
3156 |
||
3157 |
line := self visibleLineToAbsoluteLine:visLine. |
|
3158 |
||
3159 |
allIn := false. |
|
3160 |
allOut := false. |
|
4528 | 3161 |
(selectionStartLine isNil or:[selectionEndLine isNil |
3162 |
or:[selectionStartCol isNil or:[selectionEndCol isNil]]]) ifTrue:[ |
|
3163 |
allOut := true |
|
248 | 3164 |
] ifFalse:[ |
4528 | 3165 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
3166 |
allOut := true |
|
3167 |
] ifTrue:[ |
|
3168 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
3169 |
((endCol < selectionStartCol) |
|
3170 |
or:[startCol > selectionEndCol]) ifTrue:[ |
|
3171 |
allOut := true |
|
3172 |
] ifFalse:[ |
|
3173 |
((startCol >= selectionStartCol) |
|
3174 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
|
3175 |
allIn := true |
|
3176 |
] |
|
3177 |
] |
|
3178 |
] ifFalse:[ |
|
3179 |
(line == selectionStartLine) ifTrue:[ |
|
3180 |
(endCol < selectionStartCol) ifTrue:[ |
|
3181 |
allOut := true |
|
3182 |
] ifFalse:[ |
|
3183 |
(startCol >= selectionStartCol) ifTrue:[ |
|
3184 |
allIn := true |
|
3185 |
] |
|
3186 |
] |
|
3187 |
] ifFalse:[ |
|
3188 |
(line == selectionEndLine) ifTrue:[ |
|
3189 |
(startCol > selectionEndCol) ifTrue:[ |
|
3190 |
allOut := true |
|
3191 |
] ifFalse:[ |
|
3192 |
(endCol <= selectionEndCol) ifTrue:[ |
|
3193 |
allIn := true |
|
3194 |
] |
|
3195 |
] |
|
3196 |
] ifFalse:[ |
|
3197 |
allIn := true |
|
3198 |
] |
|
3199 |
] |
|
3200 |
] |
|
3201 |
] |
|
248 | 3202 |
]. |
3203 |
allOut ifTrue:[ |
|
4528 | 3204 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
3205 |
^ self |
|
248 | 3206 |
]. |
3207 |
||
3208 |
allIn ifTrue:[ |
|
4528 | 3209 |
self drawVisibleLineSelected:visLine from:startCol to:endCol |
248 | 3210 |
] ifFalse:[ |
4528 | 3211 |
"redraw part before selection" |
3212 |
((line == selectionStartLine) |
|
3213 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
|
3214 |
super redrawVisibleLine:visLine from:startCol |
|
3215 |
to:(selectionStartCol - 1). |
|
3216 |
leftCol := selectionStartCol |
|
3217 |
] ifFalse:[ |
|
3218 |
leftCol := startCol |
|
3219 |
]. |
|
3220 |
"redraw selected part" |
|
3221 |
(selectionEndLine > line) ifTrue:[ |
|
3222 |
rightCol := endCol |
|
3223 |
] ifFalse:[ |
|
3224 |
rightCol := selectionEndCol min:endCol |
|
3225 |
]. |
|
3226 |
self drawVisibleLineSelected:visLine from:leftCol to:rightCol. |
|
3227 |
||
3228 |
"redraw part after selection" |
|
3229 |
(rightCol < endCol) ifTrue:[ |
|
3230 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
|
3231 |
] |
|
248 | 3232 |
]. |
3233 |
||
3234 |
"special care for first and last line of selection: |
|
3235 |
must handle margin also" |
|
3236 |
||
3237 |
((line == selectionEndLine) |
|
3238 |
and:[(startCol == 1) |
|
3239 |
and:[selectionStartLine < selectionEndLine]]) |
|
3240 |
ifTrue:[ |
|
4528 | 3241 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
248 | 3242 |
]. |
3243 |
||
3244 |
((line == selectionStartLine) |
|
3245 |
and:[(startCol == 1) |
|
3246 |
and:[selectionStartLine < selectionEndLine]]) |
|
3247 |
ifTrue:[ |
|
4528 | 3248 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
4602 | 3249 |
]. |
3250 |
||
3251 |
((line > selectionStartLine) |
|
3252 |
and:[(startCol == 1) |
|
3253 |
and:[selectionStartLine < selectionEndLine |
|
3254 |
and:[line < selectionEndLine]]]) |
|
3255 |
ifTrue:[ |
|
3256 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
|
248 | 3257 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3258 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3259 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 3260 |
! ! |
3261 |
||
3262 |
!TextView methodsFor:'searching'! |
|
3263 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3264 |
clearSearchAction |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3265 |
searchAction := nil. |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3266 |
! |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3267 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3268 |
scanFor:aCharacter fromLine:startLine col:startCol forward:forward |
4500 | 3269 |
ifFound:foundBlock |
3270 |
ifNotFound:notFoundBlock |
|
3271 |
"search for a character in the direction given by forward. |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3272 |
Performs foundBlock with line/col as argument if found, notFoundBlock if not." |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3273 |
|
4500 | 3274 |
|lineString |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3275 |
line "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3276 |
col "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3277 |
delta "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3278 |
endCol "{ Class: SmallInteger }" |
4500 | 3279 |
cc |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3280 |
maxLine "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3281 |
| |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3282 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3283 |
col := startCol. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3284 |
line := startLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3285 |
forward ifTrue:[ |
4500 | 3286 |
delta := 1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3287 |
] ifFalse:[ |
4500 | 3288 |
delta := -1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3289 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3290 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3291 |
lineString := list at:line. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3292 |
maxLine := list size. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3293 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3294 |
col := col + delta. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3295 |
[true] whileTrue:[ |
4500 | 3296 |
lineString notNil ifTrue:[ |
3297 |
forward ifTrue:[ |
|
3298 |
endCol := lineString size. |
|
3299 |
] ifFalse:[ |
|
3300 |
endCol := 1 |
|
3301 |
]. |
|
3302 |
||
3303 |
col to:endCol by:delta do:[:rCol | |
|
3304 |
cc := lineString at:rCol. |
|
3305 |
cc == aCharacter ifTrue:[ |
|
3306 |
^ foundBlock value:line value:rCol. |
|
3307 |
] |
|
3308 |
]. |
|
3309 |
]. |
|
3310 |
line := line + delta. |
|
3311 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
|
3312 |
^ notFoundBlock value |
|
3313 |
]. |
|
3314 |
lineString := list at:line. |
|
3315 |
forward ifTrue:[ |
|
3316 |
col := 1 |
|
3317 |
] ifFalse:[ |
|
3318 |
col := lineString size |
|
3319 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3320 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3321 |
"not reached" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3322 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3323 |
"Modified: 15.10.1996 / 12:22:30 / cg" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3324 |
"Created: 11.9.1997 / 04:36:29 / cg" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3325 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3326 |
|
3802 | 3327 |
searchAction |
3328 |
^ searchAction |
|
3329 |
! |
|
3330 |
||
2807 | 3331 |
searchAction:aSearcherOrSearchBlock |
3332 |
searchAction := aSearcherOrSearchBlock |
|
3333 |
! |
|
3334 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3335 |
searchAgainInSameDirection |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3336 |
"search again in the same direction and -if found- position cursor" |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3337 |
|
3577 | 3338 |
|ign match| |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3339 |
|
3981 | 3340 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 3341 |
searchBarActionBlock value:#forward value:self. |
3342 |
^ self |
|
3581 | 3343 |
]. |
3344 |
||
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3345 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 3346 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
3347 |
||
3348 |
self setSearchPatternWithMatchEscapes: match. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3349 |
lastSearchPattern notNil ifTrue:[ |
4500 | 3350 |
lastSearchDirection == #backward ifTrue:[ |
3351 |
self |
|
3352 |
searchBwd:lastSearchPattern |
|
3353 |
ignoreCase:ign |
|
3354 |
match: match |
|
3355 |
] ifFalse:[ |
|
3356 |
self |
|
3357 |
searchFwd:lastSearchPattern |
|
3358 |
ignoreCase:ign |
|
3359 |
match: match |
|
3360 |
] |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3361 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3362 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3363 |
"Created: / 03-05-1999 / 15:02:16 / cg" |
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3364 |
"Modified: / 21-09-2006 / 16:47:57 / cg" |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3365 |
! |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3366 |
|
248 | 3367 |
searchBwd |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3368 |
"search backward (for the same thing again) |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3369 |
If found, position cursor" |
248 | 3370 |
|
4399 | 3371 |
|ign selectedVariable| |
1353 | 3372 |
|
2811 | 3373 |
searchAction notNil ifTrue:[ |
4500 | 3374 |
"/autosearch is cleared whenever there is search with user selection |
3375 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4178 | 3376 |
]. |
3377 |
||
3378 |
searchAction notNil ifTrue:[ |
|
4500 | 3379 |
"/confusing: this is for autosearch of variables (browse variable uses, for example) |
3380 |
self searchUsingSearchAction:#backward. |
|
3381 |
^ self. |
|
2807 | 3382 |
]. |
3981 | 3383 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 3384 |
searchBarActionBlock value:#backward value:self. |
3385 |
^ self |
|
3581 | 3386 |
]. |
4399 | 3387 |
lastSearchWasVariableSearch ifTrue:[ |
4500 | 3388 |
selectedVariable := self syntaxElementForSelectedVariable. |
3389 |
selectedVariable notNil ifTrue:[ |
|
3390 |
self searchVariableWithSyntaxElement:selectedVariable forward:false. |
|
3391 |
^ self. |
|
3392 |
]. |
|
3393 |
lastSearchWasVariableSearch := false. |
|
4399 | 3394 |
]. |
2807 | 3395 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3396 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
1353 | 3397 |
|
3577 | 3398 |
self setSearchPatternWithMatchEscapes: false. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3399 |
lastSearchPattern isNil ifTrue:[ |
4500 | 3400 |
LastSearchPatterns size > 0 ifTrue:[ |
3401 |
lastSearchPattern := LastSearchPatterns first |
|
3402 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3403 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3404 |
|
1326 | 3405 |
lastSearchPattern notNil ifTrue:[ |
4500 | 3406 |
lastSearchDirection := #backward. |
3407 |
self rememberSearchPattern:lastSearchPattern. |
|
3408 |
self |
|
3409 |
searchBwd:lastSearchPattern |
|
3410 |
ignoreCase:ign |
|
248 | 3411 |
] |
1326 | 3412 |
|
4399 | 3413 |
"Modified: / 08-03-2012 / 14:26:25 / cg" |
248 | 3414 |
! |
3415 |
||
3416 |
searchBwd:pattern |
|
3417 |
"do a backward search" |
|
3418 |
||
3419 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3420 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3421 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3422 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3423 |
"Modified: / 21-09-2006 / 16:48:29 / cg" |
248 | 3424 |
! |
3425 |
||
3426 |
searchBwd:pattern ifAbsent:aBlock |
|
3427 |
"do a backward search" |
|
3428 |
||
4500 | 3429 |
self |
3430 |
searchBwdUsingSpec:(ListView::SearchSpec new |
|
3431 |
pattern:pattern) |
|
3432 |
ifAbsent:aBlock |
|
1326 | 3433 |
|
3434 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
3435 |
! |
|
3436 |
||
3437 |
searchBwd:pattern ignoreCase:ign |
|
3438 |
"do a backward search" |
|
3439 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3440 |
self |
4500 | 3441 |
searchBwd:pattern |
3442 |
ignoreCase:ign |
|
3443 |
ifAbsent:[ |
|
3444 |
self sensor compressKeyPressEventsWithKey:#FindPrev. |
|
3445 |
self showNotFound |
|
3446 |
]. |
|
4408 | 3447 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3448 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3449 |
|
4408 | 3450 |
"Created: / 13-09-1997 / 06:18:00 / cg" |
3451 |
"Modified: / 23-03-2012 / 12:10:25 / cg" |
|
1326 | 3452 |
! |
3453 |
||
3454 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
3455 |
"do a backward search" |
|
3456 |
||
4500 | 3457 |
self |
3458 |
searchBwdUsingSpec:(ListView::SearchSpec new |
|
3459 |
pattern:pattern |
|
3460 |
ignoreCase:ign) |
|
3461 |
ifAbsent:aBlock |
|
1326 | 3462 |
|
3463 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
3464 |
"Created: 13.9.1997 / 06:18:41 / cg" |
|
248 | 3465 |
! |
3466 |
||
3577 | 3467 |
searchBwd:pattern ignoreCase:ign match: match |
3468 |
"do a backward search. |
|
3469 |
match pattern functionality is not yet available for backward search" |
|
3470 |
||
4408 | 3471 |
"/ lastSearchWasMatch := match. |
3577 | 3472 |
self searchBwd:pattern ignoreCase:ign. |
4408 | 3473 |
|
3474 |
"Modified: / 23-03-2012 / 12:12:44 / cg" |
|
3577 | 3475 |
! |
3476 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3477 |
searchBwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3478 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3479 |
|
4500 | 3480 |
self |
3481 |
searchBwdUsingSpec:searchSpec |
|
3482 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3483 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3484 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3485 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3486 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3487 |
"Modified: / 21-09-2006 / 16:48:29 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3488 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3489 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3490 |
searchBwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3491 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3492 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3493 |
|pos startLine startCol| |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3494 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3495 |
pos := self startPositionForSearchBackward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3496 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3497 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3498 |
|
4500 | 3499 |
self |
3500 |
searchBackwardUsingSpec:searchSpec |
|
3501 |
startingAtLine:startLine col:startCol |
|
3502 |
ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col] |
|
3503 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3504 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3505 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3506 |
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3507 |
"select characters enclosed by matching parenthesis if one is under startLine/Col" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3508 |
|
4500 | 3509 |
self |
3510 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
3511 |
ifFound:[:line :col | |
|
3512 |
self selectFromLine:startLine col:startCol |
|
3513 |
toLine:line col:col] |
|
3514 |
ifNotFound:[self showNotFound] |
|
3515 |
onError:[self beep] |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3516 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3517 |
"Modified: 9.10.1997 / 12:57:34 / cg" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3518 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3519 |
|
248 | 3520 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4500 | 3521 |
ifFound:foundBlock |
3522 |
ifNotFound:notFoundBlock |
|
3523 |
onError:failBlock |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3524 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3525 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
248 | 3526 |
Search for the corresponding character is done forward if its an opening, |
3527 |
backwards if its a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3528 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3529 |
If there is a nesting error, evaluate failBlock." |
248 | 3530 |
|
3531 |
^ self |
|
4500 | 3532 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3533 |
ifFound:foundBlock |
|
3534 |
ifNotFound:notFoundBlock |
|
3535 |
onError:failBlock |
|
3536 |
ignoring:(parenthesisSpecification at:#ignore ifAbsent:#()) "/ #( $' $" '$[' '$]' '${' '$)' ) |
|
3478 | 3537 |
|
3538 |
"Modified: / 12-04-2007 / 11:24:24 / cg" |
|
248 | 3539 |
! |
3540 |
||
3541 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
4500 | 3542 |
ifFound:foundBlock |
3543 |
ifNotFound:notFoundBlock |
|
3544 |
onError:failBlock |
|
3545 |
ignoring:ignoreSet |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3546 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3547 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
248 | 3548 |
Search for the corresponding character is done forward if its an opening, |
3549 |
backwards if its a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3550 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3551 |
If there is a nesting error, evaluate failBlock." |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3552 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3553 |
^ self |
4500 | 3554 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3555 |
ifFound:foundBlock |
|
3556 |
ifNotFound:notFoundBlock |
|
3557 |
onError:failBlock |
|
3558 |
openingCharacters: (parenthesisSpecification at:#open) "/ #( $( $[ ${ "$> $<") |
|
3559 |
closingCharacters: (parenthesisSpecification at:#close) "/ #( $) $] $} "$> $<") |
|
3560 |
ignoredCharacters: ignoreSet |
|
3561 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/ |
|
3562 |
||
3563 |
"/ |i direction lineString |
|
3564 |
"/ parChar charSet closingChar |
|
3565 |
"/ ignoring |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3566 |
"/ line "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3567 |
"/ col "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3568 |
"/ delta "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3569 |
"/ endCol "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3570 |
"/ runCol "{ Class: SmallInteger }" |
4500 | 3571 |
"/ cc prevCC nextCC incSet decSet |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3572 |
"/ nesting "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3573 |
"/ maxLine "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3574 |
"/ ign skip anySet| |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3575 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3576 |
"/ charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3577 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3578 |
"/ parChar := self characterAtLine:startLine col:startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3579 |
"/ i := charSet indexOf:parChar. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3580 |
"/ i == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3581 |
"/ ^ failBlock value "not a parenthesis" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3582 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3583 |
"/ direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3584 |
"/ closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3585 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3586 |
"/ col := startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3587 |
"/ line := startLine. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3588 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3589 |
"/ delta := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3590 |
"/ incSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3591 |
"/ decSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3592 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3593 |
"/ delta := -1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3594 |
"/ incSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3595 |
"/ decSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3596 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3597 |
"/ anySet := Set new. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3598 |
"/ anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3599 |
"/ anySet := (anySet select:[:c | c isCharacter]) asString. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3600 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3601 |
"/ nesting := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3602 |
"/ ignoring := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3603 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3604 |
"/ maxLine := list size. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3605 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3606 |
"/ col := col + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3607 |
"/ [nesting ~~ 0] whileTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3608 |
"/ (lineString notNil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3609 |
"/ and:[lineString includesAny:anySet]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3610 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3611 |
"/ endCol := lineString size. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3612 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3613 |
"/ endCol := 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3614 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3615 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3616 |
"/ col to:endCol by:delta do:[:rCol | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3617 |
"/ runCol := rCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3618 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3619 |
"/ cc := lineString at:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3620 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3621 |
"/ nextCC := lineString at:runCol+1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3622 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3623 |
"/ nextCC := nil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3624 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3625 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3626 |
"/ prevCC := lineString at:runCol-1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3627 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3628 |
"/ prevCC := nil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3629 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3630 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3631 |
"/ ign := skip := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3632 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3633 |
"/ "/ check for comments. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3634 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3635 |
"/ ((cc == $" and:[nextCC == $/]) |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3636 |
"/ or:[prevCC == $$ ]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3637 |
"/ "/ do nothing |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3638 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3639 |
"/ skip := true. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3640 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3641 |
"/ ignoreSet do:[:ignore | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3642 |
"/ ignore == cc ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3643 |
"/ ign := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3644 |
"/ ] ifFalse:[ |
4500 | 3645 |
"/ ignore isString ifTrue:[ |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3646 |
"/ cc == (ignore at:2) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3647 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3648 |
"/ (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3649 |
"/ skip := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3650 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3651 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3652 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3653 |
"/ cc == (ignore at:1) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3654 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3655 |
"/ (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3656 |
"/ skip := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3657 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3658 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3659 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3660 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3661 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3662 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3663 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3664 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3665 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3666 |
"/ ign ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3667 |
"/ ignoring := ignoring not |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3668 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3669 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3670 |
"/ ignoring ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3671 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3672 |
"/ (incSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3673 |
"/ nesting := nesting + 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3674 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3675 |
"/ (decSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3676 |
"/ nesting := nesting - 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3677 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3678 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3679 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3680 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3681 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3682 |
"/ nesting == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3683 |
"/ "check if legal" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3684 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3685 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3686 |
"/ cc == closingChar ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3687 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3688 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3689 |
"/ ^ foundBlock value:line value:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3690 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3691 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3692 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3693 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3694 |
"/ line := line + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3695 |
"/ (line < 1 or:[line > maxLine]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3696 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3697 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3698 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3699 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3700 |
"/ col := 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3701 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3702 |
"/ col := lineString size |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3703 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3704 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3705 |
"/ ^ notFoundBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3706 |
|
3478 | 3707 |
"Modified: / 12-04-2007 / 11:25:36 / cg" |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3708 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3709 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3710 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4500 | 3711 |
ifFound:foundBlock |
3712 |
ifNotFound:notFoundBlock |
|
3713 |
onError:failBlock |
|
3714 |
openingCharacters:openingCharacters |
|
3715 |
closingCharacters:closingCharacters |
|
3605 | 3716 |
|
3717 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
|
3718 |
Search for the corresponding character is done forward if its an opening, |
|
3719 |
backwards if its a closing parenthesis. |
|
3720 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
|
3721 |
If there is a nesting error, evaluate failBlock." |
|
3722 |
||
3723 |
^ self |
|
4500 | 3724 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3725 |
ifFound:foundBlock |
|
3726 |
ifNotFound:notFoundBlock |
|
3727 |
onError:failBlock |
|
3728 |
openingCharacters: openingCharacters |
|
3729 |
closingCharacters: closingCharacters |
|
3730 |
ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#()) |
|
3731 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/ |
|
3732 |
||
3733 |
"/ |i direction lineString |
|
3734 |
"/ parChar charSet closingChar |
|
3735 |
"/ ignoring |
|
3605 | 3736 |
"/ line "{ Class: SmallInteger }" |
3737 |
"/ col "{ Class: SmallInteger }" |
|
3738 |
"/ delta "{ Class: SmallInteger }" |
|
3739 |
"/ endCol "{ Class: SmallInteger }" |
|
3740 |
"/ runCol "{ Class: SmallInteger }" |
|
4500 | 3741 |
"/ cc prevCC nextCC incSet decSet |
3605 | 3742 |
"/ nesting "{ Class: SmallInteger }" |
3743 |
"/ maxLine "{ Class: SmallInteger }" |
|
3744 |
"/ ign skip anySet| |
|
3745 |
"/ |
|
3746 |
"/ charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
|
3747 |
"/ |
|
3748 |
"/ parChar := self characterAtLine:startLine col:startCol. |
|
3749 |
"/ i := charSet indexOf:parChar. |
|
3750 |
"/ i == 0 ifTrue:[ |
|
3751 |
"/ ^ failBlock value "not a parenthesis" |
|
3752 |
"/ ]. |
|
3753 |
"/ direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
|
3754 |
"/ closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
|
3755 |
"/ |
|
3756 |
"/ col := startCol. |
|
3757 |
"/ line := startLine. |
|
3758 |
"/ direction == #fwd ifTrue:[ |
|
3759 |
"/ delta := 1. |
|
3760 |
"/ incSet := #( $( $[ ${ "$<" ). |
|
3761 |
"/ decSet := #( $) $] $} "$>" ). |
|
3762 |
"/ ] ifFalse:[ |
|
3763 |
"/ delta := -1. |
|
3764 |
"/ incSet := #( $) $] $} "$>" ). |
|
3765 |
"/ decSet := #( $( $[ ${ "$<" ). |
|
3766 |
"/ ]. |
|
3767 |
"/ anySet := Set new. |
|
3768 |
"/ anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
3769 |
"/ anySet := (anySet select:[:c | c isCharacter]) asString. |
|
3770 |
"/ |
|
3771 |
"/ nesting := 1. |
|
3772 |
"/ ignoring := false. |
|
3773 |
"/ lineString := list at:line. |
|
3774 |
"/ maxLine := list size. |
|
3775 |
"/ |
|
3776 |
"/ col := col + delta. |
|
3777 |
"/ [nesting ~~ 0] whileTrue:[ |
|
3778 |
"/ (lineString notNil |
|
3779 |
"/ and:[lineString includesAny:anySet]) ifTrue:[ |
|
3780 |
"/ direction == #fwd ifTrue:[ |
|
3781 |
"/ endCol := lineString size. |
|
3782 |
"/ ] ifFalse:[ |
|
3783 |
"/ endCol := 1 |
|
3784 |
"/ ]. |
|
3785 |
"/ |
|
3786 |
"/ col to:endCol by:delta do:[:rCol | |
|
3787 |
"/ runCol := rCol. |
|
3788 |
"/ |
|
3789 |
"/ cc := lineString at:runCol. |
|
3790 |
"/ runCol < lineString size ifTrue:[ |
|
3791 |
"/ nextCC := lineString at:runCol+1 |
|
3792 |
"/ ] ifFalse:[ |
|
3793 |
"/ nextCC := nil |
|
3794 |
"/ ]. |
|
3795 |
"/ runCol > 1 ifTrue:[ |
|
3796 |
"/ prevCC := lineString at:runCol-1 |
|
3797 |
"/ ] ifFalse:[ |
|
3798 |
"/ prevCC := nil |
|
3799 |
"/ ]. |
|
3800 |
"/ |
|
3801 |
"/ ign := skip := false. |
|
3802 |
"/ |
|
3803 |
"/ "/ check for comments. |
|
3804 |
"/ |
|
3805 |
"/ ((cc == $" and:[nextCC == $/]) |
|
3806 |
"/ or:[prevCC == $$ ]) ifTrue:[ |
|
3807 |
"/ "/ do nothing |
|
3808 |
"/ |
|
3809 |
"/ skip := true. |
|
3810 |
"/ ] ifFalse:[ |
|
3811 |
"/ ignoreSet do:[:ignore | |
|
3812 |
"/ ignore == cc ifTrue:[ |
|
3813 |
"/ ign := true |
|
3814 |
"/ ] ifFalse:[ |
|
4500 | 3815 |
"/ ignore isString ifTrue:[ |
3605 | 3816 |
"/ cc == (ignore at:2) ifTrue:[ |
3817 |
"/ runCol > 1 ifTrue:[ |
|
3818 |
"/ (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
|
3819 |
"/ skip := true |
|
3820 |
"/ ] |
|
3821 |
"/ ] |
|
3822 |
"/ ] ifFalse:[ |
|
3823 |
"/ cc == (ignore at:1) ifTrue:[ |
|
3824 |
"/ runCol < lineString size ifTrue:[ |
|
3825 |
"/ (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
|
3826 |
"/ skip := true |
|
3827 |
"/ ] |
|
3828 |
"/ ] |
|
3829 |
"/ ] |
|
3830 |
"/ ] |
|
3831 |
"/ ] |
|
3832 |
"/ ] |
|
3833 |
"/ ] |
|
3834 |
"/ ]. |
|
3835 |
"/ |
|
3836 |
"/ ign ifTrue:[ |
|
3837 |
"/ ignoring := ignoring not |
|
3838 |
"/ ]. |
|
3839 |
"/ |
|
3840 |
"/ ignoring ifFalse:[ |
|
3841 |
"/ skip ifFalse:[ |
|
3842 |
"/ (incSet includes:cc) ifTrue:[ |
|
3843 |
"/ nesting := nesting + 1 |
|
3844 |
"/ ] ifFalse:[ |
|
3845 |
"/ (decSet includes:cc) ifTrue:[ |
|
3846 |
"/ nesting := nesting - 1 |
|
3847 |
"/ ] |
|
3848 |
"/ ] |
|
3849 |
"/ ] |
|
3850 |
"/ ]. |
|
3851 |
"/ |
|
3852 |
"/ nesting == 0 ifTrue:[ |
|
3853 |
"/ "check if legal" |
|
3854 |
"/ |
|
3855 |
"/ skip ifFalse:[ |
|
3856 |
"/ cc == closingChar ifFalse:[ |
|
3857 |
"/ ^ failBlock value |
|
3858 |
"/ ]. |
|
3859 |
"/ ^ foundBlock value:line value:runCol. |
|
3860 |
"/ ] |
|
3861 |
"/ ] |
|
3862 |
"/ ]. |
|
3863 |
"/ ]. |
|
3864 |
"/ line := line + delta. |
|
3865 |
"/ (line < 1 or:[line > maxLine]) ifTrue:[ |
|
3866 |
"/ ^ failBlock value |
|
3867 |
"/ ]. |
|
3868 |
"/ lineString := list at:line. |
|
3869 |
"/ direction == #fwd ifTrue:[ |
|
3870 |
"/ col := 1 |
|
3871 |
"/ ] ifFalse:[ |
|
3872 |
"/ col := lineString size |
|
3873 |
"/ ] |
|
3874 |
"/ ]. |
|
3875 |
"/ ^ notFoundBlock value |
|
3876 |
||
3877 |
"Modified: / 12-04-2007 / 11:25:36 / cg" |
|
3878 |
! |
|
3879 |
||
3880 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
4500 | 3881 |
ifFound:foundBlock |
3882 |
ifNotFound:notFoundBlock |
|
3883 |
onError:failBlock |
|
3884 |
openingCharacters:openingCharacters |
|
3885 |
closingCharacters:closingCharacters |
|
3886 |
ignoredCharacters:ignoreSet |
|
3887 |
specialEOLComment:eolCommentSequence |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3888 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3889 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3890 |
Search for the corresponding character is done forward if its an opening, |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3891 |
backwards if its a closing parenthesis. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3892 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3893 |
If there is a nesting error, evaluate failBlock." |
248 | 3894 |
|
4500 | 3895 |
|i direction lineString |
3896 |
parChar charSet closingChar |
|
3897 |
ignoring |
|
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3898 |
line "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3899 |
col "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3900 |
delta "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3901 |
endCol "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3902 |
runCol "{ Class: SmallInteger }" |
4500 | 3903 |
cc prevCC nextCC incSet decSet |
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3904 |
nesting "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3905 |
maxLine "{ Class: SmallInteger }" |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3906 |
ign skip anySet |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3907 |
eol1 eol2| |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3908 |
|
2772
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
3909 |
self assert:(openingCharacters size == closingCharacters size). |
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
3910 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3911 |
charSet := openingCharacters , closingCharacters. |
248 | 3912 |
|
3913 |
parChar := self characterAtLine:startLine col:startCol. |
|
3914 |
i := charSet indexOf:parChar. |
|
3915 |
i == 0 ifTrue:[ |
|
4500 | 3916 |
^ failBlock value "not a parenthesis" |
248 | 3917 |
]. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3918 |
|
3858 | 3919 |
direction := (i <= openingCharacters size) ifTrue:[#fwd] ifFalse:[#bwd]. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3920 |
closingChar := (closingCharacters , openingCharacters) at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3921 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3922 |
eol1 := eolCommentSequence at:1 ifAbsent:nil. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3923 |
eol2 := eolCommentSequence at:2 ifAbsent:nil. |
248 | 3924 |
|
3925 |
col := startCol. |
|
3926 |
line := startLine. |
|
3927 |
direction == #fwd ifTrue:[ |
|
4500 | 3928 |
delta := 1. |
3929 |
incSet := openingCharacters. |
|
3930 |
decSet := closingCharacters. |
|
248 | 3931 |
] ifFalse:[ |
4500 | 3932 |
delta := -1. |
3933 |
incSet := closingCharacters. |
|
3934 |
decSet := openingCharacters. |
|
248 | 3935 |
]. |
1454 | 3936 |
anySet := Set new. |
3937 |
anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
3938 |
anySet := (anySet select:[:c | c isCharacter]) asString. |
|
248 | 3939 |
|
3940 |
nesting := 1. |
|
3941 |
ignoring := false. |
|
3942 |
lineString := list at:line. |
|
3943 |
maxLine := list size. |
|
3944 |
||
3945 |
col := col + delta. |
|
3946 |
[nesting ~~ 0] whileTrue:[ |
|
4500 | 3947 |
(lineString notNil |
3948 |
and:[lineString includesAny:anySet]) ifTrue:[ |
|
3949 |
direction == #fwd ifTrue:[ |
|
3950 |
endCol := lineString size. |
|
3951 |
] ifFalse:[ |
|
3952 |
endCol := 1 |
|
3953 |
]. |
|
3954 |
||
3955 |
col to:endCol by:delta do:[:rCol | |
|
3956 |
runCol := rCol. |
|
3957 |
||
3958 |
cc := lineString at:runCol. |
|
3959 |
runCol < lineString size ifTrue:[ |
|
3960 |
nextCC := lineString at:runCol+1 |
|
3961 |
] ifFalse:[ |
|
3962 |
nextCC := nil |
|
3963 |
]. |
|
3964 |
runCol > 1 ifTrue:[ |
|
3965 |
prevCC := lineString at:runCol-1 |
|
3966 |
] ifFalse:[ |
|
3967 |
prevCC := nil |
|
3968 |
]. |
|
3969 |
||
3970 |
ign := skip := false. |
|
3971 |
||
3972 |
"/ check for comments. |
|
3973 |
||
3974 |
((cc == eol1 and:[nextCC == eol2]) |
|
3975 |
or:[prevCC == $$ ]) ifTrue:[ |
|
3976 |
"/ do nothing |
|
3977 |
||
3978 |
skip := true. |
|
3979 |
] ifFalse:[ |
|
3980 |
ignoreSet do:[:ignore | |
|
3981 |
ignore == cc ifTrue:[ |
|
3982 |
ign := true |
|
3983 |
] ifFalse:[ |
|
3984 |
ignore isString ifTrue:[ |
|
3985 |
cc == (ignore at:2) ifTrue:[ |
|
3986 |
runCol > 1 ifTrue:[ |
|
3987 |
(lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
|
3988 |
skip := true |
|
3989 |
] |
|
3990 |
] |
|
3991 |
] ifFalse:[ |
|
3992 |
cc == (ignore at:1) ifTrue:[ |
|
3993 |
runCol < lineString size ifTrue:[ |
|
3994 |
(lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
|
3995 |
skip := true |
|
3996 |
] |
|
3997 |
] |
|
3998 |
] |
|
3999 |
] |
|
4000 |
] |
|
4001 |
] |
|
4002 |
] |
|
4003 |
]. |
|
4004 |
||
4005 |
ign ifTrue:[ |
|
4006 |
ignoring := ignoring not |
|
4007 |
]. |
|
4008 |
||
4009 |
ignoring ifFalse:[ |
|
4010 |
skip ifFalse:[ |
|
4011 |
(incSet includes:cc) ifTrue:[ |
|
4012 |
nesting := nesting + 1 |
|
4013 |
] ifFalse:[ |
|
4014 |
(decSet includes:cc) ifTrue:[ |
|
4015 |
nesting := nesting - 1 |
|
4016 |
] |
|
4017 |
] |
|
4018 |
] |
|
4019 |
]. |
|
4020 |
||
4021 |
nesting == 0 ifTrue:[ |
|
4022 |
"check if legal" |
|
4023 |
skip ifFalse:[ |
|
4024 |
cc == closingChar ifFalse:[ |
|
4025 |
^ failBlock value |
|
4026 |
]. |
|
4027 |
^ foundBlock value:line value:runCol. |
|
4028 |
] |
|
4029 |
] |
|
4030 |
]. |
|
4031 |
]. |
|
4032 |
line := line + delta. |
|
4033 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
|
4034 |
^ failBlock value |
|
4035 |
]. |
|
4036 |
lineString := list at:line. |
|
4037 |
direction == #fwd ifTrue:[ |
|
4038 |
col := 1 |
|
4039 |
] ifFalse:[ |
|
4040 |
col := lineString size |
|
4041 |
] |
|
248 | 4042 |
]. |
4043 |
^ notFoundBlock value |
|
4044 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
4045 |
"Modified: 15.10.1996 / 12:22:30 / cg" |
248 | 4046 |
! |
4047 |
||
4048 |
searchFwd |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4049 |
"search forward for the same pattern or selection again" |
248 | 4050 |
|
4399 | 4051 |
|ign match variable| |
1353 | 4052 |
|
2811 | 4053 |
searchAction notNil ifTrue:[ |
4500 | 4054 |
"/ autosearch is cleared whenever there is search with user selection |
4055 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4177 | 4056 |
]. |
4057 |
||
4058 |
searchAction notNil ifTrue:[ |
|
4500 | 4059 |
"/ confusing: this is for autosearch of variables (browse variable uses, for example) |
4060 |
self searchUsingSearchAction:#forward. |
|
4061 |
^ self. |
|
2807 | 4062 |
]. |
3981 | 4063 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 4064 |
searchBarActionBlock value:#forward value:self. |
4065 |
^ self |
|
3581 | 4066 |
]. |
4399 | 4067 |
lastSearchWasVariableSearch ifTrue:[ |
4500 | 4068 |
variable := self syntaxElementForSelectedVariable. |
4069 |
variable notNil ifTrue:[ |
|
4070 |
self searchVariableWithSyntaxElement:variable forward:true. |
|
4071 |
^ self. |
|
4072 |
]. |
|
4073 |
lastSearchWasVariableSearch := false. |
|
4399 | 4074 |
]. |
3581 | 4075 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4076 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 4077 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
1353 | 4078 |
|
248 | 4079 |
selectStyle == #wordLeft ifTrue:[ |
4500 | 4080 |
" |
4081 |
remove the space from the selection |
|
4082 |
" |
|
4083 |
selectionStartCol := selectionStartCol + 1. |
|
4084 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
|
4085 |
selectStyle := #word. |
|
4086 |
self selectionChanged. |
|
248 | 4087 |
]. |
3577 | 4088 |
self setSearchPatternWithMatchEscapes: match. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4089 |
|
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4090 |
lastSearchPattern isNil ifTrue:[ |
4500 | 4091 |
LastSearchPatterns size > 0 ifTrue:[ |
4092 |
lastSearchPattern := LastSearchPatterns first |
|
4093 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4094 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4095 |
|
1326 | 4096 |
lastSearchPattern notNil ifTrue:[ |
4500 | 4097 |
self rememberSearchPattern:lastSearchPattern. |
4098 |
lastSearchDirection := #forward. |
|
4099 |
self |
|
4100 |
searchFwd:lastSearchPattern |
|
4101 |
ignoreCase:ign |
|
4102 |
match: match |
|
248 | 4103 |
] |
1326 | 4104 |
|
4399 | 4105 |
"Modified: / 08-03-2012 / 14:25:42 / cg" |
248 | 4106 |
! |
4107 |
||
4108 |
searchFwd:pattern |
|
4109 |
"do a forward search" |
|
4110 |
||
4111 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4112 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4113 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4114 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4115 |
"Modified: / 21-09-2006 / 16:52:04 / cg" |
248 | 4116 |
! |
4117 |
||
4118 |
searchFwd:pattern ifAbsent:aBlock |
|
4119 |
"do a forward search" |
|
4120 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4121 |
self |
4500 | 4122 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4123 |
pattern:pattern) |
|
4124 |
ifAbsent:aBlock |
|
1326 | 4125 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4126 |
"Modified: / 21-09-2006 / 16:51:28 / cg" |
1326 | 4127 |
! |
4128 |
||
4129 |
searchFwd:pattern ignoreCase:ign |
|
4130 |
"do a forward search" |
|
4131 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4132 |
self |
4500 | 4133 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4134 |
pattern:pattern |
|
4135 |
ignoreCase:ign) |
|
4136 |
ifAbsent:[ |
|
4137 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4138 |
self showNotFound |
|
4139 |
]. |
|
4408 | 4140 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4141 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4142 |
|
4408 | 4143 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4144 |
"Modified: / 23-03-2012 / 12:09:59 / cg" |
|
1326 | 4145 |
! |
4146 |
||
4147 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
4148 |
"do a forward search" |
|
4149 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4150 |
self |
4500 | 4151 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4152 |
pattern:pattern |
|
4153 |
ignoreCase:ign) |
|
4154 |
ifAbsent:aBlock |
|
1326 | 4155 |
|
4156 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4157 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
248 | 4158 |
! |
4159 |
||
3577 | 4160 |
searchFwd:pattern ignoreCase:ign match: match |
4161 |
"do a forward search" |
|
4162 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4163 |
self |
4500 | 4164 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4165 |
pattern:pattern |
|
4166 |
ignoreCase:ign |
|
4167 |
match:match) |
|
4168 |
ifAbsent:[ |
|
4169 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4170 |
self showNotFound |
|
4171 |
]. |
|
4408 | 4172 |
"/ lastSearchIgnoredCase := ign. |
4173 |
"/ lastSearchWasMatch := match. |
|
3577 | 4174 |
lastSearchPattern := pattern string |
4175 |
||
4408 | 4176 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4177 |
"Modified: / 23-03-2012 / 12:12:47 / cg" |
|
3577 | 4178 |
! |
4179 |
||
4180 |
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock |
|
4181 |
"do a forward search" |
|
4182 |
||
4500 | 4183 |
self |
4184 |
searchFwdUsingSpec:(ListView::SearchSpec new |
|
4185 |
pattern:pattern |
|
4186 |
ignoreCase:ign |
|
4187 |
match:match) |
|
4188 |
ifAbsent:aBlock |
|
3581 | 4189 |
|
4190 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4191 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
4192 |
! |
|
4193 |
||
4194 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
4195 |
"do a forward search" |
|
4196 |
||
4500 | 4197 |
self |
4198 |
searchFwdUsingSpec:(ListView::SearchSpec new |
|
4199 |
pattern:pattern |
|
4200 |
ignoreCase:ign |
|
4201 |
match:match) |
|
4202 |
startingAtLine:startLine col:startCol |
|
4203 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4204 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4205 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4206 |
searchFwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4207 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4208 |
|
4500 | 4209 |
self |
4210 |
searchFwdUsingSpec:searchSpec |
|
4211 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4212 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4213 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4214 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4215 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4216 |
"Modified: / 21-09-2006 / 16:52:04 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4217 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4218 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4219 |
searchFwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4220 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4221 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4222 |
|pos startLine startCol| |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4223 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4224 |
pos := self startPositionForSearchForward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4225 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4226 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4227 |
|
4500 | 4228 |
self |
4229 |
searchFwdUsingSpec:searchSpec |
|
4230 |
startingAtLine:startLine col:startCol |
|
4231 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4232 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4233 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4234 |
"Created: 13.9.1997 / 06:18:27 / cg" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4235 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4236 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4237 |
searchFwdUsingSpec:searchSpec startingAtLine:startLine col:startCol ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4238 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4239 |
|
4500 | 4240 |
self |
4241 |
searchForwardUsingSpec:searchSpec |
|
4242 |
startingAtLine:startLine col:startCol |
|
4243 |
ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col] |
|
4244 |
ifAbsent:aBlock |
|
3577 | 4245 |
! |
4246 |
||
248 | 4247 |
searchPattern |
4248 |
"return the last search pattern" |
|
4249 |
||
1326 | 4250 |
^ lastSearchPattern |
248 | 4251 |
! |
4252 |
||
2807 | 4253 |
searchUsingSearchAction:direction |
4500 | 4254 |
self |
4255 |
searchUsingSearchAction:direction |
|
4256 |
ifAbsent:[ |
|
4257 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4258 |
self showNotFound |
|
4259 |
] |
|
2816 | 4260 |
! |
4261 |
||
4262 |
searchUsingSearchAction:direction ifAbsent:notFoundAction |
|
2807 | 4263 |
|pos startLine startCol| |
4264 |
||
4500 | 4265 |
pos := direction == #backward |
4266 |
ifTrue:[self startPositionForSearchBackward] |
|
4267 |
ifFalse:[self startPositionForSearchForward]. |
|
2807 | 4268 |
startLine := pos y. |
4269 |
startCol := pos x. |
|
4270 |
||
4271 |
searchAction notNil ifTrue:[ |
|
4500 | 4272 |
searchAction |
4273 |
value:direction |
|
4274 |
value:startLine |
|
4275 |
value:startCol |
|
4276 |
value:[:line :col | self selectFromLine:line toLine:line] |
|
4277 |
value:notFoundAction. |
|
4278 |
self hasSelection ifTrue: [ |
|
4279 |
self changeTypeOfSelectionTo: #searchAction. |
|
4280 |
]. |
|
2807 | 4281 |
]. |
4282 |
! |
|
4283 |
||
248 | 4284 |
setSearchPattern |
4285 |
"set the searchpattern from the selection if there is one" |
|
4286 |
||
3577 | 4287 |
self setSearchPatternWithMatchEscapes: false. |
248 | 4288 |
! |
4289 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4290 |
setSearchPattern:aStringOrNil |
248 | 4291 |
"set the searchpattern for future searches" |
4292 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4293 |
aStringOrNil isEmptyOrNil ifTrue:[ |
5247 | 4294 |
lastSearchPattern := nil. |
248 | 4295 |
] ifFalse:[ |
5247 | 4296 |
"/ not withoutSeparators: may want to search for spaces... |
4297 |
lastSearchPattern := aStringOrNil asString "withoutSeparators" string. |
|
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4298 |
]. |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4299 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4300 |
"Modified: / 6.3.1999 / 23:47:36 / cg" |
248 | 4301 |
! |
4302 |
||
2200 | 4303 |
setSearchPattern:aString ignoreCase:aBoolean |
4304 |
"set the searchpattern and caseIgnore for future searches" |
|
4305 |
||
4306 |
self setSearchPattern:aString. |
|
4307 |
lastSearchIgnoredCase := aBoolean. |
|
4308 |
! |
|
4309 |
||
3577 | 4310 |
setSearchPatternWithMatchEscapes: match |
4311 |
"set the searchpattern from the selection if there is one" |
|
4312 |
||
4313 |
|sel searchPattern | |
|
4314 |
||
4315 |
"/ clickPos isNil ifTrue:[^ self]. |
|
4316 |
||
4317 |
sel := self selection. |
|
4318 |
sel notNil ifTrue:[ |
|
4500 | 4319 |
searchPattern := sel asString. |
4320 |
match ifTrue:[searchPattern := searchPattern withMatchEscapes]. |
|
4321 |
self setSearchPattern:searchPattern. |
|
3577 | 4322 |
] |
4323 |
||
4324 |
"Modified: / 6.3.1999 / 23:48:04 / cg" |
|
4325 |
! |
|
4326 |
||
248 | 4327 |
showMatch:pattern atLine:line col:col |
4328 |
"after a search, highlight the matched pattern. |
|
4329 |
The code below needs a rewrite to take care of match-characters |
|
4330 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4331 |
||
4120 | 4332 |
self showMatch:pattern isMatch:true atLine:line col:col |
4333 |
! |
|
4334 |
||
4335 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
|
4336 |
"after a search, highlight the matched pattern. |
|
4337 |
The code below needs a rewrite to take care of match-characters |
|
4338 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4339 |
||
248 | 4340 |
|realPattern| |
4341 |
||
4342 |
realPattern := pattern. |
|
4120 | 4343 |
|
4344 |
isMatch ifTrue: [ |
|
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4345 |
(realPattern startsWith:$*) ifTrue:[ |
5093 | 4346 |
realPattern := realPattern copyButFirst |
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4347 |
]. |
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4348 |
(realPattern endsWith:$*) ifTrue:[ |
5092 | 4349 |
realPattern := realPattern copyButLast |
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4350 |
]. |
248 | 4351 |
]. |
4352 |
||
4353 |
self selectFromLine:line col:col |
|
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4354 |
toLine:line col:(col + realPattern size - 1). |
248 | 4355 |
self makeLineVisible:line |
4356 |
! |
|
4357 |
||
4358 |
showNotFound |
|
4359 |
"search not found - tell user by beeping and changing |
|
4360 |
cursor for a while (sometimes I work with a headset :-) |
|
4361 |
(used to be: tell user by changing cursor for a while)" |
|
4362 |
||
5052 | 4363 |
self withCursor:(Cursor cross) do:[ |
4364 |
self beep. |
|
4365 |
Processor activeProcess millisecondDelay:200. |
|
1028 | 4366 |
] |
4367 |
||
4368 |
"Modified: 20.2.1997 / 12:49:27 / cg" |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4369 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4370 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4371 |
startPositionForSearchBackward |
2822 | 4372 |
^ self startPositionForSearchBackwardBasedOnSelection |
4373 |
! |
|
4374 |
||
4375 |
startPositionForSearchBackwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4376 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4377 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4378 |
selectionStartLine notNil ifTrue:[ |
4500 | 4379 |
startLine := selectionStartLine. |
4380 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4381 |
] ifFalse:[ |
4500 | 4382 |
startLine := 1. |
4383 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4384 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4385 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4386 |
^ startCol @ startLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4387 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4388 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4389 |
startPositionForSearchForward |
2822 | 4390 |
^ self startPositionForSearchForwardBasedOnSelection |
4391 |
! |
|
4392 |
||
4393 |
startPositionForSearchForwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4394 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4395 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4396 |
selectionStartLine notNil ifTrue:[ |
4500 | 4397 |
startLine := selectionStartLine. |
4398 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4399 |
] ifFalse:[ |
4500 | 4400 |
startLine := 1. |
4401 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4402 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4403 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4404 |
^ startCol @ startLine |
248 | 4405 |
! ! |
4406 |
||
4407 |
!TextView methodsFor:'selections'! |
|
4408 |
||
2604
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4409 |
changeTypeOfSelectionTo:newType |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4410 |
"ignored here - but redefined in subclasses which |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4411 |
differentiate between pasted- and user-selections" |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4412 |
! |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4413 |
|
458 | 4414 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4415 |
|l t| |
458 | 4416 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4417 |
selectionStartLine notNil ifTrue:[ |
4787 | 4418 |
expandingTop == true ifTrue:[ |
4419 |
l := selectionStartLine. |
|
4420 |
selectionStartLine := selectionStartLine + 1. |
|
4421 |
(selectionStartLine > clickLine |
|
4422 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
|
4423 |
ifTrue:[ |
|
4424 |
t := selectionStartLine. |
|
4425 |
selectionStartLine := selectionEndLine. |
|
4426 |
selectionEndLine := t. |
|
4427 |
t := selectionStartCol. |
|
4428 |
selectionStartCol := selectionEndCol. |
|
4429 |
selectionEndCol := t. |
|
4430 |
expandingTop := false |
|
4431 |
]. |
|
4432 |
] ifFalse:[ |
|
4433 |
l := selectionEndLine. |
|
4434 |
selectionEndLine := selectionEndLine + 1. |
|
4435 |
]. |
|
4500 | 4436 |
"/ self redrawLine:l. |
2442 | 4437 |
"/ self redrawLine:l+1. |
4787 | 4438 |
self validateNewSelection. |
4439 |
self setPrimarySelection. |
|
4440 |
self selectionChanged. |
|
4441 |
self redrawFromLine:l to:l+1. |
|
4442 |
self makeSelectionVisible. |
|
458 | 4443 |
]. |
4444 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4445 |
"Created: / 01-03-1996 / 23:35:08 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4446 |
"Modified: / 18-03-1996 / 17:18:15 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4447 |
"Modified: / 17-04-2012 / 21:01:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4448 |
! |
4449 |
||
4450 |
expandSelectionLeft |
|
502 | 4451 |
|c l t c1 c2| |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4452 |
|
458 | 4453 |
selectionStartLine notNil ifTrue:[ |
4787 | 4454 |
expandingTop == true ifTrue:[ |
4455 |
selectionStartCol == 0 ifTrue:[^ self]. |
|
4456 |
l := selectionStartLine. |
|
4457 |
selectionStartCol := (selectionStartCol - 1) max:1. |
|
4458 |
c := selectionStartCol. |
|
4459 |
] ifFalse:[ |
|
4460 |
l := selectionEndLine. |
|
4461 |
selectionEndCol := (selectionEndCol - 1) max:0. |
|
4462 |
c := selectionEndCol. |
|
4463 |
selectionEndLine == selectionStartLine ifTrue:[ |
|
4464 |
selectionEndCol <= selectionStartCol ifTrue:[ |
|
4465 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4466 |
selectionEndCol := t. |
|
4467 |
expandingTop := true. |
|
4468 |
c := selectionStartCol. |
|
4469 |
] |
|
4470 |
]. |
|
4471 |
]. |
|
4472 |
c1 := c. |
|
4473 |
c2 := c1 + 1. |
|
4474 |
c1 == 0 ifTrue:[ |
|
4475 |
c1 := 1 |
|
4476 |
]. |
|
4477 |
self validateNewSelection. |
|
4478 |
self setPrimarySelection. |
|
4479 |
self selectionChanged. |
|
4480 |
self redrawLine:l from:c1 to:c2. |
|
4481 |
self makeSelectionVisible. |
|
458 | 4482 |
]. |
4483 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4484 |
"Modified: / 18-03-1996 / 17:05:46 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4485 |
"Modified: / 17-04-2012 / 21:01:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4486 |
! |
4487 |
||
4488 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4489 |
|l c t| |
458 | 4490 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4491 |
selectionStartLine notNil ifTrue:[ |
4787 | 4492 |
expandingTop == true ifTrue:[ |
4493 |
l := selectionStartLine. |
|
4494 |
c := selectionStartCol. |
|
4495 |
selectionStartCol := selectionStartCol + 1. |
|
4496 |
l == selectionEndLine ifTrue:[ |
|
4497 |
c >= selectionEndCol ifTrue:[ |
|
4498 |
expandingTop := false. |
|
4499 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4500 |
selectionEndCol := t. |
|
4501 |
c := selectionStartCol. |
|
4502 |
] |
|
4503 |
] |
|
4504 |
] ifFalse:[ |
|
4505 |
l := selectionEndLine. |
|
4506 |
c := selectionEndCol. |
|
4507 |
selectionEndCol := selectionEndCol + 1. |
|
4508 |
]. |
|
4509 |
||
4510 |
self validateNewSelection. |
|
4511 |
self setPrimarySelection. |
|
4512 |
self selectionChanged. |
|
4804 | 4513 |
self redrawLine:l from:(c max:1) to:c+1. |
4787 | 4514 |
self makeSelectionVisible. |
458 | 4515 |
]. |
4516 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4517 |
"Created: / 01-03-1996 / 23:33:17 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4518 |
"Modified: / 06-03-1996 / 13:54:10 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4519 |
"Modified: / 17-04-2012 / 21:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4520 |
! |
4521 |
||
4522 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4523 |
|l t| |
458 | 4524 |
|
4525 |
selectionStartLine notNil ifTrue:[ |
|
4787 | 4526 |
expandingTop == true ifTrue:[ |
4527 |
selectionStartLine := (selectionStartLine - 1) max:1. |
|
4528 |
l := selectionStartLine. |
|
4529 |
] ifFalse:[ |
|
4530 |
selectionEndLine := (selectionEndLine - 1) max:0. |
|
4531 |
||
4532 |
l := selectionEndLine. |
|
4533 |
(selectionEndLine < clickLine |
|
4534 |
or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])]) |
|
4535 |
ifTrue:[ |
|
4536 |
t := selectionStartLine. |
|
4537 |
selectionStartLine := selectionEndLine. |
|
4538 |
selectionEndLine := t. |
|
4539 |
t := selectionStartCol. |
|
4540 |
selectionStartCol := selectionEndCol. |
|
4541 |
selectionEndCol := t. |
|
4542 |
l := selectionStartLine. |
|
4543 |
expandingTop := true |
|
4544 |
]. |
|
4545 |
]. |
|
4546 |
self validateNewSelection. |
|
4547 |
self setPrimarySelection. |
|
4548 |
self selectionChanged. |
|
4549 |
"/ self redrawLine:l. |
|
4550 |
"/ self redrawLine:l+1. |
|
4551 |
self redrawFromLine:l to:l+1. |
|
4552 |
self makeSelectionVisible. |
|
458 | 4553 |
]. |
4554 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4555 |
"Modified: / 06-03-1996 / 14:12:06 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4556 |
"Modified: / 17-04-2012 / 21:01:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4557 |
! |
4558 |
||
248 | 4559 |
hasSelection |
4560 |
"return true, if there is a selection" |
|
4561 |
||
4562 |
^ selectionStartLine notNil |
|
4563 |
! |
|
4564 |
||
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4565 |
hasSelectionForCopy |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4566 |
"return true, if there is a selection which can be copyied |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4567 |
(the same as #hasSelection, except for editfields in password-mode)" |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4568 |
|
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4569 |
^ self hasSelection |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4570 |
! |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4571 |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4572 |
hasSelectionWithinSingleLine |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4573 |
"return true, if there is a selection and it is within a line" |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4574 |
|
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4575 |
^ selectionStartLine notNil |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4576 |
and:[ selectionStartLine == selectionEndLine ] |
3315 | 4577 |
|
4578 |
"Modified: / 04-07-2006 / 18:42:59 / fm" |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4579 |
! |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4580 |
|
5004 | 4581 |
hasSingleFullLineSelected |
4582 |
^ (selectionStartLine notNil |
|
4583 |
and:[selectionEndLine notNil |
|
4584 |
and:[selectionEndLine == (selectionStartLine+1) |
|
4585 |
and:[selectionStartCol == 1 |
|
4586 |
and:[selectionEndCol == 0 |
|
4587 |
]]]]) |
|
4588 |
! |
|
4589 |
||
2588 | 4590 |
isInSelection:line col:aColNr |
4591 |
"returns true, if the line, and column is in the selection |
|
4592 |
" |
|
3438 | 4593 |
selectionStartLine isNil ifTrue:[^ false]. |
4594 |
selectionEndLine isNil ifTrue:[^ false]. |
|
2588 | 4595 |
|
4596 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
|
4500 | 4597 |
^ false |
2588 | 4598 |
]. |
4599 |
||
4600 |
line == selectionStartLine ifTrue:[ |
|
4500 | 4601 |
aColNr < selectionStartCol ifTrue:[^ false] |
2588 | 4602 |
]. |
4603 |
||
4604 |
line == selectionEndLine ifTrue:[ |
|
4500 | 4605 |
(selectionEndCol ~~ 0 and:[selectionEndCol < aColNr]) ifTrue:[^ false] |
2588 | 4606 |
]. |
4607 |
^ true |
|
4608 |
! |
|
4609 |
||
248 | 4610 |
makeSelectionVisible |
4611 |
"scroll to make the selection visible" |
|
4612 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4613 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4614 |
|
248 | 4615 |
selectionStartLine notNil ifTrue:[ |
4500 | 4616 |
expandingTop == true ifTrue:[ |
4617 |
line := selectionStartLine. |
|
4618 |
col := selectionStartCol. |
|
4619 |
] ifFalse:[ |
|
4620 |
line := selectionEndLine. |
|
4621 |
col := selectionEndCol. |
|
4622 |
]. |
|
4623 |
self makeLineVisible:line. |
|
4624 |
self makeColVisible:col inLine:line. |
|
248 | 4625 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4626 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4627 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 4628 |
! |
4629 |
||
4630 |
selectAll |
|
4631 |
"select the whole text" |
|
4632 |
||
4633 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
4634 |
! |
|
4635 |
||
4140
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4636 |
selectFromCharacterPosition:pos1 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4637 |
"compute line/col from the character position and select the text up to the end" |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4638 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4639 |
|line1 col1 line2 col2| |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4640 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4641 |
line1 := self lineOfCharacterPosition:pos1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4642 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4643 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4644 |
line2 := (list size + 1). |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4645 |
col2 := 0. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4646 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4647 |
! |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4648 |
|
248 | 4649 |
selectFromCharacterPosition:pos1 to:pos2 |
4650 |
"compute line/col from character positions and select the text" |
|
4651 |
||
4652 |
|line1 col1 line2 col2| |
|
4653 |
||
4554 | 4654 |
pos1 > pos2 ifTrue:[ |
4655 |
^ self unselect |
|
4656 |
]. |
|
248 | 4657 |
line1 := self lineOfCharacterPosition:pos1. |
4658 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
4554 | 4659 |
col1 < 1 ifTrue:[ col1 := 1 ]. |
4660 |
||
248 | 4661 |
line2 := self lineOfCharacterPosition:pos2. |
4662 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
4554 | 4663 |
col2 < 1 ifTrue:[ col2 := 1 ]. |
248 | 4664 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
4665 |
! |
|
4666 |
||
4667 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
4668 |
"select a piece of text and redraw that area" |
|
4669 |
||
5046 | 4670 |
((selectionStartLine = startLine) |
4671 |
and:[ (selectionStartCol = startCol) |
|
4672 |
and:[ (selectionEndLine = endLine) |
|
4673 |
and:[ (selectionEndCol = endCol) ]]]) ifTrue:[^ self ]. |
|
4674 |
||
248 | 4675 |
self unselect. |
4676 |
startLine notNil ifTrue:[ |
|
4787 | 4677 |
"new:" |
4678 |
endLine < startLine ifTrue:[ |
|
4679 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
|
4680 |
]. |
|
4681 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
|
4682 |
endCol ~~ 0 ifTrue:[ |
|
4683 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
|
4684 |
]. |
|
4685 |
^ self |
|
4686 |
]. |
|
248 | 4687 |
|
4688 |
" old: |
|
4787 | 4689 |
endLine < startLine ifTrue:[^ self]. |
4690 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
|
248 | 4691 |
" |
4787 | 4692 |
selectionStartLine := startLine. |
4693 |
selectionStartCol := startCol. |
|
4694 |
selectionEndLine := endLine. |
|
4695 |
selectionEndCol := endCol. |
|
4696 |
self validateNewSelection. |
|
4697 |
self setPrimarySelection. |
|
4698 |
self selectionChanged. |
|
4699 |
||
4700 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
4701 |
self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol |
|
4702 |
] ifFalse:[ |
|
4703 |
selectionStartLine to:selectionEndLine do:[:lineNr | |
|
4704 |
self redrawLine:lineNr |
|
4705 |
] |
|
4706 |
]. |
|
4707 |
selectStyle := nil. |
|
248 | 4708 |
] |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4709 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4710 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4711 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4712 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4713 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4714 |
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
|
4715 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4716 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4717 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4718 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4719 |
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
|
4720 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4721 |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4722 |
"Modified: / 02-01-1997 / 13:32:25 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4723 |
"Modified: / 17-04-2012 / 21:00:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4724 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4725 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4726 |
selectFromLine:startLine toLine:endLine |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4727 |
"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
|
4728 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4729 |
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
|
4730 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4731 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4732 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4733 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4734 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4735 |
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
|
4736 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4737 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4738 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4739 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4740 |
v selectFromLine:2 toLine:10 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4741 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4742 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4743 |
"Modified: 29.4.1996 / 12:23:46 / cg" |
248 | 4744 |
! |
4745 |
||
4746 |
selectLine:selectLine |
|
4747 |
"select one line and redraw it" |
|
4748 |
||
4749 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
4750 |
wordStartCol := selectionStartCol. |
|
4751 |
wordEndCol := selectionEndCol. |
|
4752 |
wordStartLine := selectionStartLine. |
|
4753 |
wordEndLine := selectionEndLine. |
|
4754 |
selectStyle := #line |
|
4755 |
! |
|
4756 |
||
4757 |
selectLineAtY:y |
|
4758 |
"select the line at given y-(view-)coordinate" |
|
4759 |
||
2413 | 4760 |
|selectLine| |
4761 |
||
4762 |
selectLine := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y). |
|
248 | 4763 |
selectLine notNil ifTrue:[ |
4500 | 4764 |
self selectLine:selectLine |
248 | 4765 |
] |
4766 |
! |
|
4767 |
||
4768 |
selectLineWhereCharacterPosition:pos |
|
4769 |
"select the line, where characterPosition pos is living. |
|
4770 |
The argument pos starts at 1 from the start of the text |
|
4500 | 4771 |
and counts characters (i.e. can be used to convert from |
248 | 4772 |
character position within a string to line-position in view)." |
4773 |
||
4774 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
4775 |
! |
|
4776 |
||
4777 |
selectWordAtLine:line col:col |
|
4778 |
"select the word at given line/col" |
|
4779 |
||
4500 | 4780 |
self |
4781 |
wordAtLine:line col:col do:[ |
|
4782 |
:beginLine :beginCol :endLine :endCol :style | |
|
4783 |
||
4784 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4785 |
selectStyle := style |
|
4786 |
] |
|
504 | 4787 |
|
4788 |
"Modified: 18.3.1996 / 17:30:38 / cg" |
|
248 | 4789 |
! |
4790 |
||
4791 |
selectWordAtX:x y:y |
|
4792 |
"select the word at given x/y-(view-)coordinate" |
|
4793 |
||
4794 |
|selectVisibleLine selectLine selectCol| |
|
4795 |
||
4796 |
selectStyle := nil. |
|
4797 |
selectVisibleLine := self visibleLineOfY:y. |
|
4798 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
4799 |
selectLine notNil ifTrue:[ |
|
4500 | 4800 |
selectCol := self colOfX:x inVisibleLine:selectVisibleLine. |
4801 |
self selectWordAtLine:selectLine col:selectCol |
|
248 | 4802 |
] |
1661
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
4803 |
|
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
4804 |
"Modified: / 8.9.1998 / 21:22:46 / cg" |
248 | 4805 |
! |
4806 |
||
3528 | 4807 |
selectedInterval |
4808 |
"return the selection-boundaries as interval" |
|
4809 |
||
4810 |
^ self selectionStartIndex to:(self selectionStopIndex - 1) |
|
4811 |
! |
|
4812 |
||
248 | 4813 |
selection |
4814 |
"return the selection as a collection of (line-)strings. |
|
4815 |
If the selection ends in a full line, the last entry in the returned |
|
4816 |
collection will be an empty string." |
|
4817 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4818 |
|sel| |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4819 |
|
248 | 4820 |
selectionStartLine isNil ifTrue:[^ nil]. |
4466 | 4821 |
sel := self textFromLine:selectionStartLine col:(selectionStartCol max:1) toLine:selectionEndLine col:selectionEndCol. |
5391 | 4822 |
sel notEmptyOrNil ifTrue:[ |
4823 |
(characterEncoding ? #'iso10646-1' "eg unicode") ~~ #'iso10646-1' ifTrue:[ |
|
4824 |
sel := sel encodeFrom:characterEncoding into:#'iso10646-1' |
|
4825 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4826 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4827 |
^ sel |
2158
1fbe3297506f
generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
2120
diff
changeset
|
4828 |
|
4361
646cd7c5513e
comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
4829 |
"Modified (comment): / 25-01-2012 / 00:29:09 / cg" |
248 | 4830 |
! |
4831 |
||
2217 | 4832 |
selectionAsString |
4833 |
"return the selection as a String (i.e. without emphasis)" |
|
4834 |
||
2693 | 4835 |
|sel| |
2217 | 4836 |
|
4837 |
(sel := self selection) isNil ifTrue:[^ nil]. |
|
2419 | 4838 |
sel := sel collect:[:each| each isNil ifTrue:[nil] ifFalse:[each string]]. |
2217 | 4839 |
^ (sel asStringWithCRsFrom:1 to:(sel size) compressTabs:false withCR:false) string |
4840 |
! |
|
4841 |
||
4101 | 4842 |
selectionChanged |
4843 |
"can be redefined for notification or special actions" |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4844 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4845 |
"Modified: / 17-04-2012 / 20:59:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4101 | 4846 |
! |
4847 |
||
248 | 4848 |
selectionEndCol |
4849 |
^ selectionEndCol |
|
4850 |
! |
|
4851 |
||
4852 |
selectionEndLine |
|
4853 |
^ selectionEndLine |
|
4854 |
! |
|
4855 |
||
4856 |
selectionStartCol |
|
4857 |
^ selectionStartCol |
|
4858 |
! |
|
4859 |
||
4860 |
selectionStartLine |
|
4861 |
^ selectionStartLine |
|
4862 |
! |
|
4863 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4864 |
setPrimarySelection |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4865 |
"can be redefined for notification or special actions" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4866 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4867 |
device notNil ifTrue:[ |
4500 | 4868 |
"On X11, be nice and set the PRIMARY selection. |
4869 |
(#setPrimaryText:ownerView: is void in DeviceWorkstation)" |
|
4870 |
device setPrimaryText: self selectionAsString ownerView: self. |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4871 |
]. |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4872 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4873 |
"Created: / 17-04-2012 / 20:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4874 |
! |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4875 |
|
3308 | 4876 |
st80SelectMode |
3459 | 4877 |
st80SelectMode notNil ifTrue:[^ st80SelectMode]. |
4878 |
^ self class st80SelectMode |
|
3308 | 4879 |
|
4880 |
"Created: / 03-07-2006 / 16:30:59 / cg" |
|
4881 |
! |
|
4882 |
||
3459 | 4883 |
st80SelectMode:aBoolean |
4884 |
st80SelectMode := aBoolean |
|
4885 |
! |
|
4886 |
||
248 | 4887 |
unselect |
4888 |
"unselect - if there was a selection redraw that area" |
|
4889 |
||
4890 |
|startLine endLine startVisLine endVisLine| |
|
4891 |
||
4892 |
selectionStartLine notNil ifTrue:[ |
|
4500 | 4893 |
startLine := selectionStartLine. |
4894 |
endLine := selectionEndLine. |
|
4895 |
||
4896 |
self unselectWithoutRedraw. |
|
4897 |
||
4898 |
"/ if the selection is not visible, we are done |
|
4899 |
||
4900 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
|
4901 |
endLine < firstLineShown ifTrue:[^ self]. |
|
4902 |
||
4903 |
startLine < firstLineShown ifTrue:[ |
|
4904 |
startVisLine := 1 |
|
4905 |
] ifFalse:[ |
|
4906 |
startVisLine := self listLineToVisibleLine:startLine |
|
4907 |
]. |
|
4908 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
|
4909 |
endVisLine := nLinesShown |
|
4910 |
] ifFalse:[ |
|
4911 |
endVisLine := self listLineToVisibleLine:endLine |
|
4912 |
]. |
|
4913 |
||
4914 |
"/ if its only part of a line, just redraw what has to be |
|
4915 |
||
4916 |
(startLine == endLine) ifTrue:[ |
|
4917 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
|
4918 |
] ifFalse:[ |
|
4919 |
self redrawFromVisibleLine:startVisLine to:endVisLine |
|
4920 |
]. |
|
248 | 4921 |
]. |
4922 |
selectStyle := nil |
|
503 | 4923 |
|
715 | 4924 |
"Modified: 29.5.1996 / 14:54:11 / cg" |
248 | 4925 |
! |
4926 |
||
4927 |
unselectWithoutRedraw |
|
4928 |
"forget selection but do not redraw the selection area |
|
4929 |
- 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
|
4930 |
known to be invisible (however, redraw knows about that anyway)." |
248 | 4931 |
|
2735 | 4932 |
selectionStartLine := selectionEndLine := nil. |
4101 | 4933 |
self selectionChanged. |
248 | 4934 |
! |
4935 |
||
4936 |
validateNewSelection |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4937 |
"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
|
4938 |
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
|
4939 |
may redefine it to limit the selection to a single line, or whatever." |
248 | 4940 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4941 |
^ self |
504 | 4942 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4943 |
"Modified: 29.4.1996 / 12:32:08 / cg" |
5378 | 4944 |
! |
4945 |
||
4946 |
withSelectionForeground:hilightFg background:hilightBg do:aBlock |
|
4947 |
"evaluate aBlock while the selection is shown highlighted with colors passed as args." |
|
4948 |
||
4949 |
|oldFg oldBg| |
|
4950 |
||
4951 |
" |
|
4952 |
change color of selection & hide cursor |
|
4953 |
" |
|
4954 |
oldFg := selectionFgColor. |
|
4955 |
oldBg := selectionBgColor. |
|
4956 |
selectionBgColor := hilightBg. |
|
4957 |
selectionFgColor := hilightFg. |
|
4958 |
||
4959 |
expandingTop := true. "/ hack to make the top of the selection visible |
|
4960 |
self makeSelectionVisible. |
|
4961 |
selectionStartLine notNil ifTrue:[ |
|
4962 |
selectionEndLine notNil ifTrue:[ |
|
4963 |
self redrawFromLine:selectionStartLine to:selectionEndLine. |
|
4964 |
]. |
|
4965 |
]. |
|
4966 |
self flush. |
|
4967 |
||
4968 |
aBlock ensure:[ |
|
4969 |
" |
|
4970 |
undo selection color change and show cursor again |
|
4971 |
" |
|
4972 |
selectionFgColor := oldFg. |
|
4973 |
selectionBgColor := oldBg. |
|
4974 |
]. |
|
248 | 4975 |
! ! |
4976 |
||
4310 | 4977 |
!TextView methodsFor:'testing'! |
4978 |
||
4979 |
isTextView |
|
4980 |
"I am showing text" |
|
4981 |
||
4982 |
^ true |
|
4983 |
! ! |
|
4984 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
4985 |
!TextView class methodsFor:'documentation'! |
248 | 4986 |
|
4987 |
version |
|
5374 | 4988 |
^ '$Header$' |
3964 | 4989 |
! |
4990 |
||
4991 |
version_CVS |
|
5374 | 4992 |
^ '$Header$' |
248 | 4993 |
! ! |
2630
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
4994 |
|
4485 | 4995 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
4996 |
TextView initialize! |