Module: QDA::GUI::FindableText
Defined Under Namespace
Classes: UsefulFindReplaceData
Instance Method Summary
collapse
Instance Method Details
#get_subject ⇒ Object
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 199
def get_subject()
if @f_data.up?
subject = get_range( 0, insertion_point )
else
subject = get_range( insertion_point, last_position )
end
if @f_data.no_matchcase?
subject.downcase!
end
return subject
end
|
#initialize(*args) ⇒ Object
175
176
177
178
179
180
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 175
def initialize(*args)
super(*args)
@f_dialog = nil
@f_data = UsefulFindReplaceData.new(1)
@hooked = nil
end
|
#on_find(evt) ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 219
def on_find(evt)
@f_data.flags = evt.flags
sought = @f_data.find_string()
return if sought.empty?
sought.downcase! if @f_data.no_matchcase?
return unless subject = get_subject()
adjustment = 0
if searching_down? and string_selection == sought
adjustment = sought.length
subject = subject[adjustment .. -1]
end
point = searching_down? ? subject.index( sought ) :
subject.rindex( sought )
if point
if searching_up?
self.insertion_point = true_point( point )
else
self.insertion_point = true_insertion_point + point + adjustment
end
sel_start = true_index_to_pos( insertion_point )
sel_end = true_index_to_pos( insertion_point + sought.length )
self.set_selection( sel_end, sel_start )
end
end
|
#on_find_close(evt) ⇒ Object
254
255
256
257
258
259
260
261
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 254
def on_find_close(evt)
if @f_dialog
@f_dialog.destroy()
@f_dialog = nil
end
self.set_focus()
evt.skip()
end
|
#searching_down? ⇒ Boolean
211
212
213
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 211
def searching_down?
@f_data.down?
end
|
#searching_up? ⇒ Boolean
215
216
217
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 215
def searching_up?
@f_data.up?
end
|
#start_find(parent_win) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 182
def start_find(parent_win)
if not @f_dialog
@f_dialog = Wx::FindReplaceDialog.new( parent_win, @f_data,
"Find text", Wx::FR_NOWHOLEWORD )
end
if not @hooked
parent_win.evt_find(-1) { | e | on_find(e) }
parent_win.evt_find_next(-1) { | e | on_find(e) }
parent_win.evt_find_close(-1) { | e | on_find_close(e) }
parent_win.evt_close() { | e | on_find_close(e) }
@hooked = parent_win
end
@f_dialog.show()
end
|