wxStaticBoxSizer* sbSizer_testFrames;
sbSizer_testFrames = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test Frames")), wxVERTICAL);
- m_ckboxTestFrame = new wxCheckBox(this, wxID_ANY, _("Enable System Calls"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ m_ckboxTestFrame = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
sbSizer_testFrames->Add(m_ckboxTestFrame, 0, wxALIGN_LEFT, 0);
bSizer30->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
// event processing enable
- m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+ m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable System Calls"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
sbSizer_events->Add(m_ckbox_events, 0, 0, 5);
// list of regexps
sbSizer_event_log->Add(bSizer33, 1, wxEXPAND, 5);
sbSizer_events->Add(sbSizer_event_log, 1, wxEXPAND, 5);
- // test event
-
- wxStaticBoxSizer* sbSizer_event_test = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test your Regular Expression")), wxVERTICAL);
- wxBoxSizer* bSizer34 = new wxBoxSizer(wxHORIZONTAL);
- m_txt_event_test = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
- m_txt_event_test->SetToolTip(_("Enter event text to test a regular expression"));
- bSizer34->Add(m_txt_event_test, 1, wxEXPAND|wxALL, 5);
- m_btn_event_test = new wxButton(this, wxID_ANY, _("Test"), wxDefaultPosition, wxDefaultSize, 0);
- bSizer34->Add(m_btn_event_test, 0, wxEXPAND|wxALL, 5);
- sbSizer_event_test->Add(bSizer34, 0, wxEXPAND, 5);
- sbSizer_events->Add(sbSizer_event_test, 0, wxEXPAND, 5);
-
bSizer30->Add(sbSizer_events,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
//------------------------------
// process with regexp and issue system command
+ // Each regexp in our list is separated by a newline. We want to try all of them.
+
wxString event_str(event);
- wxRegEx re(wxGetApp().m_events_regexp_match);
- wxString regexp_replace_str(wxGetApp().m_events_regexp_replace);
- re.Replace(&event_str, regexp_replace_str);
- const char *event_out = event_str.ToUTF8();
-
- wxString event_out_with_return_code;
-
- bool enableSystem = false;
- if (wxGetApp().m_events)
- enableSystem = true;
-
- // If options dialog is up current value of events checkbox overrides
-
- if (optionsDlg != NULL) {
- if (optionsDlg->enableEventsChecked())
- enableSystem = true;
- else
- enableSystem = false;
- }
-
- if (enableSystem) {
- int ret = wxExecute(event_str);
- event_out_with_return_code.Printf(_T("%s -> process ID %d"), event_out, ret);
- }
- else {
- event_out_with_return_code.Printf(_T("%s)"), event_out);
- }
+ int match_end, replace_end;
+ match_end = replace_end = 0;
+ wxString regexp_match_list = wxGetApp().m_events_regexp_match;
+ wxString regexp_replace_list = wxGetApp().m_events_regexp_replace;
+
+ while ((match_end = regexp_match_list.Find('\n')) != wxNOT_FOUND) {
+ printf("match_end: %d\n", match_end);
+ if ((replace_end = regexp_replace_list.Find('\n')) != wxNOT_FOUND) {
+ printf("replace_end = %d\n", replace_end);
+ // candidate match and replace regexps strings exist, so lets try them
+
+ wxString regexp_match = regexp_match_list.SubString(0, match_end-1);
+ wxString regexp_replace = regexp_replace_list.SubString(0, replace_end-1);
+ printf("match: %s replace: %s\n", (const char *)regexp_match.c_str(), (const char *)regexp_replace.c_str());
+ wxRegEx re(regexp_match);
+
+ // if we found a match, lets run the replace regexp and issue the system command
+
+ wxString event_str_rep = event_str;
+
+ if (re.Replace(&event_str_rep, regexp_replace) != 0) {
+ printf("found match!\n");
+ bool enableSystem = false;
+ if (wxGetApp().m_events)
+ enableSystem = true;
+
+ // If options dialog is up current value of events checkbox overrides wxGetApp().m_events
- // update event log GUI if currently displayed
+ if (optionsDlg != NULL) {
+ if (optionsDlg->enableEventsChecked())
+ enableSystem = true;
+ else
+ enableSystem = false;
+ }
- if (optionsDlg != NULL) {
- optionsDlg->updateEventLog(wxString(event), event_out_with_return_code);
+ const char *event_out = event_str_rep.ToUTF8();
+ wxString event_out_with_return_code;
+
+ if (enableSystem) {
+ int ret = wxExecute(event_str_rep);
+ event_out_with_return_code.Printf(_T("%s -> process ID %d"), event_out, ret);
+ }
+ else
+ event_out_with_return_code.Printf(_T("%s)"), event_out);
+
+ // update event log GUI if currently displayed
+ printf("hello\n");
+ if (optionsDlg != NULL) {
+ printf("hello\n");
+ optionsDlg->updateEventLog(wxString(event), event_out_with_return_code);
+ }
+ }
+ }
+ regexp_match_list = regexp_match_list.SubString(match_end+1, regexp_match_list.length());
+ regexp_replace_list = regexp_replace_list.SubString(replace_end+1, regexp_replace_list.length());
}
}