# File lib/json/editor.rb, line 997
 997:       def ask_for_find_term(search = nil)
 998:         dialog = Dialog.new(
 999:           "Find a node matching regex in tree.",
1000:           nil, nil,
1001:           [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
1002:           [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
1003:         )
1004:         hbox = HBox.new(false, 5)
1005: 
1006:         hbox.pack_start(Label.new("Regex:"), false)
1007:         hbox.pack_start(regex_input = Entry.new)
1008:         hbox.pack_start(icase_checkbox = CheckButton.new('Icase'), false)
1009:         regex_input.width_chars = 60
1010:         if search
1011:           regex_input.text = search.source
1012:           icase_checkbox.active = search.casefold?
1013:         end
1014: 
1015:         dialog.vbox.pack_start(hbox, false)
1016: 
1017:         dialog.signal_connect('key-press-event''key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
1018:         dialog.show_all
1019:         self.focus = dialog
1020:         dialog.run do |response| 
1021:           if response == Dialog::RESPONSE_ACCEPT
1022:             begin
1023:               return Regexp.new(regex_input.text, icase_checkbox.active? ? Regexp::IGNORECASE : 0)
1024:             rescue => e
1025:               Editor.error_dialog(self, "Evaluation of regex /#{regex_input.text}/ failed: #{e}!")
1026:               return
1027:             end
1028:           end
1029:         end
1030:         return
1031:       ensure
1032:         dialog.destroy if dialog
1033:       end