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