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