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