From 0f3358248b03775e2eaee5a56039b1541f1c9b87 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sun, 19 Apr 2015 22:17:40 -0500 Subject: [PATCH] Nyquist prompt updates Based on Robert's and Steve's suggestions, I removed the "Clear" button, replaced FileDialog usage with wxFileDialog to restore extension suffixing, and escaped newlines in save settings so that chains work properly. I also attempted to locate the issue where code isn't being parsed and made a couple of changes, but I doubt I got it. --- include/audacity/EffectAutomationParameters.h | 42 ++++++++++--------- src/effects/nyquist/Nyquist.cpp | 40 ++++++++---------- src/effects/nyquist/Nyquist.h | 1 - 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/include/audacity/EffectAutomationParameters.h b/include/audacity/EffectAutomationParameters.h index bf6fbdd79..70f200cc3 100644 --- a/include/audacity/EffectAutomationParameters.h +++ b/include/audacity/EffectAutomationParameters.h @@ -61,26 +61,26 @@ public: virtual ~EffectAutomationParameters() { } - - virtual bool DoReadString(const wxString & key, wxString *pStr) const - { - return wxFileConfig::DoReadString(NormalizeName(key), pStr); - } - - virtual bool DoReadLong(const wxString & key, long *pl) const - { - return wxFileConfig::DoReadLong(NormalizeName(key), pl); - } - - virtual bool DoWriteString(const wxString & key, const wxString & szValue) - { - return wxFileConfig::DoWriteString(NormalizeName(key), szValue); - } - - virtual bool DoWriteLong(const wxString & key, long lValue) - { - return wxFileConfig::DoWriteLong(NormalizeName(key), lValue); - } + + virtual bool DoReadString(const wxString & key, wxString *pStr) const + { + return wxFileConfig::DoReadString(NormalizeName(key), pStr); + } + + virtual bool DoReadLong(const wxString & key, long *pl) const + { + return wxFileConfig::DoReadLong(NormalizeName(key), pl); + } + + virtual bool DoWriteString(const wxString & key, const wxString & szValue) + { + return wxFileConfig::DoWriteString(NormalizeName(key), szValue); + } + + virtual bool DoWriteLong(const wxString & key, long lValue) + { + return wxFileConfig::DoWriteLong(NormalizeName(key), lValue); + } bool ReadFloat(const wxString & key, float *pf) const { @@ -259,12 +259,14 @@ public: { val.Replace(wxT("\\"), wxT("\\\\"), true); val.Replace(wxT("\""), wxT("\\\""), true); + val.Replace(wxT("\n"), wxT("\\n"), true); return val; } wxString Unescape(wxString val) { + val.Replace(wxT("\\n"), wxT("\n"), true); val.Replace(wxT("\\\""), wxT("\""), true); val.Replace(wxT("\\\\"), wxT("\\"), true); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index dae58bd4e..e024dcf15 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -71,7 +71,6 @@ enum ID_Version, ID_Load, ID_Save, - ID_Clear, ID_Debug, ID_Slider = 11000, @@ -96,7 +95,6 @@ WX_DEFINE_OBJARRAY(NyqControlArray); BEGIN_EVENT_TABLE(NyquistEffect, wxEvtHandler) EVT_BUTTON(ID_Load, NyquistEffect::OnLoad) EVT_BUTTON(ID_Save, NyquistEffect::OnSave) - EVT_BUTTON(ID_Clear, NyquistEffect::OnClear) EVT_BUTTON(ID_Debug, NyquistEffect::OnDebug) EVT_COMMAND_RANGE(ID_Slider, ID_Slider+99, @@ -626,7 +624,7 @@ bool NyquistEffect::ShowInterface(wxWindow *parent, bool forceModal) { // Show the normal (prompt or effect) interface bool res = Effect::ShowInterface(parent, forceModal); -printf("res = %d %d %d\n", res, mIsPrompt, (int)mControls.GetCount()); + // We're done if the user clicked "Close", we are not the Nyquist Prompt, // or the program currently loaded into the prompt doesn't have a UI. if (!res || !mIsPrompt || mControls.GetCount() == 0) @@ -1787,7 +1785,6 @@ void NyquistEffect::BuildPromptWindow(ShuttleGui & S) { S.Id(ID_Load).AddButton(_("&Load")); S.Id(ID_Save).AddButton(_("&Save")); - S.Id(ID_Clear).AddButton(_("&Clear")); S.AddSpace(10, 1); S.Id(ID_Debug).AddButton(_("&Debug")); } @@ -1901,12 +1898,12 @@ void NyquistEffect::OnLoad(wxCommandEvent & WXUNUSED(evt)) } } - FileDialog dlog(mUIParent, - _("Load Nyquist script"), - mFileName.GetPath(), - wxEmptyString, - _("Nyquist scripts (*.ny)|*.ny|Lisp scripts (*.lsp)|*.lsp|All files|*"), - wxFD_OPEN | wxRESIZE_BORDER); + wxFileDialog dlog(mUIParent, + _("Load Nyquist script"), + mFileName.GetPath(), + wxEmptyString, + _("Nyquist scripts (*.ny)|*.ny|Lisp scripts (*.lsp)|*.lsp|Text files (*.txt)|*.txt|All files|*"), + wxFD_OPEN | wxRESIZE_BORDER); if (dlog.ShowModal() != wxID_OK) { @@ -1923,12 +1920,12 @@ void NyquistEffect::OnLoad(wxCommandEvent & WXUNUSED(evt)) void NyquistEffect::OnSave(wxCommandEvent & WXUNUSED(evt)) { - FileDialog dlog(mUIParent, - _("Save Nyquist script"), - mFileName.GetPath(), - mFileName.GetFullName(), - _("Nyquist scripts (*.ny)|*.ny|Lisp scripts (*.lsp)|*.lsp|All files|*"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER); + wxFileDialog dlog(mUIParent, + _("Save Nyquist script"), + mFileName.GetPath(), + mFileName.GetFullName(), + _("Nyquist scripts (*.ny)|*.ny|Lisp scripts (*.lsp)|*.lsp|All files|*"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER); if (dlog.ShowModal() != wxID_OK) { @@ -1943,16 +1940,13 @@ void NyquistEffect::OnSave(wxCommandEvent & WXUNUSED(evt)) } } -void NyquistEffect::OnClear(wxCommandEvent & WXUNUSED(evt)) -{ - mCommandText->Clear(); -} - void NyquistEffect::OnDebug(wxCommandEvent & WXUNUSED(evt)) { + TransferDataFromPromptWindow(); + NyquistEffect effect(NYQUIST_WORKER_ID); - effect.SetCommand(mCommandText->GetValue()); + effect.SetCommand(mInputCmd); effect.mDebug = true; SelectedRegion region(mT0, mT1); @@ -1971,6 +1965,8 @@ void NyquistEffect::OnDebug(wxCommandEvent & WXUNUSED(evt)) dlog.CentreOnParent(); dlog.ShowModal(); + SaveUserPreset(GetCurrentSettingsGroup()); + return; } diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 4e0225143..1c8f88501 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -155,7 +155,6 @@ private: void OnLoad(wxCommandEvent & evt); void OnSave(wxCommandEvent & evt); - void OnClear(wxCommandEvent & evt); void OnDebug(wxCommandEvent & evt); void OnText(wxCommandEvent & evt);