author | Claus Gittinger <cg@exept.de> |
Thu, 01 Oct 2015 11:08:34 +0200 | |
changeset 5443 | 61ebc1660709 |
parent 5412 | d248d42bac05 |
child 5444 | cd4f2b359bfe |
child 5460 | c353fd71390d |
permissions | -rw-r--r-- |
5443 | 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:[ |
|
5412 | 1230 |
^ self |
2881 | 1231 |
]. |
5412 | 1232 |
(fontsEncoding notNil and:[CharacterEncoder isEncoding:pref subSetOf:fontsEncoding]) ifTrue:[ |
1233 |
^ self |
|
2881 | 1234 |
]. |
1235 |
||
1236 |
filter := [:f | |coding| |
|
5412 | 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:[ |
|
5412 | 1247 |
defaultFont := matchingFamilyFaceStyleSizeFonts first |
2881 | 1248 |
] ifFalse:[ |
5412 | 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:[ |
|
5412 | 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:[ |
5412 | 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 |
|
5443 | 2662 |
|italicFont boldFont| |
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. |
5443 | 2665 |
"/ do we really need this info now? |
2666 |
"/ on unix, it seems to work with the next two lines commented; |
|
2667 |
"/ should probably check on windows too |
|
3258
0a07b6fdd85d
fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents:
3251
diff
changeset
|
2668 |
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
|
2669 |
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
|
2670 |
|
5443 | 2671 |
fontHeight := font height. |
2672 |
fontAscent := font ascent. |
|
2673 |
fontWidth := font width. |
|
2674 |
fontIsFixedWidth := font isFixedWidth. |
|
2675 |
||
2676 |
"/ fA := font maxAscent. |
|
2677 |
italicFont notNil ifTrue:[ |
|
2678 |
fontHeight := fontHeight max:(italicFont height). |
|
2679 |
fontAscent := fontAscent max:(italicFont ascent). |
|
2680 |
fontIsFixedWidth := fontIsFixedWidth and:[ italicFont isFixedWidth ] |
|
2681 |
]. |
|
2682 |
boldFont notNil ifTrue:[ |
|
2683 |
fontHeight := fontHeight max:(boldFont height). |
|
2684 |
fontAscent := fontAscent max:(boldFont ascent). |
|
2685 |
fontIsFixedWidth := fontIsFixedWidth and:[ boldFont isFixedWidth ] |
|
2686 |
]. |
|
2687 |
||
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2688 |
includesNonStrings == true ifTrue:[ |
4569 | 2689 |
"/ for now, we do not support variable height entries ... |
4779 | 2690 |
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
|
2691 |
]. |
4579 | 2692 |
fontHeight := fontHeight + lineSpacing. |
668
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2693 |
|
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2694 |
"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
|
2695 |
"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
|
2696 |
! |
729295eb37fc
use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents:
651
diff
changeset
|
2697 |
|
5374 | 2698 |
highlightLineSpacing |
2699 |
"true if the spacing between lines is to be drawn with selected color, |
|
2700 |
false if it remains white. |
|
2701 |
false for selection in list views; true for edit/text views" |
|
2702 |
||
2703 |
^ true |
|
2704 |
! |
|
2705 |
||
3605 | 2706 |
isClosingParenthesis:ch |
2707 |
((parenthesisSpecification at:#close) includes:ch) ifTrue:[^ true]. |
|
4368 | 2708 |
^ ')]}' includes:ch |
2709 |
||
2710 |
"Modified: / 12-02-2012 / 08:37:01 / cg" |
|
3605 | 2711 |
! |
2712 |
||
2713 |
isOpeningParenthesis:ch |
|
2714 |
((parenthesisSpecification at:#open) includes:ch) ifTrue:[^ true]. |
|
4368 | 2715 |
^ '([{' includes:ch |
2716 |
||
2717 |
"Modified: / 12-02-2012 / 08:37:11 / cg" |
|
3605 | 2718 |
! |
2719 |
||
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2720 |
rememberSearchPattern:pattern |
2691 | 2721 |
|nRemembered patternString| |
2722 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
2723 |
self clearSearchAction. |
2813
ec8e83691849
forget searchAction, when a new pattern-search is done
Claus Gittinger <cg@exept.de>
parents:
2811
diff
changeset
|
2724 |
|
2691 | 2725 |
patternString := pattern string. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2726 |
|
3270
e3ed37e15f9d
oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents:
3258
diff
changeset
|
2727 |
nRemembered := NumRememberedSearchPatterns ? 20. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2728 |
|
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2729 |
LastSearchPatterns isNil ifTrue:[ |
4500 | 2730 |
LastSearchPatterns := OrderedCollection new. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2731 |
]. |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2732 |
"/ move to top or addFirst |
4409 | 2733 |
(LastSearchPatterns includes:patternString) ifTrue:[ |
4500 | 2734 |
LastSearchPatterns remove:patternString. |
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2735 |
] ifFalse:[ |
4500 | 2736 |
LastSearchPatterns size > nRemembered ifTrue:[ |
2737 |
LastSearchPatterns removeLast |
|
2738 |
] |
|
2201
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2739 |
]. |
4409 | 2740 |
LastSearchPatterns addFirst:patternString. |
2741 |
||
2742 |
"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
|
2743 |
! |
ee684354d1d6
search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents:
2200
diff
changeset
|
2744 |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2745 |
removeTrailingWhitespace |
3001 | 2746 |
list isNil ifTrue:[^self]. |
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2747 |
list keysAndValuesDo:[:lineNR :line | |
4500 | 2748 |
|l| |
2749 |
||
2750 |
line notNil ifTrue:[ |
|
2751 |
l := line withoutTrailingSeparators. |
|
2752 |
list at:lineNR put:l. |
|
2753 |
] |
|
2945
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2754 |
]. |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2755 |
! |
5c4f000c7f17
remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents:
2944
diff
changeset
|
2756 |
|
4009 | 2757 |
resetVariablesBeforeNewSearch |
2758 |
"clear the autosearch action, when the first pattern is searched for" |
|
2759 |
||
2760 |
searchAction := nil. |
|
2761 |
! |
|
2762 |
||
248 | 2763 |
scrollSelectDown |
2764 |
"auto scroll action; scroll and reinstall timed-block" |
|
2765 |
||
2766 |
|prevEndLine| |
|
2767 |
||
2768 |
"just to make certain ..." |
|
2769 |
selectionEndLine isNil ifTrue:[^ self]. |
|
2770 |
||
2771 |
self scrollDown. |
|
2772 |
||
2773 |
"make new selection immediately visible" |
|
2774 |
prevEndLine := selectionEndLine. |
|
2775 |
selectionEndLine := firstLineShown + nFullLinesShown. |
|
2776 |
selectionEndCol := 0. |
|
2777 |
prevEndLine to:selectionEndLine do:[:lineNr | |
|
5235 | 2778 |
self redrawLine:lineNr |
248 | 2779 |
]. |
5235 | 2780 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2781 |
self selectionChanged. |
248 | 2782 |
! |
2783 |
||
2784 |
scrollSelectLeft |
|
2785 |
"auto scroll action; scroll and reinstall timed-block" |
|
2786 |
||
2787 |
|prevStartLine| |
|
2788 |
||
2789 |
"just to make certain ..." |
|
2790 |
selectionStartLine isNil ifTrue:[^ self]. |
|
2791 |
selectionStartCol isNil ifTrue:[^ self]. |
|
2792 |
||
2793 |
"make new selection immediately visible" |
|
2794 |
prevStartLine := selectionStartLine. |
|
2795 |
selectionStartCol := selectionStartCol - 1 max:1. |
|
2796 |
self scrollLeft. |
|
2797 |
||
5236 | 2798 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2799 |
self selectionChanged. |
248 | 2800 |
! |
2801 |
||
2802 |
scrollSelectRight |
|
2803 |
"auto scroll action; scroll and reinstall timed-block" |
|
2804 |
||
4156 | 2805 |
|prevEndCol firstVisibleCol endLine| |
248 | 2806 |
|
2807 |
"just to make certain ..." |
|
2808 |
selectionEndCol isNil ifTrue:[^ self]. |
|
4169 | 2809 |
selectionEndLine isNil ifTrue:[^ self]. |
248 | 2810 |
|
2811 |
prevEndCol := selectionEndCol. |
|
4156 | 2812 |
selectionEndCol := (selectionEndCol + 1) min:(self listAt:selectionEndLine) size. |
2813 |
||
2814 |
endLine := self listLineToVisibleLine:selectionEndLine. |
|
2815 |
endLine notNil ifTrue:[ |
|
5236 | 2816 |
firstVisibleCol := self colOfX:1 inVisibleLine:endLine. |
2817 |
selectionEndCol < firstVisibleCol ifTrue:[ |
|
2818 |
"/ scrolling faster than selection advances... |
|
2819 |
selectionEndCol := firstVisibleCol |
|
2820 |
]. |
|
4156 | 2821 |
]. |
2822 |
||
2823 |
self selectionChanged. |
|
248 | 2824 |
self scrollRight. |
4156 | 2825 |
"/ self repairDamage. |
248 | 2826 |
|
5236 | 2827 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4156 | 2828 |
|
2829 |
"Modified: / 05-08-2010 / 21:25:56 / cg" |
|
248 | 2830 |
! |
2831 |
||
2832 |
scrollSelectUp |
|
2833 |
"auto scroll action; scroll and reinstall timed-block" |
|
2834 |
||
2835 |
|prevStartLine| |
|
2836 |
||
2837 |
"just to make certain ..." |
|
2838 |
selectionStartLine isNil ifTrue:[^ self]. |
|
2839 |
||
2840 |
self scrollUp. |
|
2841 |
||
2842 |
"make new selection immediately visible" |
|
2843 |
prevStartLine := selectionStartLine. |
|
2844 |
selectionStartLine := firstLineShown. |
|
2845 |
selectionStartCol := 1. |
|
2846 |
selectionStartLine to:prevStartLine do:[:lineNr | |
|
5236 | 2847 |
self redrawLine:lineNr |
248 | 2848 |
]. |
5236 | 2849 |
autoScrollBlock notNil ifTrue:[ Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT ]. |
4101 | 2850 |
self selectionChanged. |
248 | 2851 |
! |
2852 |
||
2853 |
stopScrollSelect |
|
2854 |
"stop auto scroll; deinstall timed-block" |
|
2855 |
||
2856 |
autoScrollBlock notNil ifTrue:[ |
|
4500 | 2857 |
Processor removeTimedBlock:autoScrollBlock. |
2858 |
self compressMotionEvents:true. |
|
2859 |
autoScrollBlock := nil. |
|
2860 |
autoScrollDeltaT := nil |
|
248 | 2861 |
] |
2862 |
! |
|
2863 |
||
5120 | 2864 |
textChanged |
2865 |
self isNativeWidget ifTrue:[ |
|
2866 |
drawableId notNil ifTrue:[ |
|
2867 |
device changeText:self contents in:drawableId |
|
2868 |
] |
|
2869 |
]. |
|
2870 |
super textChanged |
|
2871 |
! |
|
2872 |
||
248 | 2873 |
widthForScrollBetween:firstLine and:lastLine |
2874 |
"return the width in pixels for a scroll between firstLine and lastLine" |
|
2875 |
||
2876 |
selectionStartLine notNil ifTrue:[ |
|
4500 | 2877 |
"/ if there is a selection which covers multiple lines, |
2878 |
"/ we have to scroll the whole width (to include the selection-rectangle) |
|
2879 |
||
2880 |
(lastLine < selectionStartLine) ifFalse:[ |
|
2881 |
(firstLine > selectionEndLine) ifFalse:[ |
|
2882 |
^ width |
|
2883 |
] |
|
2884 |
]. |
|
248 | 2885 |
]. |
2886 |
^ super widthForScrollBetween:firstLine and:lastLine |
|
2887 |
! ! |
|
2888 |
||
997 | 2889 |
!TextView methodsFor:'queries'! |
2890 |
||
4063 | 2891 |
hasSearchActionSelection |
2892 |
"Here we fake the use of typeOfSelection which is really in EditTextView" |
|
2893 |
||
2894 |
^ false |
|
2895 |
! |
|
2896 |
||
997 | 2897 |
specClass |
1380 | 2898 |
"redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)" |
2899 |
||
997 | 2900 |
self class == TextView ifTrue:[^ TextEditorSpec]. |
1046 | 2901 |
^ super specClass |
997 | 2902 |
|
1380 | 2903 |
"Modified: / 31.10.1997 / 19:48:35 / cg" |
997 | 2904 |
! ! |
2905 |
||
248 | 2906 |
!TextView methodsFor:'redrawing'! |
2907 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2908 |
clearMarginOfVisibleLine:visLine with:color |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2909 |
"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
|
2910 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2911 |
(leftMargin ~~ 0) ifTrue:[ |
4602 | 2912 |
viewOrigin x <= margin ifTrue:[ |
2913 |
self paint:color. |
|
2914 |
self fillRectangleX:margin-viewOrigin x |
|
4667 | 2915 |
y:(self yOfVisibleLine:visLine)- (lineSpacing//2) |
4602 | 2916 |
width:leftMargin |
2917 |
height:fontHeight |
|
2918 |
] |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2919 |
] |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2920 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2921 |
"Created: 6.3.1996 / 14:22:55 / cg" |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2922 |
! |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
2923 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2924 |
drawSelectedFromVisibleLine:startVisLineNr to:endVisLineNr |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2925 |
startVisLineNr to:endVisLineNr do:[:visLine | |
4500 | 2926 |
self drawVisibleLineSelected:visLine |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2927 |
] |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2928 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2929 |
|
4500 | 2930 |
drawVisibleLineSelected:visLineNr |
2931 |
self |
|
2932 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2933 |
inVisible:visLineNr |
|
2934 |
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
|
2935 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2936 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2937 |
drawVisibleLineSelected:visLineNr col:col |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2938 |
self |
4500 | 2939 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
2940 |
inVisible:visLineNr |
|
2941 |
col:col |
|
2942 |
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
|
2943 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2944 |
|
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2945 |
drawVisibleLineSelected:visLineNr from:selectionStartCol |
4500 | 2946 |
self |
2947 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2948 |
inVisible:visLineNr |
|
2949 |
from:selectionStartCol |
|
2950 |
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
|
2951 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2952 |
|
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
2953 |
drawVisibleLineSelected:visLineNr from:startCol to:endCol |
4500 | 2954 |
self |
2955 |
drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr)) |
|
2956 |
inVisible:visLineNr |
|
2957 |
from:startCol to:endCol |
|
2958 |
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
|
2959 |
! |
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
2960 |
|
248 | 2961 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
2962 |
"redraw a visible line range" |
|
2963 |
||
2964 |
|startLine endLine specialCare end selVisStart line1 line2| |
|
2965 |
||
2966 |
shown ifFalse:[^ self]. |
|
2967 |
||
2968 |
end := endVisLineNr. |
|
2969 |
(end > nLinesShown) ifTrue:[ |
|
4500 | 2970 |
end := nLinesShown |
248 | 2971 |
]. |
2972 |
||
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
2973 |
selectionEndLine isNil ifTrue:[ |
4500 | 2974 |
selectionStartLine := nil |
2740
892dfb6b0da1
kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents:
2735
diff
changeset
|
2975 |
]. |
2735 | 2976 |
|
248 | 2977 |
selectionStartLine isNil ifTrue:[ |
4500 | 2978 |
specialCare := false |
248 | 2979 |
] ifFalse:[ |
4500 | 2980 |
startLine := self visibleLineToAbsoluteLine:startVisLineNr. |
2981 |
(startLine > selectionEndLine) ifTrue:[ |
|
2982 |
specialCare := false |
|
2983 |
] ifFalse:[ |
|
2984 |
endLine := self visibleLineToAbsoluteLine:end. |
|
2985 |
(endLine < selectionStartLine) ifTrue:[ |
|
2986 |
specialCare := false |
|
2987 |
] ifFalse:[ |
|
2988 |
specialCare := true |
|
2989 |
] |
|
2990 |
] |
|
248 | 2991 |
]. |
2992 |
||
2993 |
"easy: nothing is selected" |
|
2994 |
specialCare ifFalse:[ |
|
4500 | 2995 |
super redrawFromVisibleLine:startVisLineNr to:end. |
2996 |
^ self |
|
248 | 2997 |
]. |
2998 |
||
2999 |
"easy: all is selected" |
|
3000 |
((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[ |
|
4500 | 3001 |
self drawSelectedFromVisibleLine:startVisLineNr to:end. |
3002 |
^ self |
|
248 | 3003 |
]. |
3004 |
||
3005 |
(selectionStartLine >= firstLineShown) ifTrue:[ |
|
4500 | 3006 |
"draw unselected top part" |
3007 |
||
3008 |
selVisStart := self listLineToVisibleLine:selectionStartLine. |
|
3009 |
super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1). |
|
3010 |
||
3011 |
"and first partial selected line" |
|
3012 |
self redrawVisibleLine:selVisStart. |
|
3013 |
||
3014 |
"rest starts after this one" |
|
3015 |
line1 := selVisStart + 1 |
|
248 | 3016 |
] ifFalse:[ |
4500 | 3017 |
line1 := 1 |
248 | 3018 |
]. |
3019 |
||
3020 |
(line1 > end) ifTrue:[^ self]. |
|
3021 |
(line1 < startVisLineNr) ifTrue:[ |
|
4500 | 3022 |
line1 := startVisLineNr |
248 | 3023 |
]. |
3024 |
||
3025 |
"draw middle part of selection" |
|
3026 |
||
3027 |
(selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[ |
|
4500 | 3028 |
line2 := nLinesShown |
248 | 3029 |
] ifFalse:[ |
4500 | 3030 |
line2 := (self listLineToVisibleLine:selectionEndLine) - 1 |
248 | 3031 |
]. |
3032 |
(line2 > end) ifTrue:[ |
|
4500 | 3033 |
line2 := end |
248 | 3034 |
]. |
3035 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3036 |
self drawSelectedFromVisibleLine:line1 to:line2. |
248 | 3037 |
|
3038 |
(line2 >= end) ifTrue:[^ self]. |
|
3039 |
||
3040 |
"last line of selection" |
|
3041 |
self redrawVisibleLine:(line2 + 1). |
|
3042 |
||
3043 |
((line2 + 2) <= end) ifTrue:[ |
|
4500 | 3044 |
super redrawFromVisibleLine:(line2 + 2) to:end |
248 | 3045 |
] |
3046 |
! |
|
3047 |
||
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3048 |
redrawVisibleLine:visLineNr |
248 | 3049 |
"redraw visible line lineNr" |
3050 |
||
2558
4c10bec1117d
more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents:
2557
diff
changeset
|
3051 |
|line| |
248 | 3052 |
|
4528 | 3053 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3054 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
3055 |
line := self visibleLineToAbsoluteLine:visLineNr. |
|
3056 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3057 |
(line == selectionStartLine) ifTrue:[ |
|
3058 |
(line == selectionEndLine) ifTrue:[ |
|
3059 |
"it's part-of-single-line selection" |
|
3060 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3061 |
(selectionStartCol > 1) ifTrue:[ |
|
3062 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3063 |
]. |
|
3064 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol. |
|
3065 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3066 |
^ self |
|
3067 |
]. |
|
3068 |
||
3069 |
"it's the first line of a multi-line selection" |
|
3070 |
(selectionStartCol ~~ 1) ifTrue:[ |
|
3071 |
self clearMarginOfVisibleLine:visLineNr with:bgColor. |
|
3072 |
super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1) |
|
3073 |
] ifFalse:[ |
|
3074 |
viewOrigin x == 0 ifTrue:[ |
|
3075 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3076 |
] |
|
3077 |
]. |
|
3078 |
self drawVisibleLineSelected:visLineNr from:selectionStartCol. |
|
3079 |
^ self |
|
3080 |
]. |
|
3081 |
||
3082 |
(line == selectionEndLine) ifTrue:[ |
|
3083 |
"it's the last line of a multi-line selection" |
|
3084 |
(selectionEndCol == 0) ifTrue:[ |
|
3085 |
^ super redrawVisibleLine:visLineNr |
|
3086 |
]. |
|
3087 |
||
3088 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3089 |
self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol. |
|
3090 |
super redrawVisibleLine:visLineNr from:(selectionEndCol + 1). |
|
3091 |
^ self |
|
3092 |
]. |
|
3093 |
||
3094 |
"it's a full line in a multi-line selection" |
|
3095 |
self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor. |
|
3096 |
self drawVisibleLineSelected:visLineNr. |
|
3097 |
^ self |
|
3098 |
] |
|
248 | 3099 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3100 |
super redrawVisibleLine:visLineNr |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3101 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3102 |
"Modified: 6.3.1996 / 14:22:19 / cg" |
248 | 3103 |
! |
3104 |
||
3105 |
redrawVisibleLine:visLine col:col |
|
633 | 3106 |
"redraw single character at col in visible line lineNr." |
248 | 3107 |
|
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3108 |
|line| |
633 | 3109 |
|
3110 |
"/ |
|
3111 |
"/ care for selection |
|
3112 |
"/ |
|
4528 | 3113 |
(selectionStartLine notNil and:[selectionEndLine notNil |
3114 |
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
3115 |
line := self visibleLineToAbsoluteLine:visLine. |
|
3116 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3117 |
((line == selectionStartLine) |
|
3118 |
and: [col < selectionStartCol]) ifFalse:[ |
|
3119 |
((line == selectionEndLine) |
|
3120 |
and: [col > selectionEndCol]) ifFalse:[ |
|
3121 |
"its in the selection" |
|
3122 |
self drawVisibleLineSelected:visLine col:col. |
|
3123 |
^ self. |
|
3124 |
] |
|
3125 |
] |
|
3126 |
] |
|
248 | 3127 |
]. |
2557
dabeb8404df8
selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents:
2553
diff
changeset
|
3128 |
self drawVisibleLine:visLine col:col with:fgColor and:bgColor |
1496 | 3129 |
|
3130 |
"Modified: / 22.4.1998 / 08:53:05 / cg" |
|
248 | 3131 |
! |
3132 |
||
3133 |
redrawVisibleLine:visLine from:startCol |
|
3134 |
"redraw visible line lineNr from startCol to end of line" |
|
3135 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3136 |
|col line| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3137 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3138 |
col := startCol. |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3139 |
col == 0 ifTrue:[ |
4500 | 3140 |
col := 1. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3141 |
]. |
248 | 3142 |
|
2778
223915a2d6a4
kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
3143 |
(selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[ |
4500 | 3144 |
line := self visibleLineToAbsoluteLine:visLine. |
3145 |
(line between:selectionStartLine and:selectionEndLine) ifTrue:[ |
|
3146 |
((line == selectionStartLine) |
|
3147 |
or:[line == selectionEndLine]) ifTrue:[ |
|
3148 |
"since I'm lazy, redraw full line" |
|
3149 |
self redrawVisibleLine:visLine. |
|
3150 |
^ self |
|
3151 |
]. |
|
3152 |
"the line is fully within the selection" |
|
3153 |
self drawVisibleLineSelected:visLine from:col. |
|
3154 |
^ self |
|
3155 |
] |
|
248 | 3156 |
]. |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3157 |
super redrawVisibleLine:visLine from:col |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3158 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3159 |
"Modified: 6.3.1996 / 14:19:38 / cg" |
248 | 3160 |
! |
3161 |
||
3162 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
3163 |
"redraw visible line lineNr from startCol to endCol" |
|
3164 |
||
3165 |
|line allOut allIn leftCol rightCol| |
|
3166 |
||
3167 |
line := self visibleLineToAbsoluteLine:visLine. |
|
3168 |
||
3169 |
allIn := false. |
|
3170 |
allOut := false. |
|
4528 | 3171 |
(selectionStartLine isNil or:[selectionEndLine isNil |
3172 |
or:[selectionStartCol isNil or:[selectionEndCol isNil]]]) ifTrue:[ |
|
3173 |
allOut := true |
|
248 | 3174 |
] ifFalse:[ |
4528 | 3175 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
3176 |
allOut := true |
|
3177 |
] ifTrue:[ |
|
3178 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
3179 |
((endCol < selectionStartCol) |
|
3180 |
or:[startCol > selectionEndCol]) ifTrue:[ |
|
3181 |
allOut := true |
|
3182 |
] ifFalse:[ |
|
3183 |
((startCol >= selectionStartCol) |
|
3184 |
and:[endCol <= selectionEndCol]) ifTrue:[ |
|
3185 |
allIn := true |
|
3186 |
] |
|
3187 |
] |
|
3188 |
] ifFalse:[ |
|
3189 |
(line == selectionStartLine) ifTrue:[ |
|
3190 |
(endCol < selectionStartCol) ifTrue:[ |
|
3191 |
allOut := true |
|
3192 |
] ifFalse:[ |
|
3193 |
(startCol >= selectionStartCol) ifTrue:[ |
|
3194 |
allIn := true |
|
3195 |
] |
|
3196 |
] |
|
3197 |
] ifFalse:[ |
|
3198 |
(line == selectionEndLine) ifTrue:[ |
|
3199 |
(startCol > selectionEndCol) ifTrue:[ |
|
3200 |
allOut := true |
|
3201 |
] ifFalse:[ |
|
3202 |
(endCol <= selectionEndCol) ifTrue:[ |
|
3203 |
allIn := true |
|
3204 |
] |
|
3205 |
] |
|
3206 |
] ifFalse:[ |
|
3207 |
allIn := true |
|
3208 |
] |
|
3209 |
] |
|
3210 |
] |
|
3211 |
] |
|
248 | 3212 |
]. |
3213 |
allOut ifTrue:[ |
|
4528 | 3214 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
3215 |
^ self |
|
248 | 3216 |
]. |
3217 |
||
3218 |
allIn ifTrue:[ |
|
4528 | 3219 |
self drawVisibleLineSelected:visLine from:startCol to:endCol |
248 | 3220 |
] ifFalse:[ |
4528 | 3221 |
"redraw part before selection" |
3222 |
((line == selectionStartLine) |
|
3223 |
and:[startCol <= selectionStartCol]) ifTrue:[ |
|
3224 |
super redrawVisibleLine:visLine from:startCol |
|
3225 |
to:(selectionStartCol - 1). |
|
3226 |
leftCol := selectionStartCol |
|
3227 |
] ifFalse:[ |
|
3228 |
leftCol := startCol |
|
3229 |
]. |
|
3230 |
"redraw selected part" |
|
3231 |
(selectionEndLine > line) ifTrue:[ |
|
3232 |
rightCol := endCol |
|
3233 |
] ifFalse:[ |
|
3234 |
rightCol := selectionEndCol min:endCol |
|
3235 |
]. |
|
3236 |
self drawVisibleLineSelected:visLine from:leftCol to:rightCol. |
|
3237 |
||
3238 |
"redraw part after selection" |
|
3239 |
(rightCol < endCol) ifTrue:[ |
|
3240 |
super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol |
|
3241 |
] |
|
248 | 3242 |
]. |
3243 |
||
3244 |
"special care for first and last line of selection: |
|
3245 |
must handle margin also" |
|
3246 |
||
3247 |
((line == selectionEndLine) |
|
3248 |
and:[(startCol == 1) |
|
3249 |
and:[selectionStartLine < selectionEndLine]]) |
|
3250 |
ifTrue:[ |
|
4528 | 3251 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
248 | 3252 |
]. |
3253 |
||
3254 |
((line == selectionStartLine) |
|
3255 |
and:[(startCol == 1) |
|
3256 |
and:[selectionStartLine < selectionEndLine]]) |
|
3257 |
ifTrue:[ |
|
4528 | 3258 |
self clearMarginOfVisibleLine:visLine with:bgColor. |
4602 | 3259 |
]. |
3260 |
||
3261 |
((line > selectionStartLine) |
|
3262 |
and:[(startCol == 1) |
|
3263 |
and:[selectionStartLine < selectionEndLine |
|
3264 |
and:[line < selectionEndLine]]]) |
|
3265 |
ifTrue:[ |
|
3266 |
self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor. |
|
248 | 3267 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3268 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
3269 |
"Modified: 6.3.1996 / 14:23:26 / cg" |
248 | 3270 |
! ! |
3271 |
||
3272 |
!TextView methodsFor:'searching'! |
|
3273 |
||
2814
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3274 |
clearSearchAction |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3275 |
searchAction := nil. |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3276 |
! |
881a1a20eace
clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents:
2813
diff
changeset
|
3277 |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3278 |
scanFor:aCharacter fromLine:startLine col:startCol forward:forward |
4500 | 3279 |
ifFound:foundBlock |
3280 |
ifNotFound:notFoundBlock |
|
3281 |
"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
|
3282 |
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
|
3283 |
|
4500 | 3284 |
|lineString |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3285 |
line "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3286 |
col "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3287 |
delta "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3288 |
endCol "{ Class: SmallInteger }" |
4500 | 3289 |
cc |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3290 |
maxLine "{ Class: SmallInteger }" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3291 |
| |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3292 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3293 |
col := startCol. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3294 |
line := startLine. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3295 |
forward ifTrue:[ |
4500 | 3296 |
delta := 1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3297 |
] ifFalse:[ |
4500 | 3298 |
delta := -1. |
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3299 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3300 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3301 |
lineString := list at:line. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3302 |
maxLine := list size. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3303 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3304 |
col := col + delta. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3305 |
[true] whileTrue:[ |
4500 | 3306 |
lineString notNil ifTrue:[ |
3307 |
forward ifTrue:[ |
|
3308 |
endCol := lineString size. |
|
3309 |
] ifFalse:[ |
|
3310 |
endCol := 1 |
|
3311 |
]. |
|
3312 |
||
3313 |
col to:endCol by:delta do:[:rCol | |
|
3314 |
cc := lineString at:rCol. |
|
3315 |
cc == aCharacter ifTrue:[ |
|
3316 |
^ foundBlock value:line value:rCol. |
|
3317 |
] |
|
3318 |
]. |
|
3319 |
]. |
|
3320 |
line := line + delta. |
|
3321 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
|
3322 |
^ notFoundBlock value |
|
3323 |
]. |
|
3324 |
lineString := list at:line. |
|
3325 |
forward ifTrue:[ |
|
3326 |
col := 1 |
|
3327 |
] ifFalse:[ |
|
3328 |
col := lineString size |
|
3329 |
] |
|
1322
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3330 |
]. |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3331 |
"not reached" |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3332 |
|
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3333 |
"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
|
3334 |
"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
|
3335 |
! |
b4ffcad003a7
support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
3336 |
|
3802 | 3337 |
searchAction |
3338 |
^ searchAction |
|
3339 |
! |
|
3340 |
||
2807 | 3341 |
searchAction:aSearcherOrSearchBlock |
3342 |
searchAction := aSearcherOrSearchBlock |
|
3343 |
! |
|
3344 |
||
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3345 |
searchAgainInSameDirection |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3346 |
"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
|
3347 |
|
3577 | 3348 |
|ign match| |
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3349 |
|
3981 | 3350 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 3351 |
searchBarActionBlock value:#forward value:self. |
3352 |
^ self |
|
3581 | 3353 |
]. |
3354 |
||
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3355 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 3356 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
3357 |
||
3358 |
self setSearchPatternWithMatchEscapes: match. |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3359 |
lastSearchPattern notNil ifTrue:[ |
4500 | 3360 |
lastSearchDirection == #backward ifTrue:[ |
3361 |
self |
|
3362 |
searchBwd:lastSearchPattern |
|
3363 |
ignoreCase:ign |
|
3364 |
match: match |
|
3365 |
] ifFalse:[ |
|
3366 |
self |
|
3367 |
searchFwd:lastSearchPattern |
|
3368 |
ignoreCase:ign |
|
3369 |
match: match |
|
3370 |
] |
|
1893
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3371 |
] |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3372 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3373 |
"Created: / 03-05-1999 / 15:02:16 / cg" |
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3374 |
"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
|
3375 |
! |
bce50b364466
added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents:
1851
diff
changeset
|
3376 |
|
248 | 3377 |
searchBwd |
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3378 |
"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
|
3379 |
If found, position cursor" |
248 | 3380 |
|
4399 | 3381 |
|ign selectedVariable| |
1353 | 3382 |
|
2811 | 3383 |
searchAction notNil ifTrue:[ |
4500 | 3384 |
"/autosearch is cleared whenever there is search with user selection |
3385 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4178 | 3386 |
]. |
3387 |
||
3388 |
searchAction notNil ifTrue:[ |
|
4500 | 3389 |
"/confusing: this is for autosearch of variables (browse variable uses, for example) |
3390 |
self searchUsingSearchAction:#backward. |
|
3391 |
^ self. |
|
2807 | 3392 |
]. |
3981 | 3393 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 3394 |
searchBarActionBlock value:#backward value:self. |
3395 |
^ self |
|
3581 | 3396 |
]. |
4399 | 3397 |
lastSearchWasVariableSearch ifTrue:[ |
4500 | 3398 |
selectedVariable := self syntaxElementForSelectedVariable. |
3399 |
selectedVariable notNil ifTrue:[ |
|
3400 |
self searchVariableWithSyntaxElement:selectedVariable forward:false. |
|
3401 |
^ self. |
|
3402 |
]. |
|
3403 |
lastSearchWasVariableSearch := false. |
|
4399 | 3404 |
]. |
2807 | 3405 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3406 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
1353 | 3407 |
|
3577 | 3408 |
self setSearchPatternWithMatchEscapes: false. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3409 |
lastSearchPattern isNil ifTrue:[ |
4500 | 3410 |
LastSearchPatterns size > 0 ifTrue:[ |
3411 |
lastSearchPattern := LastSearchPatterns first |
|
3412 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3413 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
3414 |
|
1326 | 3415 |
lastSearchPattern notNil ifTrue:[ |
4500 | 3416 |
lastSearchDirection := #backward. |
3417 |
self rememberSearchPattern:lastSearchPattern. |
|
3418 |
self |
|
3419 |
searchBwd:lastSearchPattern |
|
3420 |
ignoreCase:ign |
|
248 | 3421 |
] |
1326 | 3422 |
|
4399 | 3423 |
"Modified: / 08-03-2012 / 14:26:25 / cg" |
248 | 3424 |
! |
3425 |
||
3426 |
searchBwd:pattern |
|
3427 |
"do a backward search" |
|
3428 |
||
3429 |
self searchBwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3430 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3431 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3432 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
3433 |
"Modified: / 21-09-2006 / 16:48:29 / cg" |
248 | 3434 |
! |
3435 |
||
3436 |
searchBwd:pattern ifAbsent:aBlock |
|
3437 |
"do a backward search" |
|
3438 |
||
4500 | 3439 |
self |
3440 |
searchBwdUsingSpec:(ListView::SearchSpec new |
|
3441 |
pattern:pattern) |
|
3442 |
ifAbsent:aBlock |
|
1326 | 3443 |
|
3444 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
3445 |
! |
|
3446 |
||
3447 |
searchBwd:pattern ignoreCase:ign |
|
3448 |
"do a backward search" |
|
3449 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3450 |
self |
4500 | 3451 |
searchBwd:pattern |
3452 |
ignoreCase:ign |
|
3453 |
ifAbsent:[ |
|
3454 |
self sensor compressKeyPressEventsWithKey:#FindPrev. |
|
3455 |
self showNotFound |
|
3456 |
]. |
|
4408 | 3457 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3458 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
3459 |
|
4408 | 3460 |
"Created: / 13-09-1997 / 06:18:00 / cg" |
3461 |
"Modified: / 23-03-2012 / 12:10:25 / cg" |
|
1326 | 3462 |
! |
3463 |
||
3464 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
3465 |
"do a backward search" |
|
3466 |
||
4500 | 3467 |
self |
3468 |
searchBwdUsingSpec:(ListView::SearchSpec new |
|
3469 |
pattern:pattern |
|
3470 |
ignoreCase:ign) |
|
3471 |
ifAbsent:aBlock |
|
1326 | 3472 |
|
3473 |
"Modified: 13.9.1997 / 01:05:49 / cg" |
|
3474 |
"Created: 13.9.1997 / 06:18:41 / cg" |
|
248 | 3475 |
! |
3476 |
||
3577 | 3477 |
searchBwd:pattern ignoreCase:ign match: match |
3478 |
"do a backward search. |
|
3479 |
match pattern functionality is not yet available for backward search" |
|
3480 |
||
4408 | 3481 |
"/ lastSearchWasMatch := match. |
3577 | 3482 |
self searchBwd:pattern ignoreCase:ign. |
4408 | 3483 |
|
3484 |
"Modified: / 23-03-2012 / 12:12:44 / cg" |
|
3577 | 3485 |
! |
3486 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3487 |
searchBwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3488 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3489 |
|
4500 | 3490 |
self |
3491 |
searchBwdUsingSpec:searchSpec |
|
3492 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3493 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3494 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3495 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3496 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3497 |
"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
|
3498 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3499 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3500 |
searchBwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3501 |
"do a backward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3502 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3503 |
|pos startLine startCol| |
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 |
pos := self startPositionForSearchBackward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3506 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3507 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3508 |
|
4500 | 3509 |
self |
3510 |
searchBackwardUsingSpec:searchSpec |
|
3511 |
startingAtLine:startLine col:startCol |
|
3512 |
ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col] |
|
3513 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3514 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
3515 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3516 |
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3517 |
"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
|
3518 |
|
4500 | 3519 |
self |
3520 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
3521 |
ifFound:[:line :col | |
|
3522 |
self selectFromLine:startLine col:startCol |
|
3523 |
toLine:line col:col] |
|
3524 |
ifNotFound:[self showNotFound] |
|
3525 |
onError:[self beep] |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3526 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3527 |
"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
|
3528 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3529 |
|
248 | 3530 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4500 | 3531 |
ifFound:foundBlock |
3532 |
ifNotFound:notFoundBlock |
|
3533 |
onError:failBlock |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3534 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3535 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
248 | 3536 |
Search for the corresponding character is done forward if its an opening, |
3537 |
backwards if its a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3538 |
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
|
3539 |
If there is a nesting error, evaluate failBlock." |
248 | 3540 |
|
3541 |
^ self |
|
4500 | 3542 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3543 |
ifFound:foundBlock |
|
3544 |
ifNotFound:notFoundBlock |
|
3545 |
onError:failBlock |
|
3546 |
ignoring:(parenthesisSpecification at:#ignore ifAbsent:#()) "/ #( $' $" '$[' '$]' '${' '$)' ) |
|
3478 | 3547 |
|
3548 |
"Modified: / 12-04-2007 / 11:24:24 / cg" |
|
248 | 3549 |
! |
3550 |
||
3551 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
4500 | 3552 |
ifFound:foundBlock |
3553 |
ifNotFound:notFoundBlock |
|
3554 |
onError:failBlock |
|
3555 |
ignoring:ignoreSet |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3556 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3557 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
248 | 3558 |
Search for the corresponding character is done forward if its an opening, |
3559 |
backwards if its a closing parenthesis. |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3560 |
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
|
3561 |
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
|
3562 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3563 |
^ self |
4500 | 3564 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3565 |
ifFound:foundBlock |
|
3566 |
ifNotFound:notFoundBlock |
|
3567 |
onError:failBlock |
|
3568 |
openingCharacters: (parenthesisSpecification at:#open) "/ #( $( $[ ${ "$> $<") |
|
3569 |
closingCharacters: (parenthesisSpecification at:#close) "/ #( $) $] $} "$> $<") |
|
3570 |
ignoredCharacters: ignoreSet |
|
3571 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/ |
|
3572 |
||
3573 |
"/ |i direction lineString |
|
3574 |
"/ parChar charSet closingChar |
|
3575 |
"/ ignoring |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3576 |
"/ line "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3577 |
"/ col "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3578 |
"/ delta "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3579 |
"/ endCol "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3580 |
"/ runCol "{ Class: SmallInteger }" |
4500 | 3581 |
"/ cc prevCC nextCC incSet decSet |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3582 |
"/ nesting "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3583 |
"/ maxLine "{ Class: SmallInteger }" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3584 |
"/ ign skip anySet| |
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 |
"/ charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3587 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3588 |
"/ parChar := self characterAtLine:startLine col:startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3589 |
"/ i := charSet indexOf:parChar. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3590 |
"/ i == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3591 |
"/ ^ failBlock value "not a parenthesis" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3592 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3593 |
"/ 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
|
3594 |
"/ closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3595 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3596 |
"/ col := startCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3597 |
"/ line := startLine. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3598 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3599 |
"/ delta := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3600 |
"/ incSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3601 |
"/ decSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3602 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3603 |
"/ delta := -1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3604 |
"/ incSet := #( $) $] $} "$>" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3605 |
"/ decSet := #( $( $[ ${ "$<" ). |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3606 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3607 |
"/ anySet := Set new. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3608 |
"/ anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3609 |
"/ anySet := (anySet select:[:c | c isCharacter]) asString. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3610 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3611 |
"/ nesting := 1. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3612 |
"/ ignoring := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3613 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3614 |
"/ maxLine := list size. |
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 := col + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3617 |
"/ [nesting ~~ 0] whileTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3618 |
"/ (lineString notNil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3619 |
"/ and:[lineString includesAny:anySet]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3620 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3621 |
"/ endCol := lineString size. |
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 |
"/ endCol := 1 |
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 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3626 |
"/ col to:endCol by:delta do:[:rCol | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3627 |
"/ runCol := rCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3628 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3629 |
"/ cc := lineString at:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3630 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3631 |
"/ nextCC := lineString at:runCol+1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3632 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3633 |
"/ nextCC := nil |
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 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3636 |
"/ prevCC := lineString at:runCol-1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3637 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3638 |
"/ prevCC := nil |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3639 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3640 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3641 |
"/ ign := skip := false. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3642 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3643 |
"/ "/ check for comments. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3644 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3645 |
"/ ((cc == $" and:[nextCC == $/]) |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3646 |
"/ or:[prevCC == $$ ]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3647 |
"/ "/ do nothing |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3648 |
"/ |
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 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3651 |
"/ ignoreSet do:[:ignore | |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3652 |
"/ ignore == cc ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3653 |
"/ ign := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3654 |
"/ ] ifFalse:[ |
4500 | 3655 |
"/ ignore isString ifTrue:[ |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3656 |
"/ cc == (ignore at:2) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3657 |
"/ runCol > 1 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3658 |
"/ (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
|
3659 |
"/ skip := true |
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 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3663 |
"/ cc == (ignore at:1) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3664 |
"/ runCol < lineString size ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3665 |
"/ (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
|
3666 |
"/ skip := true |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3667 |
"/ ] |
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 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3671 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3672 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3673 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3674 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3675 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3676 |
"/ ign ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3677 |
"/ ignoring := ignoring not |
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 |
"/ ignoring ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3681 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3682 |
"/ (incSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3683 |
"/ nesting := nesting + 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3684 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3685 |
"/ (decSet includes:cc) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3686 |
"/ nesting := nesting - 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3687 |
"/ ] |
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 |
"/ ] |
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 |
"/ nesting == 0 ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3693 |
"/ "check if legal" |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3694 |
"/ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3695 |
"/ skip ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3696 |
"/ cc == closingChar ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3697 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3698 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3699 |
"/ ^ foundBlock value:line value:runCol. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3700 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3701 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3702 |
"/ ]. |
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 |
"/ line := line + delta. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3705 |
"/ (line < 1 or:[line > maxLine]) ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3706 |
"/ ^ failBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3707 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3708 |
"/ lineString := list at:line. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3709 |
"/ direction == #fwd ifTrue:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3710 |
"/ col := 1 |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3711 |
"/ ] ifFalse:[ |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3712 |
"/ col := lineString size |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3713 |
"/ ] |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3714 |
"/ ]. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3715 |
"/ ^ notFoundBlock value |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3716 |
|
3478 | 3717 |
"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
|
3718 |
! |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3719 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3720 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
4500 | 3721 |
ifFound:foundBlock |
3722 |
ifNotFound:notFoundBlock |
|
3723 |
onError:failBlock |
|
3724 |
openingCharacters:openingCharacters |
|
3725 |
closingCharacters:closingCharacters |
|
3605 | 3726 |
|
3727 |
"search for a matching parenthesis; start search with character at startLine/startCol. |
|
3728 |
Search for the corresponding character is done forward if its an opening, |
|
3729 |
backwards if its a closing parenthesis. |
|
3730 |
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not. |
|
3731 |
If there is a nesting error, evaluate failBlock." |
|
3732 |
||
3733 |
^ self |
|
4500 | 3734 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
3735 |
ifFound:foundBlock |
|
3736 |
ifNotFound:notFoundBlock |
|
3737 |
onError:failBlock |
|
3738 |
openingCharacters: openingCharacters |
|
3739 |
closingCharacters: closingCharacters |
|
3740 |
ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#()) |
|
3741 |
specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/ |
|
3742 |
||
3743 |
"/ |i direction lineString |
|
3744 |
"/ parChar charSet closingChar |
|
3745 |
"/ ignoring |
|
3605 | 3746 |
"/ line "{ Class: SmallInteger }" |
3747 |
"/ col "{ Class: SmallInteger }" |
|
3748 |
"/ delta "{ Class: SmallInteger }" |
|
3749 |
"/ endCol "{ Class: SmallInteger }" |
|
3750 |
"/ runCol "{ Class: SmallInteger }" |
|
4500 | 3751 |
"/ cc prevCC nextCC incSet decSet |
3605 | 3752 |
"/ nesting "{ Class: SmallInteger }" |
3753 |
"/ maxLine "{ Class: SmallInteger }" |
|
3754 |
"/ ign skip anySet| |
|
3755 |
"/ |
|
3756 |
"/ charSet := #( $( $) $[ $] ${ $} " $< $> " ). |
|
3757 |
"/ |
|
3758 |
"/ parChar := self characterAtLine:startLine col:startCol. |
|
3759 |
"/ i := charSet indexOf:parChar. |
|
3760 |
"/ i == 0 ifTrue:[ |
|
3761 |
"/ ^ failBlock value "not a parenthesis" |
|
3762 |
"/ ]. |
|
3763 |
"/ direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i. |
|
3764 |
"/ closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i. |
|
3765 |
"/ |
|
3766 |
"/ col := startCol. |
|
3767 |
"/ line := startLine. |
|
3768 |
"/ direction == #fwd ifTrue:[ |
|
3769 |
"/ delta := 1. |
|
3770 |
"/ incSet := #( $( $[ ${ "$<" ). |
|
3771 |
"/ decSet := #( $) $] $} "$>" ). |
|
3772 |
"/ ] ifFalse:[ |
|
3773 |
"/ delta := -1. |
|
3774 |
"/ incSet := #( $) $] $} "$>" ). |
|
3775 |
"/ decSet := #( $( $[ ${ "$<" ). |
|
3776 |
"/ ]. |
|
3777 |
"/ anySet := Set new. |
|
3778 |
"/ anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
3779 |
"/ anySet := (anySet select:[:c | c isCharacter]) asString. |
|
3780 |
"/ |
|
3781 |
"/ nesting := 1. |
|
3782 |
"/ ignoring := false. |
|
3783 |
"/ lineString := list at:line. |
|
3784 |
"/ maxLine := list size. |
|
3785 |
"/ |
|
3786 |
"/ col := col + delta. |
|
3787 |
"/ [nesting ~~ 0] whileTrue:[ |
|
3788 |
"/ (lineString notNil |
|
3789 |
"/ and:[lineString includesAny:anySet]) ifTrue:[ |
|
3790 |
"/ direction == #fwd ifTrue:[ |
|
3791 |
"/ endCol := lineString size. |
|
3792 |
"/ ] ifFalse:[ |
|
3793 |
"/ endCol := 1 |
|
3794 |
"/ ]. |
|
3795 |
"/ |
|
3796 |
"/ col to:endCol by:delta do:[:rCol | |
|
3797 |
"/ runCol := rCol. |
|
3798 |
"/ |
|
3799 |
"/ cc := lineString at:runCol. |
|
3800 |
"/ runCol < lineString size ifTrue:[ |
|
3801 |
"/ nextCC := lineString at:runCol+1 |
|
3802 |
"/ ] ifFalse:[ |
|
3803 |
"/ nextCC := nil |
|
3804 |
"/ ]. |
|
3805 |
"/ runCol > 1 ifTrue:[ |
|
3806 |
"/ prevCC := lineString at:runCol-1 |
|
3807 |
"/ ] ifFalse:[ |
|
3808 |
"/ prevCC := nil |
|
3809 |
"/ ]. |
|
3810 |
"/ |
|
3811 |
"/ ign := skip := false. |
|
3812 |
"/ |
|
3813 |
"/ "/ check for comments. |
|
3814 |
"/ |
|
3815 |
"/ ((cc == $" and:[nextCC == $/]) |
|
3816 |
"/ or:[prevCC == $$ ]) ifTrue:[ |
|
3817 |
"/ "/ do nothing |
|
3818 |
"/ |
|
3819 |
"/ skip := true. |
|
3820 |
"/ ] ifFalse:[ |
|
3821 |
"/ ignoreSet do:[:ignore | |
|
3822 |
"/ ignore == cc ifTrue:[ |
|
3823 |
"/ ign := true |
|
3824 |
"/ ] ifFalse:[ |
|
4500 | 3825 |
"/ ignore isString ifTrue:[ |
3605 | 3826 |
"/ cc == (ignore at:2) ifTrue:[ |
3827 |
"/ runCol > 1 ifTrue:[ |
|
3828 |
"/ (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
|
3829 |
"/ skip := true |
|
3830 |
"/ ] |
|
3831 |
"/ ] |
|
3832 |
"/ ] ifFalse:[ |
|
3833 |
"/ cc == (ignore at:1) ifTrue:[ |
|
3834 |
"/ runCol < lineString size ifTrue:[ |
|
3835 |
"/ (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
|
3836 |
"/ skip := true |
|
3837 |
"/ ] |
|
3838 |
"/ ] |
|
3839 |
"/ ] |
|
3840 |
"/ ] |
|
3841 |
"/ ] |
|
3842 |
"/ ] |
|
3843 |
"/ ] |
|
3844 |
"/ ]. |
|
3845 |
"/ |
|
3846 |
"/ ign ifTrue:[ |
|
3847 |
"/ ignoring := ignoring not |
|
3848 |
"/ ]. |
|
3849 |
"/ |
|
3850 |
"/ ignoring ifFalse:[ |
|
3851 |
"/ skip ifFalse:[ |
|
3852 |
"/ (incSet includes:cc) ifTrue:[ |
|
3853 |
"/ nesting := nesting + 1 |
|
3854 |
"/ ] ifFalse:[ |
|
3855 |
"/ (decSet includes:cc) ifTrue:[ |
|
3856 |
"/ nesting := nesting - 1 |
|
3857 |
"/ ] |
|
3858 |
"/ ] |
|
3859 |
"/ ] |
|
3860 |
"/ ]. |
|
3861 |
"/ |
|
3862 |
"/ nesting == 0 ifTrue:[ |
|
3863 |
"/ "check if legal" |
|
3864 |
"/ |
|
3865 |
"/ skip ifFalse:[ |
|
3866 |
"/ cc == closingChar ifFalse:[ |
|
3867 |
"/ ^ failBlock value |
|
3868 |
"/ ]. |
|
3869 |
"/ ^ foundBlock value:line value:runCol. |
|
3870 |
"/ ] |
|
3871 |
"/ ] |
|
3872 |
"/ ]. |
|
3873 |
"/ ]. |
|
3874 |
"/ line := line + delta. |
|
3875 |
"/ (line < 1 or:[line > maxLine]) ifTrue:[ |
|
3876 |
"/ ^ failBlock value |
|
3877 |
"/ ]. |
|
3878 |
"/ lineString := list at:line. |
|
3879 |
"/ direction == #fwd ifTrue:[ |
|
3880 |
"/ col := 1 |
|
3881 |
"/ ] ifFalse:[ |
|
3882 |
"/ col := lineString size |
|
3883 |
"/ ] |
|
3884 |
"/ ]. |
|
3885 |
"/ ^ notFoundBlock value |
|
3886 |
||
3887 |
"Modified: / 12-04-2007 / 11:25:36 / cg" |
|
3888 |
! |
|
3889 |
||
3890 |
searchForMatchingParenthesisFromLine:startLine col:startCol |
|
4500 | 3891 |
ifFound:foundBlock |
3892 |
ifNotFound:notFoundBlock |
|
3893 |
onError:failBlock |
|
3894 |
openingCharacters:openingCharacters |
|
3895 |
closingCharacters:closingCharacters |
|
3896 |
ignoredCharacters:ignoreSet |
|
3897 |
specialEOLComment:eolCommentSequence |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3898 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3899 |
"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
|
3900 |
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
|
3901 |
backwards if its a closing parenthesis. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3902 |
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
|
3903 |
If there is a nesting error, evaluate failBlock." |
248 | 3904 |
|
4500 | 3905 |
|i direction lineString |
3906 |
parChar charSet closingChar |
|
3907 |
ignoring |
|
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3908 |
line "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3909 |
col "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3910 |
delta "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3911 |
endCol "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3912 |
runCol "{ Class: SmallInteger }" |
4500 | 3913 |
cc prevCC nextCC incSet decSet |
770
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3914 |
nesting "{ Class: SmallInteger }" |
a41466e3dfaa
use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents:
758
diff
changeset
|
3915 |
maxLine "{ Class: SmallInteger }" |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3916 |
ign skip anySet |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3917 |
eol1 eol2| |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3918 |
|
2772
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
3919 |
self assert:(openingCharacters size == closingCharacters size). |
4e04a3bf399f
check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents:
2756
diff
changeset
|
3920 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3921 |
charSet := openingCharacters , closingCharacters. |
248 | 3922 |
|
3923 |
parChar := self characterAtLine:startLine col:startCol. |
|
3924 |
i := charSet indexOf:parChar. |
|
3925 |
i == 0 ifTrue:[ |
|
4500 | 3926 |
^ failBlock value "not a parenthesis" |
248 | 3927 |
]. |
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3928 |
|
3858 | 3929 |
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
|
3930 |
closingChar := (closingCharacters , openingCharacters) at:i. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3931 |
|
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3932 |
eol1 := eolCommentSequence at:1 ifAbsent:nil. |
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
3933 |
eol2 := eolCommentSequence at:2 ifAbsent:nil. |
248 | 3934 |
|
3935 |
col := startCol. |
|
3936 |
line := startLine. |
|
3937 |
direction == #fwd ifTrue:[ |
|
4500 | 3938 |
delta := 1. |
3939 |
incSet := openingCharacters. |
|
3940 |
decSet := closingCharacters. |
|
248 | 3941 |
] ifFalse:[ |
4500 | 3942 |
delta := -1. |
3943 |
incSet := closingCharacters. |
|
3944 |
decSet := openingCharacters. |
|
248 | 3945 |
]. |
1454 | 3946 |
anySet := Set new. |
3947 |
anySet addAll:incSet; addAll:decSet; addAll:ignoreSet. |
|
3948 |
anySet := (anySet select:[:c | c isCharacter]) asString. |
|
248 | 3949 |
|
3950 |
nesting := 1. |
|
3951 |
ignoring := false. |
|
3952 |
lineString := list at:line. |
|
3953 |
maxLine := list size. |
|
3954 |
||
3955 |
col := col + delta. |
|
3956 |
[nesting ~~ 0] whileTrue:[ |
|
4500 | 3957 |
(lineString notNil |
3958 |
and:[lineString includesAny:anySet]) ifTrue:[ |
|
3959 |
direction == #fwd ifTrue:[ |
|
3960 |
endCol := lineString size. |
|
3961 |
] ifFalse:[ |
|
3962 |
endCol := 1 |
|
3963 |
]. |
|
3964 |
||
3965 |
col to:endCol by:delta do:[:rCol | |
|
3966 |
runCol := rCol. |
|
3967 |
||
3968 |
cc := lineString at:runCol. |
|
3969 |
runCol < lineString size ifTrue:[ |
|
3970 |
nextCC := lineString at:runCol+1 |
|
3971 |
] ifFalse:[ |
|
3972 |
nextCC := nil |
|
3973 |
]. |
|
3974 |
runCol > 1 ifTrue:[ |
|
3975 |
prevCC := lineString at:runCol-1 |
|
3976 |
] ifFalse:[ |
|
3977 |
prevCC := nil |
|
3978 |
]. |
|
3979 |
||
3980 |
ign := skip := false. |
|
3981 |
||
3982 |
"/ check for comments. |
|
3983 |
||
3984 |
((cc == eol1 and:[nextCC == eol2]) |
|
3985 |
or:[prevCC == $$ ]) ifTrue:[ |
|
3986 |
"/ do nothing |
|
3987 |
||
3988 |
skip := true. |
|
3989 |
] ifFalse:[ |
|
3990 |
ignoreSet do:[:ignore | |
|
3991 |
ignore == cc ifTrue:[ |
|
3992 |
ign := true |
|
3993 |
] ifFalse:[ |
|
3994 |
ignore isString ifTrue:[ |
|
3995 |
cc == (ignore at:2) ifTrue:[ |
|
3996 |
runCol > 1 ifTrue:[ |
|
3997 |
(lineString at:(runCol-1)) == (ignore at:1) ifTrue:[ |
|
3998 |
skip := true |
|
3999 |
] |
|
4000 |
] |
|
4001 |
] ifFalse:[ |
|
4002 |
cc == (ignore at:1) ifTrue:[ |
|
4003 |
runCol < lineString size ifTrue:[ |
|
4004 |
(lineString at:(runCol+1)) == (ignore at:2) ifTrue:[ |
|
4005 |
skip := true |
|
4006 |
] |
|
4007 |
] |
|
4008 |
] |
|
4009 |
] |
|
4010 |
] |
|
4011 |
] |
|
4012 |
] |
|
4013 |
]. |
|
4014 |
||
4015 |
ign ifTrue:[ |
|
4016 |
ignoring := ignoring not |
|
4017 |
]. |
|
4018 |
||
4019 |
ignoring ifFalse:[ |
|
4020 |
skip ifFalse:[ |
|
4021 |
(incSet includes:cc) ifTrue:[ |
|
4022 |
nesting := nesting + 1 |
|
4023 |
] ifFalse:[ |
|
4024 |
(decSet includes:cc) ifTrue:[ |
|
4025 |
nesting := nesting - 1 |
|
4026 |
] |
|
4027 |
] |
|
4028 |
] |
|
4029 |
]. |
|
4030 |
||
4031 |
nesting == 0 ifTrue:[ |
|
4032 |
"check if legal" |
|
4033 |
skip ifFalse:[ |
|
4034 |
cc == closingChar ifFalse:[ |
|
4035 |
^ failBlock value |
|
4036 |
]. |
|
4037 |
^ foundBlock value:line value:runCol. |
|
4038 |
] |
|
4039 |
] |
|
4040 |
]. |
|
4041 |
]. |
|
4042 |
line := line + delta. |
|
4043 |
(line < 1 or:[line > maxLine]) ifTrue:[ |
|
4044 |
^ failBlock value |
|
4045 |
]. |
|
4046 |
lineString := list at:line. |
|
4047 |
direction == #fwd ifTrue:[ |
|
4048 |
col := 1 |
|
4049 |
] ifFalse:[ |
|
4050 |
col := lineString size |
|
4051 |
] |
|
248 | 4052 |
]. |
4053 |
^ notFoundBlock value |
|
4054 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
4055 |
"Modified: 15.10.1996 / 12:22:30 / cg" |
248 | 4056 |
! |
4057 |
||
4058 |
searchFwd |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4059 |
"search forward for the same pattern or selection again" |
248 | 4060 |
|
4399 | 4061 |
|ign match variable| |
1353 | 4062 |
|
2811 | 4063 |
searchAction notNil ifTrue:[ |
4500 | 4064 |
"/ autosearch is cleared whenever there is search with user selection |
4065 |
(self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction]. |
|
4177 | 4066 |
]. |
4067 |
||
4068 |
searchAction notNil ifTrue:[ |
|
4500 | 4069 |
"/ confusing: this is for autosearch of variables (browse variable uses, for example) |
4070 |
self searchUsingSearchAction:#forward. |
|
4071 |
^ self. |
|
2807 | 4072 |
]. |
3981 | 4073 |
searchBarActionBlock notNil ifTrue:[ |
4500 | 4074 |
searchBarActionBlock value:#forward value:self. |
4075 |
^ self |
|
3581 | 4076 |
]. |
4399 | 4077 |
lastSearchWasVariableSearch ifTrue:[ |
4500 | 4078 |
variable := self syntaxElementForSelectedVariable. |
4079 |
variable notNil ifTrue:[ |
|
4080 |
self searchVariableWithSyntaxElement:variable forward:true. |
|
4081 |
^ self. |
|
4082 |
]. |
|
4083 |
lastSearchWasVariableSearch := false. |
|
4399 | 4084 |
]. |
3581 | 4085 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4086 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
3577 | 4087 |
match := lastSearchWasMatch ? LastSearchWasMatch ? false. |
1353 | 4088 |
|
248 | 4089 |
selectStyle == #wordLeft ifTrue:[ |
4500 | 4090 |
" |
4091 |
remove the space from the selection |
|
4092 |
" |
|
4093 |
selectionStartCol := selectionStartCol + 1. |
|
4094 |
super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1. |
|
4095 |
selectStyle := #word. |
|
4096 |
self selectionChanged. |
|
248 | 4097 |
]. |
3577 | 4098 |
self setSearchPatternWithMatchEscapes: match. |
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4099 |
|
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4100 |
lastSearchPattern isNil ifTrue:[ |
4500 | 4101 |
LastSearchPatterns size > 0 ifTrue:[ |
4102 |
lastSearchPattern := LastSearchPatterns first |
|
4103 |
] |
|
2414
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4104 |
]. |
ec98bcbd4c61
if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
4105 |
|
1326 | 4106 |
lastSearchPattern notNil ifTrue:[ |
4500 | 4107 |
self rememberSearchPattern:lastSearchPattern. |
4108 |
lastSearchDirection := #forward. |
|
4109 |
self |
|
4110 |
searchFwd:lastSearchPattern |
|
4111 |
ignoreCase:ign |
|
4112 |
match: match |
|
248 | 4113 |
] |
1326 | 4114 |
|
4399 | 4115 |
"Modified: / 08-03-2012 / 14:25:42 / cg" |
248 | 4116 |
! |
4117 |
||
4118 |
searchFwd:pattern |
|
4119 |
"do a forward search" |
|
4120 |
||
4121 |
self searchFwd:pattern ifAbsent:[self showNotFound]. |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4122 |
"/ lastSearchIgnoredCase := false. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4123 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4124 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4125 |
"Modified: / 21-09-2006 / 16:52:04 / cg" |
248 | 4126 |
! |
4127 |
||
4128 |
searchFwd:pattern ifAbsent:aBlock |
|
4129 |
"do a forward search" |
|
4130 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4131 |
self |
4500 | 4132 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4133 |
pattern:pattern) |
|
4134 |
ifAbsent:aBlock |
|
1326 | 4135 |
|
3399
c350a2e3efee
dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents:
3394
diff
changeset
|
4136 |
"Modified: / 21-09-2006 / 16:51:28 / cg" |
1326 | 4137 |
! |
4138 |
||
4139 |
searchFwd:pattern ignoreCase:ign |
|
4140 |
"do a forward search" |
|
4141 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4142 |
self |
4500 | 4143 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4144 |
pattern:pattern |
|
4145 |
ignoreCase:ign) |
|
4146 |
ifAbsent:[ |
|
4147 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4148 |
self showNotFound |
|
4149 |
]. |
|
4408 | 4150 |
"/ lastSearchIgnoredCase := ign. |
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4151 |
lastSearchPattern := pattern string |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4152 |
|
4408 | 4153 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4154 |
"Modified: / 23-03-2012 / 12:09:59 / cg" |
|
1326 | 4155 |
! |
4156 |
||
4157 |
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
4158 |
"do a forward search" |
|
4159 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4160 |
self |
4500 | 4161 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4162 |
pattern:pattern |
|
4163 |
ignoreCase:ign) |
|
4164 |
ifAbsent:aBlock |
|
1326 | 4165 |
|
4166 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4167 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
248 | 4168 |
! |
4169 |
||
3577 | 4170 |
searchFwd:pattern ignoreCase:ign match: match |
4171 |
"do a forward search" |
|
4172 |
||
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4173 |
self |
4500 | 4174 |
searchFwdUsingSpec:(ListView::SearchSpec new |
4175 |
pattern:pattern |
|
4176 |
ignoreCase:ign |
|
4177 |
match:match) |
|
4178 |
ifAbsent:[ |
|
4179 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4180 |
self showNotFound |
|
4181 |
]. |
|
4408 | 4182 |
"/ lastSearchIgnoredCase := ign. |
4183 |
"/ lastSearchWasMatch := match. |
|
3577 | 4184 |
lastSearchPattern := pattern string |
4185 |
||
4408 | 4186 |
"Created: / 13-09-1997 / 06:18:13 / cg" |
4187 |
"Modified: / 23-03-2012 / 12:12:47 / cg" |
|
3577 | 4188 |
! |
4189 |
||
4190 |
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock |
|
4191 |
"do a forward search" |
|
4192 |
||
4500 | 4193 |
self |
4194 |
searchFwdUsingSpec:(ListView::SearchSpec new |
|
4195 |
pattern:pattern |
|
4196 |
ignoreCase:ign |
|
4197 |
match:match) |
|
4198 |
ifAbsent:aBlock |
|
3581 | 4199 |
|
4200 |
"Modified: 13.9.1997 / 01:05:35 / cg" |
|
4201 |
"Created: 13.9.1997 / 06:18:27 / cg" |
|
4202 |
! |
|
4203 |
||
4204 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
4205 |
"do a forward search" |
|
4206 |
||
4500 | 4207 |
self |
4208 |
searchFwdUsingSpec:(ListView::SearchSpec new |
|
4209 |
pattern:pattern |
|
4210 |
ignoreCase:ign |
|
4211 |
match:match) |
|
4212 |
startingAtLine:startLine col:startCol |
|
4213 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4214 |
! |
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 |
searchFwdUsingSpec:searchSpec |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4217 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4218 |
|
4500 | 4219 |
self |
4220 |
searchFwdUsingSpec:searchSpec |
|
4221 |
ifAbsent:[self showNotFound]. |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4222 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4223 |
"/ lastSearchIgnoredCase := false. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4224 |
lastSearchPattern := searchSpec pattern string |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4225 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4226 |
"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
|
4227 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4228 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4229 |
searchFwdUsingSpec:searchSpec ifAbsent:aBlock |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4230 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4231 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4232 |
|pos startLine startCol| |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4233 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4234 |
pos := self startPositionForSearchForward. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4235 |
startLine := pos y. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4236 |
startCol := pos x. |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4237 |
|
4500 | 4238 |
self |
4239 |
searchFwdUsingSpec:searchSpec |
|
4240 |
startingAtLine:startLine col:startCol |
|
4241 |
ifAbsent:aBlock |
|
4462
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4242 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4243 |
"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
|
4244 |
"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
|
4245 |
! |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4246 |
|
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4247 |
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
|
4248 |
"do a forward search" |
e7580f29c467
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4457
diff
changeset
|
4249 |
|
4500 | 4250 |
self |
4251 |
searchForwardUsingSpec:searchSpec |
|
4252 |
startingAtLine:startLine col:startCol |
|
4253 |
ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col] |
|
4254 |
ifAbsent:aBlock |
|
3577 | 4255 |
! |
4256 |
||
248 | 4257 |
searchPattern |
4258 |
"return the last search pattern" |
|
4259 |
||
1326 | 4260 |
^ lastSearchPattern |
248 | 4261 |
! |
4262 |
||
2807 | 4263 |
searchUsingSearchAction:direction |
4500 | 4264 |
self |
4265 |
searchUsingSearchAction:direction |
|
4266 |
ifAbsent:[ |
|
4267 |
self sensor compressKeyPressEventsWithKey:#FindNext. |
|
4268 |
self showNotFound |
|
4269 |
] |
|
2816 | 4270 |
! |
4271 |
||
4272 |
searchUsingSearchAction:direction ifAbsent:notFoundAction |
|
2807 | 4273 |
|pos startLine startCol| |
4274 |
||
4500 | 4275 |
pos := direction == #backward |
4276 |
ifTrue:[self startPositionForSearchBackward] |
|
4277 |
ifFalse:[self startPositionForSearchForward]. |
|
2807 | 4278 |
startLine := pos y. |
4279 |
startCol := pos x. |
|
4280 |
||
4281 |
searchAction notNil ifTrue:[ |
|
4500 | 4282 |
searchAction |
4283 |
value:direction |
|
4284 |
value:startLine |
|
4285 |
value:startCol |
|
4286 |
value:[:line :col | self selectFromLine:line toLine:line] |
|
4287 |
value:notFoundAction. |
|
4288 |
self hasSelection ifTrue: [ |
|
4289 |
self changeTypeOfSelectionTo: #searchAction. |
|
4290 |
]. |
|
2807 | 4291 |
]. |
4292 |
! |
|
4293 |
||
248 | 4294 |
setSearchPattern |
4295 |
"set the searchpattern from the selection if there is one" |
|
4296 |
||
3577 | 4297 |
self setSearchPatternWithMatchEscapes: false. |
248 | 4298 |
! |
4299 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4300 |
setSearchPattern:aStringOrNil |
248 | 4301 |
"set the searchpattern for future searches" |
4302 |
||
3904
dd4c2dace4f5
changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
4303 |
aStringOrNil isEmptyOrNil ifTrue:[ |
5247 | 4304 |
lastSearchPattern := nil. |
248 | 4305 |
] ifFalse:[ |
5247 | 4306 |
"/ not withoutSeparators: may want to search for spaces... |
4307 |
lastSearchPattern := aStringOrNil asString "withoutSeparators" string. |
|
1769
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4308 |
]. |
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4309 |
|
5e272292723b
remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents:
1766
diff
changeset
|
4310 |
"Modified: / 6.3.1999 / 23:47:36 / cg" |
248 | 4311 |
! |
4312 |
||
2200 | 4313 |
setSearchPattern:aString ignoreCase:aBoolean |
4314 |
"set the searchpattern and caseIgnore for future searches" |
|
4315 |
||
4316 |
self setSearchPattern:aString. |
|
4317 |
lastSearchIgnoredCase := aBoolean. |
|
4318 |
! |
|
4319 |
||
3577 | 4320 |
setSearchPatternWithMatchEscapes: match |
4321 |
"set the searchpattern from the selection if there is one" |
|
4322 |
||
4323 |
|sel searchPattern | |
|
4324 |
||
4325 |
"/ clickPos isNil ifTrue:[^ self]. |
|
4326 |
||
4327 |
sel := self selection. |
|
4328 |
sel notNil ifTrue:[ |
|
4500 | 4329 |
searchPattern := sel asString. |
4330 |
match ifTrue:[searchPattern := searchPattern withMatchEscapes]. |
|
4331 |
self setSearchPattern:searchPattern. |
|
3577 | 4332 |
] |
4333 |
||
4334 |
"Modified: / 6.3.1999 / 23:48:04 / cg" |
|
4335 |
! |
|
4336 |
||
248 | 4337 |
showMatch:pattern atLine:line col:col |
4338 |
"after a search, highlight the matched pattern. |
|
4339 |
The code below needs a rewrite to take care of match-characters |
|
4340 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4341 |
||
4120 | 4342 |
self showMatch:pattern isMatch:true atLine:line col:col |
4343 |
! |
|
4344 |
||
4345 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
|
4346 |
"after a search, highlight the matched pattern. |
|
4347 |
The code below needs a rewrite to take care of match-characters |
|
4348 |
(for now, it only highlights simple patterns and '*string*' correctly)" |
|
4349 |
||
248 | 4350 |
|realPattern| |
4351 |
||
4352 |
realPattern := pattern. |
|
4120 | 4353 |
|
4354 |
isMatch ifTrue: [ |
|
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4355 |
(realPattern startsWith:$*) ifTrue:[ |
5093 | 4356 |
realPattern := realPattern copyButFirst |
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4357 |
]. |
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4358 |
(realPattern endsWith:$*) ifTrue:[ |
5092 | 4359 |
realPattern := realPattern copyButLast |
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4360 |
]. |
248 | 4361 |
]. |
4362 |
||
4363 |
self selectFromLine:line col:col |
|
4567
33be833bfcbf
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4554
diff
changeset
|
4364 |
toLine:line col:(col + realPattern size - 1). |
248 | 4365 |
self makeLineVisible:line |
4366 |
! |
|
4367 |
||
4368 |
showNotFound |
|
4369 |
"search not found - tell user by beeping and changing |
|
4370 |
cursor for a while (sometimes I work with a headset :-) |
|
4371 |
(used to be: tell user by changing cursor for a while)" |
|
4372 |
||
5052 | 4373 |
self withCursor:(Cursor cross) do:[ |
4374 |
self beep. |
|
4375 |
Processor activeProcess millisecondDelay:200. |
|
1028 | 4376 |
] |
4377 |
||
4378 |
"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
|
4379 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4380 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4381 |
startPositionForSearchBackward |
2822 | 4382 |
^ self startPositionForSearchBackwardBasedOnSelection |
4383 |
! |
|
4384 |
||
4385 |
startPositionForSearchBackwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4386 |
|startLine startCol| |
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 |
selectionStartLine notNil ifTrue:[ |
4500 | 4389 |
startLine := selectionStartLine. |
4390 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4391 |
] ifFalse:[ |
4500 | 4392 |
startLine := 1. |
4393 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4394 |
]. |
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 |
^ startCol @ startLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4397 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4398 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4399 |
startPositionForSearchForward |
2822 | 4400 |
^ self startPositionForSearchForwardBasedOnSelection |
4401 |
! |
|
4402 |
||
4403 |
startPositionForSearchForwardBasedOnSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4404 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4405 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4406 |
selectionStartLine notNil ifTrue:[ |
4500 | 4407 |
startLine := selectionStartLine. |
4408 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4409 |
] ifFalse:[ |
4500 | 4410 |
startLine := 1. |
4411 |
startCol := 1 |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4412 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4413 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2752
diff
changeset
|
4414 |
^ startCol @ startLine |
248 | 4415 |
! ! |
4416 |
||
4417 |
!TextView methodsFor:'selections'! |
|
4418 |
||
2604
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4419 |
changeTypeOfSelectionTo:newType |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4420 |
"ignored here - but redefined in subclasses which |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4421 |
differentiate between pasted- and user-selections" |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4422 |
! |
2031eca912aa
selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents:
2600
diff
changeset
|
4423 |
|
458 | 4424 |
expandSelectionDown |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4425 |
|l t| |
458 | 4426 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4427 |
selectionStartLine notNil ifTrue:[ |
4787 | 4428 |
expandingTop == true ifTrue:[ |
4429 |
l := selectionStartLine. |
|
4430 |
selectionStartLine := selectionStartLine + 1. |
|
4431 |
(selectionStartLine > clickLine |
|
4432 |
or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]]) |
|
4433 |
ifTrue:[ |
|
4434 |
t := selectionStartLine. |
|
4435 |
selectionStartLine := selectionEndLine. |
|
4436 |
selectionEndLine := t. |
|
4437 |
t := selectionStartCol. |
|
4438 |
selectionStartCol := selectionEndCol. |
|
4439 |
selectionEndCol := t. |
|
4440 |
expandingTop := false |
|
4441 |
]. |
|
4442 |
] ifFalse:[ |
|
4443 |
l := selectionEndLine. |
|
4444 |
selectionEndLine := selectionEndLine + 1. |
|
4445 |
]. |
|
4500 | 4446 |
"/ self redrawLine:l. |
2442 | 4447 |
"/ self redrawLine:l+1. |
4787 | 4448 |
self validateNewSelection. |
4449 |
self setPrimarySelection. |
|
4450 |
self selectionChanged. |
|
4451 |
self redrawFromLine:l to:l+1. |
|
4452 |
self makeSelectionVisible. |
|
458 | 4453 |
]. |
4454 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4455 |
"Created: / 01-03-1996 / 23:35:08 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4456 |
"Modified: / 18-03-1996 / 17:18:15 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4457 |
"Modified: / 17-04-2012 / 21:01:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4458 |
! |
4459 |
||
4460 |
expandSelectionLeft |
|
502 | 4461 |
|c l t c1 c2| |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4462 |
|
458 | 4463 |
selectionStartLine notNil ifTrue:[ |
4787 | 4464 |
expandingTop == true ifTrue:[ |
4465 |
selectionStartCol == 0 ifTrue:[^ self]. |
|
4466 |
l := selectionStartLine. |
|
4467 |
selectionStartCol := (selectionStartCol - 1) max:1. |
|
4468 |
c := selectionStartCol. |
|
4469 |
] ifFalse:[ |
|
4470 |
l := selectionEndLine. |
|
4471 |
selectionEndCol := (selectionEndCol - 1) max:0. |
|
4472 |
c := selectionEndCol. |
|
4473 |
selectionEndLine == selectionStartLine ifTrue:[ |
|
4474 |
selectionEndCol <= selectionStartCol ifTrue:[ |
|
4475 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4476 |
selectionEndCol := t. |
|
4477 |
expandingTop := true. |
|
4478 |
c := selectionStartCol. |
|
4479 |
] |
|
4480 |
]. |
|
4481 |
]. |
|
4482 |
c1 := c. |
|
4483 |
c2 := c1 + 1. |
|
4484 |
c1 == 0 ifTrue:[ |
|
4485 |
c1 := 1 |
|
4486 |
]. |
|
4487 |
self validateNewSelection. |
|
4488 |
self setPrimarySelection. |
|
4489 |
self selectionChanged. |
|
4490 |
self redrawLine:l from:c1 to:c2. |
|
4491 |
self makeSelectionVisible. |
|
458 | 4492 |
]. |
4493 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4494 |
"Modified: / 18-03-1996 / 17:05:46 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4495 |
"Modified: / 17-04-2012 / 21:01:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4496 |
! |
4497 |
||
4498 |
expandSelectionRight |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4499 |
|l c t| |
458 | 4500 |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4501 |
selectionStartLine notNil ifTrue:[ |
4787 | 4502 |
expandingTop == true ifTrue:[ |
4503 |
l := selectionStartLine. |
|
4504 |
c := selectionStartCol. |
|
4505 |
selectionStartCol := selectionStartCol + 1. |
|
4506 |
l == selectionEndLine ifTrue:[ |
|
4507 |
c >= selectionEndCol ifTrue:[ |
|
4508 |
expandingTop := false. |
|
4509 |
t := selectionStartCol. selectionStartCol := selectionEndCol. |
|
4510 |
selectionEndCol := t. |
|
4511 |
c := selectionStartCol. |
|
4512 |
] |
|
4513 |
] |
|
4514 |
] ifFalse:[ |
|
4515 |
l := selectionEndLine. |
|
4516 |
c := selectionEndCol. |
|
4517 |
selectionEndCol := selectionEndCol + 1. |
|
4518 |
]. |
|
4519 |
||
4520 |
self validateNewSelection. |
|
4521 |
self setPrimarySelection. |
|
4522 |
self selectionChanged. |
|
4804 | 4523 |
self redrawLine:l from:(c max:1) to:c+1. |
4787 | 4524 |
self makeSelectionVisible. |
458 | 4525 |
]. |
4526 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4527 |
"Created: / 01-03-1996 / 23:33:17 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4528 |
"Modified: / 06-03-1996 / 13:54:10 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4529 |
"Modified: / 17-04-2012 / 21:01:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4530 |
! |
4531 |
||
4532 |
expandSelectionUp |
|
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4533 |
|l t| |
458 | 4534 |
|
4535 |
selectionStartLine notNil ifTrue:[ |
|
4787 | 4536 |
expandingTop == true ifTrue:[ |
4537 |
selectionStartLine := (selectionStartLine - 1) max:1. |
|
4538 |
l := selectionStartLine. |
|
4539 |
] ifFalse:[ |
|
4540 |
selectionEndLine := (selectionEndLine - 1) max:0. |
|
4541 |
||
4542 |
l := selectionEndLine. |
|
4543 |
(selectionEndLine < clickLine |
|
4544 |
or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])]) |
|
4545 |
ifTrue:[ |
|
4546 |
t := selectionStartLine. |
|
4547 |
selectionStartLine := selectionEndLine. |
|
4548 |
selectionEndLine := t. |
|
4549 |
t := selectionStartCol. |
|
4550 |
selectionStartCol := selectionEndCol. |
|
4551 |
selectionEndCol := t. |
|
4552 |
l := selectionStartLine. |
|
4553 |
expandingTop := true |
|
4554 |
]. |
|
4555 |
]. |
|
4556 |
self validateNewSelection. |
|
4557 |
self setPrimarySelection. |
|
4558 |
self selectionChanged. |
|
4559 |
"/ self redrawLine:l. |
|
4560 |
"/ self redrawLine:l+1. |
|
4561 |
self redrawFromLine:l to:l+1. |
|
4562 |
self makeSelectionVisible. |
|
458 | 4563 |
]. |
4564 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4565 |
"Modified: / 06-03-1996 / 14:12:06 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4566 |
"Modified: / 17-04-2012 / 21:01:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458 | 4567 |
! |
4568 |
||
248 | 4569 |
hasSelection |
4570 |
"return true, if there is a selection" |
|
4571 |
||
4572 |
^ selectionStartLine notNil |
|
4573 |
! |
|
4574 |
||
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4575 |
hasSelectionForCopy |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4576 |
"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
|
4577 |
(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
|
4578 |
|
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4579 |
^ self hasSelection |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4580 |
! |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2336
diff
changeset
|
4581 |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4582 |
hasSelectionWithinSingleLine |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4583 |
"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
|
4584 |
|
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4585 |
^ selectionStartLine notNil |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4586 |
and:[ selectionStartLine == selectionEndLine ] |
3315 | 4587 |
|
4588 |
"Modified: / 04-07-2006 / 18:42:59 / fm" |
|
2530
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4589 |
! |
83e7b4b71496
searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents:
2520
diff
changeset
|
4590 |
|
5004 | 4591 |
hasSingleFullLineSelected |
4592 |
^ (selectionStartLine notNil |
|
4593 |
and:[selectionEndLine notNil |
|
4594 |
and:[selectionEndLine == (selectionStartLine+1) |
|
4595 |
and:[selectionStartCol == 1 |
|
4596 |
and:[selectionEndCol == 0 |
|
4597 |
]]]]) |
|
4598 |
! |
|
4599 |
||
2588 | 4600 |
isInSelection:line col:aColNr |
4601 |
"returns true, if the line, and column is in the selection |
|
4602 |
" |
|
3438 | 4603 |
selectionStartLine isNil ifTrue:[^ false]. |
4604 |
selectionEndLine isNil ifTrue:[^ false]. |
|
2588 | 4605 |
|
4606 |
(line between:selectionStartLine and:selectionEndLine) ifFalse:[ |
|
4500 | 4607 |
^ false |
2588 | 4608 |
]. |
4609 |
||
4610 |
line == selectionStartLine ifTrue:[ |
|
4500 | 4611 |
aColNr < selectionStartCol ifTrue:[^ false] |
2588 | 4612 |
]. |
4613 |
||
4614 |
line == selectionEndLine ifTrue:[ |
|
4500 | 4615 |
(selectionEndCol ~~ 0 and:[selectionEndCol < aColNr]) ifTrue:[^ false] |
2588 | 4616 |
]. |
4617 |
^ true |
|
4618 |
! |
|
4619 |
||
248 | 4620 |
makeSelectionVisible |
4621 |
"scroll to make the selection visible" |
|
4622 |
||
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4623 |
|line col| |
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4624 |
|
248 | 4625 |
selectionStartLine notNil ifTrue:[ |
4500 | 4626 |
expandingTop == true ifTrue:[ |
4627 |
line := selectionStartLine. |
|
4628 |
col := selectionStartCol. |
|
4629 |
] ifFalse:[ |
|
4630 |
line := selectionEndLine. |
|
4631 |
col := selectionEndCol. |
|
4632 |
]. |
|
4633 |
self makeLineVisible:line. |
|
4634 |
self makeColVisible:col inLine:line. |
|
248 | 4635 |
] |
478
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4636 |
|
180275291838
show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
4637 |
"Modified: 6.3.1996 / 13:53:45 / cg" |
248 | 4638 |
! |
4639 |
||
4640 |
selectAll |
|
4641 |
"select the whole text" |
|
4642 |
||
4643 |
self selectFromLine:1 col:1 toLine:(list size + 1) col:0 |
|
4644 |
! |
|
4645 |
||
4140
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4646 |
selectFromCharacterPosition:pos1 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4647 |
"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
|
4648 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4649 |
|line1 col1 line2 col2| |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4650 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4651 |
line1 := self lineOfCharacterPosition:pos1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4652 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4653 |
|
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4654 |
line2 := (list size + 1). |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4655 |
col2 := 0. |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4656 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4657 |
! |
435dc4fec8fb
added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
4120
diff
changeset
|
4658 |
|
248 | 4659 |
selectFromCharacterPosition:pos1 to:pos2 |
4660 |
"compute line/col from character positions and select the text" |
|
4661 |
||
4662 |
|line1 col1 line2 col2| |
|
4663 |
||
4554 | 4664 |
pos1 > pos2 ifTrue:[ |
4665 |
^ self unselect |
|
4666 |
]. |
|
248 | 4667 |
line1 := self lineOfCharacterPosition:pos1. |
4668 |
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1. |
|
4554 | 4669 |
col1 < 1 ifTrue:[ col1 := 1 ]. |
4670 |
||
248 | 4671 |
line2 := self lineOfCharacterPosition:pos2. |
4672 |
col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1. |
|
4554 | 4673 |
col2 < 1 ifTrue:[ col2 := 1 ]. |
248 | 4674 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2 |
4675 |
! |
|
4676 |
||
4677 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
|
4678 |
"select a piece of text and redraw that area" |
|
4679 |
||
5046 | 4680 |
((selectionStartLine = startLine) |
4681 |
and:[ (selectionStartCol = startCol) |
|
4682 |
and:[ (selectionEndLine = endLine) |
|
4683 |
and:[ (selectionEndCol = endCol) ]]]) ifTrue:[^ self ]. |
|
4684 |
||
248 | 4685 |
self unselect. |
4686 |
startLine notNil ifTrue:[ |
|
4787 | 4687 |
"new:" |
4688 |
endLine < startLine ifTrue:[ |
|
4689 |
^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol |
|
4690 |
]. |
|
4691 |
(endLine == startLine and:[endCol < startCol]) ifTrue:[ |
|
4692 |
endCol ~~ 0 ifTrue:[ |
|
4693 |
self selectFromLine:endLine col:endCol toLine:startLine col:startCol. |
|
4694 |
]. |
|
4695 |
^ self |
|
4696 |
]. |
|
248 | 4697 |
|
4698 |
" old: |
|
4787 | 4699 |
endLine < startLine ifTrue:[^ self]. |
4700 |
(startLine == endLine and:[endCol < startCol]) ifTrue:[^ self]. |
|
248 | 4701 |
" |
4787 | 4702 |
selectionStartLine := startLine. |
4703 |
selectionStartCol := startCol. |
|
4704 |
selectionEndLine := endLine. |
|
4705 |
selectionEndCol := endCol. |
|
4706 |
self validateNewSelection. |
|
4707 |
self setPrimarySelection. |
|
4708 |
self selectionChanged. |
|
4709 |
||
4710 |
(selectionStartLine == selectionEndLine) ifTrue:[ |
|
4711 |
self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol |
|
4712 |
] ifFalse:[ |
|
4713 |
selectionStartLine to:selectionEndLine do:[:lineNr | |
|
4714 |
self redrawLine:lineNr |
|
4715 |
] |
|
4716 |
]. |
|
4717 |
selectStyle := nil. |
|
248 | 4718 |
] |
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4719 |
|
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 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4722 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4723 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4724 |
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
|
4725 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4726 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4727 |
Delay waitForSeconds:1. |
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 |
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
|
4730 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4731 |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4732 |
"Modified: / 02-01-1997 / 13:32:25 / cg" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4733 |
"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
|
4734 |
! |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4735 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4736 |
selectFromLine:startLine toLine:endLine |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4737 |
"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
|
4738 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4739 |
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
|
4740 |
|
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 |
|v| |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4743 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4744 |
v := TextView extent:300@300. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4745 |
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
|
4746 |
v openAndWait. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4747 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4748 |
Delay waitForSeconds:1. |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4749 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4750 |
v selectFromLine:2 toLine:10 |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4751 |
" |
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4752 |
|
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4753 |
"Modified: 29.4.1996 / 12:23:46 / cg" |
248 | 4754 |
! |
4755 |
||
4756 |
selectLine:selectLine |
|
4757 |
"select one line and redraw it" |
|
4758 |
||
4759 |
self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0. |
|
4760 |
wordStartCol := selectionStartCol. |
|
4761 |
wordEndCol := selectionEndCol. |
|
4762 |
wordStartLine := selectionStartLine. |
|
4763 |
wordEndLine := selectionEndLine. |
|
4764 |
selectStyle := #line |
|
4765 |
! |
|
4766 |
||
4767 |
selectLineAtY:y |
|
4768 |
"select the line at given y-(view-)coordinate" |
|
4769 |
||
2413 | 4770 |
|selectLine| |
4771 |
||
4772 |
selectLine := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y). |
|
248 | 4773 |
selectLine notNil ifTrue:[ |
4500 | 4774 |
self selectLine:selectLine |
248 | 4775 |
] |
4776 |
! |
|
4777 |
||
4778 |
selectLineWhereCharacterPosition:pos |
|
4779 |
"select the line, where characterPosition pos is living. |
|
4780 |
The argument pos starts at 1 from the start of the text |
|
4500 | 4781 |
and counts characters (i.e. can be used to convert from |
248 | 4782 |
character position within a string to line-position in view)." |
4783 |
||
4784 |
self selectLine:(self lineOfCharacterPosition:pos) |
|
4785 |
! |
|
4786 |
||
4787 |
selectWordAtLine:line col:col |
|
4788 |
"select the word at given line/col" |
|
4789 |
||
4500 | 4790 |
self |
4791 |
wordAtLine:line col:col do:[ |
|
4792 |
:beginLine :beginCol :endLine :endCol :style | |
|
4793 |
||
4794 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
4795 |
selectStyle := style |
|
4796 |
] |
|
504 | 4797 |
|
4798 |
"Modified: 18.3.1996 / 17:30:38 / cg" |
|
248 | 4799 |
! |
4800 |
||
4801 |
selectWordAtX:x y:y |
|
4802 |
"select the word at given x/y-(view-)coordinate" |
|
4803 |
||
4804 |
|selectVisibleLine selectLine selectCol| |
|
4805 |
||
4806 |
selectStyle := nil. |
|
4807 |
selectVisibleLine := self visibleLineOfY:y. |
|
4808 |
selectLine := self visibleLineToListLine:selectVisibleLine. |
|
4809 |
selectLine notNil ifTrue:[ |
|
4500 | 4810 |
selectCol := self colOfX:x inVisibleLine:selectVisibleLine. |
4811 |
self selectWordAtLine:selectLine col:selectCol |
|
248 | 4812 |
] |
1661
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
4813 |
|
bf446f457d95
fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents:
1619
diff
changeset
|
4814 |
"Modified: / 8.9.1998 / 21:22:46 / cg" |
248 | 4815 |
! |
4816 |
||
3528 | 4817 |
selectedInterval |
4818 |
"return the selection-boundaries as interval" |
|
4819 |
||
4820 |
^ self selectionStartIndex to:(self selectionStopIndex - 1) |
|
4821 |
! |
|
4822 |
||
248 | 4823 |
selection |
4824 |
"return the selection as a collection of (line-)strings. |
|
4825 |
If the selection ends in a full line, the last entry in the returned |
|
4826 |
collection will be an empty string." |
|
4827 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4828 |
|sel| |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4829 |
|
248 | 4830 |
selectionStartLine isNil ifTrue:[^ nil]. |
4466 | 4831 |
sel := self textFromLine:selectionStartLine col:(selectionStartCol max:1) toLine:selectionEndLine col:selectionEndCol. |
5391 | 4832 |
sel notEmptyOrNil ifTrue:[ |
4833 |
(characterEncoding ? #'iso10646-1' "eg unicode") ~~ #'iso10646-1' ifTrue:[ |
|
4834 |
sel := sel encodeFrom:characterEncoding into:#'iso10646-1' |
|
4835 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4836 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
4837 |
^ sel |
2158
1fbe3297506f
generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
2120
diff
changeset
|
4838 |
|
4361
646cd7c5513e
comment/format in: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
4839 |
"Modified (comment): / 25-01-2012 / 00:29:09 / cg" |
248 | 4840 |
! |
4841 |
||
2217 | 4842 |
selectionAsString |
4843 |
"return the selection as a String (i.e. without emphasis)" |
|
4844 |
||
2693 | 4845 |
|sel| |
2217 | 4846 |
|
4847 |
(sel := self selection) isNil ifTrue:[^ nil]. |
|
2419 | 4848 |
sel := sel collect:[:each| each isNil ifTrue:[nil] ifFalse:[each string]]. |
2217 | 4849 |
^ (sel asStringWithCRsFrom:1 to:(sel size) compressTabs:false withCR:false) string |
4850 |
! |
|
4851 |
||
4101 | 4852 |
selectionChanged |
4853 |
"can be redefined for notification or special actions" |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4854 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4855 |
"Modified: / 17-04-2012 / 20:59:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4101 | 4856 |
! |
4857 |
||
248 | 4858 |
selectionEndCol |
4859 |
^ selectionEndCol |
|
4860 |
! |
|
4861 |
||
4862 |
selectionEndLine |
|
4863 |
^ selectionEndLine |
|
4864 |
! |
|
4865 |
||
4866 |
selectionStartCol |
|
4867 |
^ selectionStartCol |
|
4868 |
! |
|
4869 |
||
4870 |
selectionStartLine |
|
4871 |
^ selectionStartLine |
|
4872 |
! |
|
4873 |
||
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4874 |
setPrimarySelection |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4875 |
"can be redefined for notification or special actions" |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4876 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4877 |
device notNil ifTrue:[ |
4500 | 4878 |
"On X11, be nice and set the PRIMARY selection. |
4879 |
(#setPrimaryText:ownerView: is void in DeviceWorkstation)" |
|
4880 |
device setPrimaryText: self selectionAsString ownerView: self. |
|
4419
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4881 |
]. |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4882 |
|
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4883 |
"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
|
4884 |
! |
a7436b36c0a0
added: #setPrimarySelection
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4409
diff
changeset
|
4885 |
|
3308 | 4886 |
st80SelectMode |
3459 | 4887 |
st80SelectMode notNil ifTrue:[^ st80SelectMode]. |
4888 |
^ self class st80SelectMode |
|
3308 | 4889 |
|
4890 |
"Created: / 03-07-2006 / 16:30:59 / cg" |
|
4891 |
! |
|
4892 |
||
3459 | 4893 |
st80SelectMode:aBoolean |
4894 |
st80SelectMode := aBoolean |
|
4895 |
! |
|
4896 |
||
248 | 4897 |
unselect |
4898 |
"unselect - if there was a selection redraw that area" |
|
4899 |
||
4900 |
|startLine endLine startVisLine endVisLine| |
|
4901 |
||
4902 |
selectionStartLine notNil ifTrue:[ |
|
4500 | 4903 |
startLine := selectionStartLine. |
4904 |
endLine := selectionEndLine. |
|
4905 |
||
4906 |
self unselectWithoutRedraw. |
|
4907 |
||
4908 |
"/ if the selection is not visible, we are done |
|
4909 |
||
4910 |
startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self]. |
|
4911 |
endLine < firstLineShown ifTrue:[^ self]. |
|
4912 |
||
4913 |
startLine < firstLineShown ifTrue:[ |
|
4914 |
startVisLine := 1 |
|
4915 |
] ifFalse:[ |
|
4916 |
startVisLine := self listLineToVisibleLine:startLine |
|
4917 |
]. |
|
4918 |
endLine >= (firstLineShown + nLinesShown) ifTrue:[ |
|
4919 |
endVisLine := nLinesShown |
|
4920 |
] ifFalse:[ |
|
4921 |
endVisLine := self listLineToVisibleLine:endLine |
|
4922 |
]. |
|
4923 |
||
4924 |
"/ if its only part of a line, just redraw what has to be |
|
4925 |
||
4926 |
(startLine == endLine) ifTrue:[ |
|
4927 |
super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol |
|
4928 |
] ifFalse:[ |
|
4929 |
self redrawFromVisibleLine:startVisLine to:endVisLine |
|
4930 |
]. |
|
248 | 4931 |
]. |
4932 |
selectStyle := nil |
|
503 | 4933 |
|
715 | 4934 |
"Modified: 29.5.1996 / 14:54:11 / cg" |
248 | 4935 |
! |
4936 |
||
4937 |
unselectWithoutRedraw |
|
4938 |
"forget selection but do not redraw the selection area |
|
4939 |
- 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
|
4940 |
known to be invisible (however, redraw knows about that anyway)." |
248 | 4941 |
|
2735 | 4942 |
selectionStartLine := selectionEndLine := nil. |
4101 | 4943 |
self selectionChanged. |
248 | 4944 |
! |
4945 |
||
4946 |
validateNewSelection |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4947 |
"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
|
4948 |
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
|
4949 |
may redefine it to limit the selection to a single line, or whatever." |
248 | 4950 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4951 |
^ self |
504 | 4952 |
|
599
aae5e752e1cf
characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents:
586
diff
changeset
|
4953 |
"Modified: 29.4.1996 / 12:32:08 / cg" |
5378 | 4954 |
! |
4955 |
||
4956 |
withSelectionForeground:hilightFg background:hilightBg do:aBlock |
|
4957 |
"evaluate aBlock while the selection is shown highlighted with colors passed as args." |
|
4958 |
||
4959 |
|oldFg oldBg| |
|
4960 |
||
4961 |
" |
|
4962 |
change color of selection & hide cursor |
|
4963 |
" |
|
4964 |
oldFg := selectionFgColor. |
|
4965 |
oldBg := selectionBgColor. |
|
4966 |
selectionBgColor := hilightBg. |
|
4967 |
selectionFgColor := hilightFg. |
|
4968 |
||
4969 |
expandingTop := true. "/ hack to make the top of the selection visible |
|
4970 |
self makeSelectionVisible. |
|
4971 |
selectionStartLine notNil ifTrue:[ |
|
4972 |
selectionEndLine notNil ifTrue:[ |
|
4973 |
self redrawFromLine:selectionStartLine to:selectionEndLine. |
|
4974 |
]. |
|
4975 |
]. |
|
4976 |
self flush. |
|
4977 |
||
4978 |
aBlock ensure:[ |
|
4979 |
" |
|
4980 |
undo selection color change and show cursor again |
|
4981 |
" |
|
4982 |
selectionFgColor := oldFg. |
|
4983 |
selectionBgColor := oldBg. |
|
4984 |
]. |
|
248 | 4985 |
! ! |
4986 |
||
4310 | 4987 |
!TextView methodsFor:'testing'! |
4988 |
||
4989 |
isTextView |
|
4990 |
"I am showing text" |
|
4991 |
||
4992 |
^ true |
|
4993 |
! ! |
|
4994 |
||
844
03e45d817dce
fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
4995 |
!TextView class methodsFor:'documentation'! |
248 | 4996 |
|
4997 |
version |
|
5374 | 4998 |
^ '$Header$' |
3964 | 4999 |
! |
5000 |
||
5001 |
version_CVS |
|
5374 | 5002 |
^ '$Header$' |
248 | 5003 |
! ! |
2630
f3c95e73f862
for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents:
2604
diff
changeset
|
5004 |
|
4485 | 5005 |
|
2553
9838f1097a2f
allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents:
2547
diff
changeset
|
5006 |
TextView initialize! |