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