8049
|
1 |
"{ Package: 'stx:libtool' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Tools }"
|
|
4 |
|
|
5 |
StringSearchTool subclass:#StringSearchToolForTextView
|
|
6 |
instanceVariableNames:'textView matchHolder'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Interface-Tools'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!StringSearchToolForTextView class methodsFor:'interface specs'!
|
|
14 |
|
|
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 801 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'
|
8062
|
62 |
layout: (LayoutFrame 23 0 1 0 71 0 23 0)
|
8049
|
63 |
translateLabel: true
|
|
64 |
adjust: right
|
|
65 |
)
|
|
66 |
(InputFieldSpec
|
|
67 |
name: 'SearchEntryField'
|
8062
|
68 |
layout: (LayoutFrame 72 0 1 0 253 0 23 0)
|
8049
|
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'
|
8062
|
81 |
layout: (LayoutFrame 258 0 2 0 279 0 23 0)
|
8049
|
82 |
hasCharacterOrientedLabel: false
|
|
83 |
translateLabel: true
|
|
84 |
model: searchNextText
|
|
85 |
)
|
|
86 |
(ActionButtonSpec
|
|
87 |
label: 'searchPreviousIcon'
|
|
88 |
name: 'searchPreviousButton'
|
8062
|
89 |
layout: (LayoutFrame 286 0 2 0 307 0 23 0)
|
8049
|
90 |
hasCharacterOrientedLabel: false
|
|
91 |
translateLabel: true
|
|
92 |
model: searchPreviousText
|
|
93 |
)
|
|
94 |
(CheckBoxSpec
|
|
95 |
label: 'Ignore case'
|
|
96 |
name: 'IgnoreCaseCheckBox'
|
8062
|
97 |
layout: (LayoutFrame 312 0 1 0 424 0 23 0)
|
8049
|
98 |
model: ignoreCaseHolder
|
|
99 |
translateLabel: true
|
|
100 |
)
|
|
101 |
(CheckBoxSpec
|
|
102 |
label: 'Match'
|
|
103 |
name: 'MatchCheckBox'
|
8062
|
104 |
layout: (LayoutFrame 424 0 1 0 508 0 23 0)
|
8049
|
105 |
model: matchHolder
|
|
106 |
translateLabel: true
|
|
107 |
)
|
|
108 |
(LabelSpec
|
|
109 |
label: 'SearchBarImageInfoLabel'
|
|
110 |
name: 'SearchBarImageInfoLabel'
|
8062
|
111 |
layout: (LayoutFrame 510 0 1 0 534 0 23 0)
|
8049
|
112 |
hasCharacterOrientedLabel: false
|
|
113 |
translateLabel: true
|
|
114 |
labelChannel: searchBarImageInfoLabelHolder
|
|
115 |
)
|
|
116 |
(LabelSpec
|
|
117 |
label: 'SearchBarInfoLabel'
|
|
118 |
name: 'SearchBarInfoLabel'
|
8062
|
119 |
layout: (LayoutFrame 545 0 1 0 794 0 23 0)
|
8049
|
120 |
translateLabel: true
|
|
121 |
labelChannel: searchBarInfoLabelHolder
|
|
122 |
adjust: left
|
|
123 |
)
|
|
124 |
)
|
|
125 |
|
|
126 |
)
|
|
127 |
)
|
|
128 |
)
|
|
129 |
|
|
130 |
)
|
|
131 |
)
|
|
132 |
! !
|
|
133 |
|
|
134 |
!StringSearchToolForTextView methodsFor:'accessing'!
|
|
135 |
|
|
136 |
textView
|
|
137 |
^ textView
|
|
138 |
!
|
|
139 |
|
|
140 |
textView:something
|
|
141 |
textView := something.
|
|
142 |
! !
|
|
143 |
|
|
144 |
!StringSearchToolForTextView methodsFor:'aspects'!
|
|
145 |
|
|
146 |
matchHolder
|
|
147 |
|
|
148 |
matchHolder isNil ifTrue:[
|
|
149 |
matchHolder := false asValue.
|
|
150 |
"/ if your app needs to be notified of changes, uncomment one of the lines below:
|
|
151 |
"/ matchHolder addDependent:self.
|
|
152 |
matchHolder onChangeSend:#matchHolderChanged to:self.
|
|
153 |
|
|
154 |
].
|
|
155 |
^ matchHolder.
|
|
156 |
|
|
157 |
"Created: / 16-06-2007 / 06:45:04 / Administrador"
|
|
158 |
"Modified: / 16-06-2007 / 19:32:15 / Administrador"
|
|
159 |
! !
|
|
160 |
|
|
161 |
!StringSearchToolForTextView methodsFor:'change & update'!
|
|
162 |
|
|
163 |
matchHolderChanged
|
|
164 |
|
|
165 |
self searchNextTextIncludingCurrentSelection: true.
|
8062
|
166 |
self setFocusToSearchTextView.
|
8049
|
167 |
! !
|
|
168 |
|
|
169 |
!StringSearchToolForTextView methodsFor:'initialization & release'!
|
|
170 |
|
|
171 |
postBuildSearchTextView: anEditFieldView
|
|
172 |
|
|
173 |
super postBuildSearchTextView: anEditFieldView.
|
|
174 |
anEditFieldView crAction: self crAction.
|
|
175 |
! !
|
|
176 |
|
|
177 |
!StringSearchToolForTextView methodsFor:'public'!
|
|
178 |
|
|
179 |
crAction
|
|
180 |
|
|
181 |
^ [self returnFocusToTextView]
|
|
182 |
!
|
|
183 |
|
|
184 |
returnFocusToTextView
|
|
185 |
|
|
186 |
textView takeFocus
|
|
187 |
! !
|
|
188 |
|
|
189 |
!StringSearchToolForTextView methodsFor:'searching'!
|
|
190 |
|
|
191 |
hideSearchBar
|
|
192 |
|
|
193 |
masterApplication isNil ifTrue:[^ self].
|
|
194 |
masterApplication hideSearchBar.
|
|
195 |
self returnFocusToTextView.
|
|
196 |
!
|
|
197 |
|
|
198 |
searchNextTextFromBeginning
|
|
199 |
|searchText ignoreCase match absentBlock|
|
|
200 |
|
|
201 |
searchText := searchTextView contents.
|
|
202 |
searchText isEmptyOrNil ifTrue:[^self].
|
|
203 |
self textView isNil ifTrue:[^ self].
|
|
204 |
ignoreCase := self ignoreCaseHolder value.
|
|
205 |
match := self matchHolder value.
|
|
206 |
absentBlock := [self searchTextNotFound.].
|
|
207 |
self textView
|
|
208 |
searchFwd:searchText
|
|
209 |
ignoreCase:ignoreCase
|
|
210 |
match: match
|
|
211 |
startingAtLine:1
|
|
212 |
col:0
|
|
213 |
ifAbsent:absentBlock
|
|
214 |
!
|
|
215 |
|
|
216 |
searchNextTextIncludingCurrentSelection: includeCurrentSelection
|
|
217 |
|searchText ignoreCase match absentBlock startCol startLine|
|
|
218 |
|
|
219 |
self searchTextStarted.
|
|
220 |
searchText := searchTextView contents.
|
|
221 |
searchText isEmptyOrNil ifTrue:[^self].
|
|
222 |
self textView isNil ifTrue:[^ self].
|
|
223 |
ignoreCase := self ignoreCaseHolder value.
|
|
224 |
match := self matchHolder value.
|
|
225 |
absentBlock := [self searchNextTextReachEnd].
|
|
226 |
(self textView hasSelection and:[includeCurrentSelection])
|
|
227 |
ifTrue:[
|
8060
|
228 |
startCol := ((self textView selectionStartCol ? 1) - 1) max: 0.
|
8049
|
229 |
startLine := (self textView selectionStartLine ? 1).
|
|
230 |
self textView searchFwd:searchText ignoreCase:ignoreCase match: match startingAtLine:startLine col:startCol ifAbsent:absentBlock.
|
|
231 |
] ifFalse:[
|
|
232 |
self textView searchFwd:searchText ignoreCase:ignoreCase match: match ifAbsent:absentBlock
|
|
233 |
].
|
|
234 |
!
|
|
235 |
|
|
236 |
searchPreviousText
|
|
237 |
|
|
238 |
|searchText ignoreCase absentBlock|
|
|
239 |
|
|
240 |
self searchTextStarted.
|
|
241 |
searchText := searchTextView contents.
|
8062
|
242 |
self setFocusToSearchTextView.
|
8049
|
243 |
searchText isEmptyOrNil ifTrue:[^self].
|
|
244 |
ignoreCase := self ignoreCaseHolder value.
|
|
245 |
self textView isNil ifTrue:[^ self].
|
|
246 |
absentBlock := [self searchPreviousTextReachBeginning].
|
|
247 |
self textView searchBwd:searchText ignoreCase:ignoreCase ifAbsent:absentBlock.
|
|
248 |
!
|
|
249 |
|
|
250 |
searchPreviousTextFromEnd
|
|
251 |
|
|
252 |
|searchText ignoreCase absentBlock startLine startCol|
|
|
253 |
|
|
254 |
searchText := searchTextView contents.
|
|
255 |
searchText isEmptyOrNil ifTrue:[^self].
|
|
256 |
ignoreCase := self ignoreCaseHolder value.
|
|
257 |
self textView isNil ifTrue:[^ self].
|
|
258 |
absentBlock := [self searchTextNotFound.].
|
|
259 |
startLine := self textView numberOfLines + 1.
|
|
260 |
startCol := 1.
|
|
261 |
self textView
|
|
262 |
searchBwd:searchText
|
|
263 |
ignoreCase:ignoreCase
|
|
264 |
startingAtLine:startLine
|
|
265 |
col:startCol
|
|
266 |
ifAbsent:absentBlock
|
|
267 |
! !
|
|
268 |
|
|
269 |
!StringSearchToolForTextView class methodsFor:'documentation'!
|
|
270 |
|
|
271 |
version
|
8062
|
272 |
^ '$Header: /cvs/stx/stx/libtool/Tools__StringSearchToolForTextView.st,v 1.3 2008-04-08 09:03:48 fm Exp $'
|
8049
|
273 |
! !
|