Module: QDA::GUI::FindableText
Defined Under Namespace
Classes: UsefulFindReplaceData
Instance Method Summary
collapse
Instance Method Details
#get_subject ⇒ Object
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 207
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
183
184
185
186
187
188
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 183
def initialize(*args)
super(*args)
@f_dialog = nil
@f_data = UsefulFindReplaceData.new(1)
@hooked = nil
end
|
#on_find(evt) ⇒ Object
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
253
254
255
256
257
258
259
260
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 227
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
262
263
264
265
266
267
268
269
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 262
def on_find_close(evt)
if @f_dialog
@f_dialog.destroy()
@f_dialog = nil
end
self.set_focus()
evt.skip()
end
|
#searching_down? ⇒ Boolean
219
220
221
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 219
def searching_down?
@f_data.down?
end
|
#searching_up? ⇒ Boolean
223
224
225
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 223
def searching_up?
@f_data.up?
end
|
#start_find(parent_win) ⇒ Object
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 190
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
|