author | Claus Gittinger <cg@exept.de> |
Tue, 23 Sep 2008 01:29:40 +0200 | |
changeset 8276 | 43b76fabaa23 |
parent 8085 | e050190fee76 |
child 8910 | 7c30cd06ddf4 |
permissions | -rw-r--r-- |
8276 | 1 |
" |
2 |
COPYRIGHT (c) 2008 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
8049 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
"{ NameSpace: Tools }" |
|
15 |
||
16 |
StringSearchTool subclass:#StringSearchToolForTextView |
|
8079 | 17 |
instanceVariableNames:'textView matchHolder' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Tools' |
|
8049 | 21 |
! |
22 |
||
8276 | 23 |
!StringSearchToolForTextView class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2008 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! ! |
|
8049 | 38 |
|
39 |
!StringSearchToolForTextView class methodsFor:'interface specs'! |
|
40 |
||
8079 | 41 |
windowSpec |
42 |
"This resource specification was automatically generated |
|
43 |
by the UIPainter of ST/X." |
|
44 |
||
45 |
"Do not manually edit this!! If it is corrupted, |
|
46 |
the UIPainter may not be able to read the specification." |
|
47 |
||
48 |
" |
|
49 |
UIPainter new openOnClass:Tools::StringSearchToolForTextView andSelector:#windowSpec |
|
50 |
Tools::StringSearchToolForTextView new openInterface:#windowSpec |
|
51 |
Tools::StringSearchToolForTextView open |
|
52 |
" |
|
53 |
||
54 |
<resource: #canvas> |
|
55 |
||
56 |
^ |
|
57 |
#(FullSpec |
|
58 |
name: windowSpec |
|
59 |
window: |
|
60 |
(WindowSpec |
|
61 |
label: 'Tools::StringSearchTool' |
|
62 |
name: 'Tools::StringSearchTool' |
|
63 |
min: (Point 10 10) |
|
64 |
max: (Point 1024 768) |
|
65 |
bounds: (Rectangle 0 0 883 27) |
|
66 |
) |
|
67 |
component: |
|
68 |
(SpecCollection |
|
69 |
collection: ( |
|
70 |
(ViewSpec |
|
71 |
name: 'SearchBox' |
|
72 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
73 |
level: -1 |
|
74 |
component: |
|
75 |
(SpecCollection |
|
76 |
collection: ( |
|
77 |
(ActionButtonSpec |
|
78 |
label: 'closeSearchBarIcon' |
|
79 |
name: 'hideSearchBarButton' |
|
80 |
layout: (LayoutFrame 1 0 2 0 22 0 23 0) |
|
81 |
hasCharacterOrientedLabel: false |
|
82 |
translateLabel: true |
|
83 |
model: hideSearchBar |
|
84 |
) |
|
85 |
(LabelSpec |
|
86 |
label: 'Search:' |
|
87 |
name: 'SearchLabel' |
|
88 |
layout: (LayoutFrame 23 0 1 0 71 0 23 0) |
|
89 |
translateLabel: true |
|
90 |
adjust: right |
|
91 |
) |
|
92 |
(InputFieldSpec |
|
93 |
name: 'SearchEntryField' |
|
94 |
layout: (LayoutFrame 72 0 1 0 253 0 23 0) |
|
95 |
model: searchTextHolder |
|
96 |
immediateAccept: true |
|
97 |
acceptOnReturn: true |
|
98 |
acceptOnTab: true |
|
99 |
acceptOnLostFocus: true |
|
100 |
modifiedChannel: searchTextModifiedHolder |
|
101 |
acceptOnPointerLeave: false |
|
102 |
postBuildCallback: postBuildSearchTextView: |
|
103 |
) |
|
104 |
(ActionButtonSpec |
|
105 |
label: 'searchNextIcon' |
|
106 |
name: 'SearchNextButton' |
|
107 |
layout: (LayoutFrame 258 0 2 0 279 0 23 0) |
|
108 |
hasCharacterOrientedLabel: false |
|
109 |
translateLabel: true |
|
110 |
model: searchNextTextButtonPressed |
|
111 |
) |
|
112 |
(ActionButtonSpec |
|
113 |
label: 'searchPreviousIcon' |
|
114 |
name: 'searchPreviousButton' |
|
115 |
layout: (LayoutFrame 286 0 2 0 307 0 23 0) |
|
116 |
hasCharacterOrientedLabel: false |
|
117 |
translateLabel: true |
|
118 |
model: searchPreviousTextButtonPressed |
|
119 |
) |
|
120 |
(CheckBoxSpec |
|
121 |
label: 'Ignore case' |
|
122 |
name: 'IgnoreCaseCheckBox' |
|
123 |
layout: (LayoutFrame 312 0 1 0 424 0 23 0) |
|
124 |
model: ignoreCaseHolder |
|
125 |
translateLabel: true |
|
126 |
) |
|
127 |
(CheckBoxSpec |
|
128 |
label: 'Match' |
|
129 |
name: 'MatchCheckBox' |
|
130 |
layout: (LayoutFrame 424 0 1 0 508 0 23 0) |
|
131 |
model: matchHolder |
|
132 |
translateLabel: true |
|
133 |
) |
|
134 |
(CheckBoxSpec |
|
135 |
label: 'Restart' |
|
136 |
name: 'RestartCheckBox' |
|
137 |
layout: (LayoutFrame 509 0 1 0 593 0 23 0) |
|
138 |
model: restartHolder |
|
139 |
translateLabel: true |
|
140 |
) |
|
141 |
(LabelSpec |
|
142 |
label: 'SearchBarImageInfoLabel' |
|
143 |
name: 'SearchBarImageInfoLabel' |
|
144 |
layout: (LayoutFrame 598 0 1 0 622 0 23 0) |
|
145 |
hasCharacterOrientedLabel: false |
|
146 |
translateLabel: true |
|
147 |
labelChannel: searchBarImageInfoLabelHolder |
|
148 |
) |
|
149 |
(LabelSpec |
|
150 |
label: 'SearchBarInfoLabel' |
|
151 |
name: 'SearchBarInfoLabel' |
|
152 |
layout: (LayoutFrame 633 0 1 0 882 0 23 0) |
|
153 |
translateLabel: true |
|
154 |
labelChannel: searchBarInfoLabelHolder |
|
155 |
adjust: left |
|
156 |
) |
|
157 |
) |
|
158 |
||
159 |
) |
|
160 |
) |
|
161 |
) |
|
162 |
||
163 |
) |
|
164 |
) |
|
165 |
! |
|
166 |
||
8070
2acefb7023d2
changed #matchCheckboxVisible
Claus Gittinger <cg@exept.de>
parents:
8064
diff
changeset
|
167 |
windowSpec_old |
8049 | 168 |
"This resource specification was automatically generated |
169 |
by the UIPainter of ST/X." |
|
170 |
||
171 |
"Do not manually edit this!! If it is corrupted, |
|
172 |
the UIPainter may not be able to read the specification." |
|
173 |
||
174 |
" |
|
175 |
UIPainter new openOnClass:Tools::StringSearchToolForTextView andSelector:#windowSpec |
|
176 |
Tools::StringSearchToolForTextView new openInterface:#windowSpec |
|
177 |
Tools::StringSearchToolForTextView open |
|
178 |
" |
|
179 |
||
180 |
<resource: #canvas> |
|
181 |
||
182 |
^ |
|
183 |
#(FullSpec |
|
184 |
name: windowSpec |
|
185 |
window: |
|
186 |
(WindowSpec |
|
187 |
label: 'Tools::StringSearchTool' |
|
188 |
name: 'Tools::StringSearchTool' |
|
189 |
min: (Point 10 10) |
|
190 |
max: (Point 1024 768) |
|
8078 | 191 |
bounds: (Rectangle 0 0 883 27) |
8049 | 192 |
) |
193 |
component: |
|
194 |
(SpecCollection |
|
195 |
collection: ( |
|
196 |
(ViewSpec |
|
197 |
name: 'SearchBox' |
|
198 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
199 |
level: -1 |
|
200 |
component: |
|
201 |
(SpecCollection |
|
202 |
collection: ( |
|
203 |
(ActionButtonSpec |
|
204 |
label: 'closeSearchBarIcon' |
|
205 |
name: 'hideSearchBarButton' |
|
206 |
layout: (LayoutFrame 1 0 2 0 22 0 23 0) |
|
207 |
hasCharacterOrientedLabel: false |
|
208 |
translateLabel: true |
|
209 |
model: hideSearchBar |
|
210 |
) |
|
211 |
(LabelSpec |
|
212 |
label: 'Search:' |
|
213 |
name: 'SearchLabel' |
|
8062 | 214 |
layout: (LayoutFrame 23 0 1 0 71 0 23 0) |
8049 | 215 |
translateLabel: true |
216 |
adjust: right |
|
217 |
) |
|
218 |
(InputFieldSpec |
|
219 |
name: 'SearchEntryField' |
|
8062 | 220 |
layout: (LayoutFrame 72 0 1 0 253 0 23 0) |
8049 | 221 |
model: searchTextHolder |
222 |
immediateAccept: true |
|
223 |
acceptOnReturn: true |
|
224 |
acceptOnTab: true |
|
225 |
acceptOnLostFocus: true |
|
226 |
modifiedChannel: searchTextModifiedHolder |
|
227 |
acceptOnPointerLeave: false |
|
228 |
postBuildCallback: postBuildSearchTextView: |
|
229 |
) |
|
230 |
(ActionButtonSpec |
|
231 |
label: 'searchNextIcon' |
|
232 |
name: 'SearchNextButton' |
|
8062 | 233 |
layout: (LayoutFrame 258 0 2 0 279 0 23 0) |
8049 | 234 |
hasCharacterOrientedLabel: false |
235 |
translateLabel: true |
|
8078 | 236 |
model: searchNextTextButtonPressed |
8049 | 237 |
) |
238 |
(ActionButtonSpec |
|
239 |
label: 'searchPreviousIcon' |
|
240 |
name: 'searchPreviousButton' |
|
8062 | 241 |
layout: (LayoutFrame 286 0 2 0 307 0 23 0) |
8049 | 242 |
hasCharacterOrientedLabel: false |
243 |
translateLabel: true |
|
8078 | 244 |
model: searchPreviousTextButtonPressed |
8049 | 245 |
) |
246 |
(CheckBoxSpec |
|
247 |
label: 'Ignore case' |
|
248 |
name: 'IgnoreCaseCheckBox' |
|
8062 | 249 |
layout: (LayoutFrame 312 0 1 0 424 0 23 0) |
8049 | 250 |
model: ignoreCaseHolder |
251 |
translateLabel: true |
|
252 |
) |
|
253 |
(CheckBoxSpec |
|
254 |
label: 'Match' |
|
255 |
name: 'MatchCheckBox' |
|
8062 | 256 |
layout: (LayoutFrame 424 0 1 0 508 0 23 0) |
8049 | 257 |
model: matchHolder |
258 |
translateLabel: true |
|
259 |
) |
|
8078 | 260 |
(CheckBoxSpec |
261 |
label: 'Restart' |
|
262 |
name: 'RestartCheckBox' |
|
263 |
layout: (LayoutFrame 509 0 1 0 593 0 23 0) |
|
264 |
model: restartHolder |
|
265 |
translateLabel: true |
|
266 |
) |
|
8049 | 267 |
(LabelSpec |
268 |
label: 'SearchBarImageInfoLabel' |
|
269 |
name: 'SearchBarImageInfoLabel' |
|
8078 | 270 |
layout: (LayoutFrame 598 0 1 0 622 0 23 0) |
8049 | 271 |
hasCharacterOrientedLabel: false |
272 |
translateLabel: true |
|
273 |
labelChannel: searchBarImageInfoLabelHolder |
|
274 |
) |
|
275 |
(LabelSpec |
|
276 |
label: 'SearchBarInfoLabel' |
|
277 |
name: 'SearchBarInfoLabel' |
|
8078 | 278 |
layout: (LayoutFrame 633 0 1 0 882 0 23 0) |
8049 | 279 |
translateLabel: true |
280 |
labelChannel: searchBarInfoLabelHolder |
|
281 |
adjust: left |
|
282 |
) |
|
283 |
) |
|
284 |
||
285 |
) |
|
286 |
) |
|
287 |
) |
|
288 |
||
289 |
) |
|
290 |
) |
|
291 |
! ! |
|
292 |
||
293 |
!StringSearchToolForTextView methodsFor:'accessing'! |
|
294 |
||
295 |
textView |
|
296 |
^ textView |
|
297 |
! |
|
298 |
||
299 |
textView:something |
|
300 |
textView := something. |
|
301 |
! ! |
|
302 |
||
303 |
!StringSearchToolForTextView methodsFor:'aspects'! |
|
304 |
||
8070
2acefb7023d2
changed #matchCheckboxVisible
Claus Gittinger <cg@exept.de>
parents:
8064
diff
changeset
|
305 |
matchCheckboxVisible |
2acefb7023d2
changed #matchCheckboxVisible
Claus Gittinger <cg@exept.de>
parents:
8064
diff
changeset
|
306 |
^ true |
2acefb7023d2
changed #matchCheckboxVisible
Claus Gittinger <cg@exept.de>
parents:
8064
diff
changeset
|
307 |
! |
2acefb7023d2
changed #matchCheckboxVisible
Claus Gittinger <cg@exept.de>
parents:
8064
diff
changeset
|
308 |
|
8049 | 309 |
matchHolder |
310 |
||
311 |
matchHolder isNil ifTrue:[ |
|
312 |
matchHolder := false asValue. |
|
313 |
"/ if your app needs to be notified of changes, uncomment one of the lines below: |
|
314 |
"/ matchHolder addDependent:self. |
|
315 |
matchHolder onChangeSend:#matchHolderChanged to:self. |
|
316 |
||
317 |
]. |
|
318 |
^ matchHolder. |
|
319 |
||
320 |
"Created: / 16-06-2007 / 06:45:04 / Administrador" |
|
321 |
"Modified: / 16-06-2007 / 19:32:15 / Administrador" |
|
322 |
! ! |
|
323 |
||
324 |
!StringSearchToolForTextView methodsFor:'change & update'! |
|
325 |
||
326 |
matchHolderChanged |
|
327 |
||
328 |
self searchNextTextIncludingCurrentSelection: true. |
|
8062 | 329 |
self setFocusToSearchTextView. |
8049 | 330 |
! ! |
331 |
||
332 |
!StringSearchToolForTextView methodsFor:'initialization & release'! |
|
333 |
||
334 |
postBuildSearchTextView: anEditFieldView |
|
335 |
||
336 |
super postBuildSearchTextView: anEditFieldView. |
|
337 |
anEditFieldView crAction: self crAction. |
|
338 |
! ! |
|
339 |
||
340 |
!StringSearchToolForTextView methodsFor:'public'! |
|
341 |
||
342 |
crAction |
|
343 |
||
344 |
^ [self returnFocusToTextView] |
|
345 |
! |
|
346 |
||
8085 | 347 |
escapePressed |
348 |
||
349 |
self returnFocusToTextView. |
|
350 |
super escapePressed. |
|
351 |
! |
|
352 |
||
8049 | 353 |
returnFocusToTextView |
354 |
||
355 |
textView takeFocus |
|
356 |
! ! |
|
357 |
||
358 |
!StringSearchToolForTextView methodsFor:'searching'! |
|
359 |
||
360 |
hideSearchBar |
|
361 |
||
362 |
masterApplication isNil ifTrue:[^ self]. |
|
363 |
masterApplication hideSearchBar. |
|
364 |
self returnFocusToTextView. |
|
365 |
! |
|
366 |
||
367 |
searchNextTextFromBeginning |
|
368 |
|searchText ignoreCase match absentBlock| |
|
369 |
||
370 |
searchText := searchTextView contents. |
|
371 |
searchText isEmptyOrNil ifTrue:[^self]. |
|
372 |
self textView isNil ifTrue:[^ self]. |
|
373 |
ignoreCase := self ignoreCaseHolder value. |
|
374 |
match := self matchHolder value. |
|
375 |
absentBlock := [self searchTextNotFound.]. |
|
376 |
self textView |
|
377 |
searchFwd:searchText |
|
378 |
ignoreCase:ignoreCase |
|
379 |
match: match |
|
380 |
startingAtLine:1 |
|
381 |
col:0 |
|
382 |
ifAbsent:absentBlock |
|
383 |
! |
|
384 |
||
385 |
searchNextTextIncludingCurrentSelection: includeCurrentSelection |
|
386 |
|searchText ignoreCase match absentBlock startCol startLine| |
|
387 |
||
388 |
self searchTextStarted. |
|
389 |
searchText := searchTextView contents. |
|
390 |
searchText isEmptyOrNil ifTrue:[^self]. |
|
391 |
self textView isNil ifTrue:[^ self]. |
|
392 |
ignoreCase := self ignoreCaseHolder value. |
|
393 |
match := self matchHolder value. |
|
394 |
absentBlock := [self searchNextTextReachEnd]. |
|
395 |
(self textView hasSelection and:[includeCurrentSelection]) |
|
396 |
ifTrue:[ |
|
8064 | 397 |
startCol := ((self textView selectionStartCol ? 1) - 2) max: 0. |
8049 | 398 |
startLine := (self textView selectionStartLine ? 1). |
399 |
self textView searchFwd:searchText ignoreCase:ignoreCase match: match startingAtLine:startLine col:startCol ifAbsent:absentBlock. |
|
400 |
] ifFalse:[ |
|
401 |
self textView searchFwd:searchText ignoreCase:ignoreCase match: match ifAbsent:absentBlock |
|
402 |
]. |
|
403 |
! |
|
404 |
||
405 |
searchPreviousText |
|
406 |
||
407 |
|searchText ignoreCase absentBlock| |
|
408 |
||
409 |
self searchTextStarted. |
|
410 |
searchText := searchTextView contents. |
|
411 |
searchText isEmptyOrNil ifTrue:[^self]. |
|
412 |
ignoreCase := self ignoreCaseHolder value. |
|
413 |
self textView isNil ifTrue:[^ self]. |
|
414 |
absentBlock := [self searchPreviousTextReachBeginning]. |
|
415 |
self textView searchBwd:searchText ignoreCase:ignoreCase ifAbsent:absentBlock. |
|
416 |
! |
|
417 |
||
418 |
searchPreviousTextFromEnd |
|
419 |
||
420 |
|searchText ignoreCase absentBlock startLine startCol| |
|
421 |
||
422 |
searchText := searchTextView contents. |
|
423 |
searchText isEmptyOrNil ifTrue:[^self]. |
|
424 |
ignoreCase := self ignoreCaseHolder value. |
|
425 |
self textView isNil ifTrue:[^ self]. |
|
426 |
absentBlock := [self searchTextNotFound.]. |
|
427 |
startLine := self textView numberOfLines + 1. |
|
428 |
startCol := 1. |
|
429 |
self textView |
|
430 |
searchBwd:searchText |
|
431 |
ignoreCase:ignoreCase |
|
432 |
startingAtLine:startLine |
|
433 |
col:startCol |
|
434 |
ifAbsent:absentBlock |
|
435 |
! ! |
|
436 |
||
437 |
!StringSearchToolForTextView class methodsFor:'documentation'! |
|
438 |
||
439 |
version |
|
8276 | 440 |
^ '$Header: /cvs/stx/stx/libtool/Tools__StringSearchToolForTextView.st,v 1.9 2008-09-22 23:29:40 cg Exp $' |
8049 | 441 |
! ! |