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