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