first pass at matching multiple regexp
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 10 Jun 2014 07:40:23 +0000 (07:40 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 10 Jun 2014 07:40:23 +0000 (07:40 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1643 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/Makefile.linux
fdmdv2/src/dlg_options.cpp
fdmdv2/src/dlg_options.h
fdmdv2/src/fdmdv2_main.cpp

index 632f146d8f245cbd00653f7f24953a0e220d9604..19b43a1e8fd5c11b0ee01ed6dfa8fe0e45d74dfc 100644 (file)
@@ -52,7 +52,7 @@ endif
 
 # Codec 2 -----------------------------------------------
 
-CODEC2=codec2
+CODEC2=codec2-dev
 CODEC2_INC=-I$(CODEC2)/src
 CODEC2_LIB=$(CODEC2)/build_dir/src/libcodec2.a
 
@@ -112,7 +112,7 @@ dlg_filter.o \
 dlg_options.o \
 varicode.o \
 sox_biquad.o \
-codec2/src/golay23.c \
+codec2-dev/src/golay23.c \
 hamlib.o
 
 all: $(LIBS_TO_BUILD) $(CODEC2)/.built freedv
index f5c16be7a3037ee05cbc74dba89534a34a315e0c..e19c2085a6192bf430d8e3b87a5a84b8959ca3ed 100644 (file)
@@ -39,7 +39,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
     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);
@@ -80,7 +80,7 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
 
     // 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
@@ -105,18 +105,6 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
     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);
 
     //------------------------------
index 49da32c7706654d457513a6ae78dcefa48ac8c57..767ce36442411eb2809ea33f049cdca8dcca2e69 100644 (file)
@@ -60,8 +60,6 @@ class OptionsDlg : public wxDialog
         wxTextCtrl   *m_txt_events_regexp_replace;
         wxTextCtrl   *m_txt_events_in;
         wxTextCtrl   *m_txt_events_out;
-        wxTextCtrl   *m_txt_event_test;
-        wxButton     *m_btn_event_test;
 
         wxButton*     m_sdbSizer5OK;
         wxButton*     m_sdbSizer5Cancel;
index e072c7a29bafa07253d7e8c5b7e5664418290702..e01af5a0022161f1641d645b489f6e53ac5b1938 100644 (file)
@@ -2520,39 +2520,64 @@ void MainFrame::processTxtEvent(char event[]) {
 
     // 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());
     }
 }