mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-03 17:39:25 +02:00
.ny header can distinguish internal vs visible choice strings...
... Syntax is like: ( "InternalString" (_ "Visible String") ) But none of the shipped .ny headers need this yet.
This commit is contained in:
parent
d464878d65
commit
7f30636ecb
@ -1489,8 +1489,14 @@ std::vector<IdentInterfaceSymbol> NyquistEffect::ParseChoice(const wxString & te
|
|||||||
Tokenizer tzer;
|
Tokenizer tzer;
|
||||||
tzer.Tokenize(text, true, 1, 1);
|
tzer.Tokenize(text, true, 1, 1);
|
||||||
auto &choices = tzer.tokens;
|
auto &choices = tzer.tokens;
|
||||||
for (auto &choice : choices)
|
wxString extra;
|
||||||
results.push_back( { UnQuote(choice) } );
|
for (auto &choice : choices) {
|
||||||
|
auto label = UnQuote(choice, true, &extra);
|
||||||
|
if (extra.empty())
|
||||||
|
results.push_back( { label } );
|
||||||
|
else
|
||||||
|
results.push_back( { extra, label } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Old style: expecting a comma-separated list of
|
// Old style: expecting a comma-separated list of
|
||||||
@ -1533,8 +1539,12 @@ void NyquistEffect::Stop()
|
|||||||
mStop = true;
|
mStop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString NyquistEffect::UnQuote(const wxString &s, bool allowParens)
|
wxString NyquistEffect::UnQuote(const wxString &s, bool allowParens,
|
||||||
|
wxString *pExtraString)
|
||||||
{
|
{
|
||||||
|
if (pExtraString)
|
||||||
|
*pExtraString = wxString{};
|
||||||
|
|
||||||
int len = s.Length();
|
int len = s.Length();
|
||||||
if (len >= 2 && s[0] == wxT('\"') && s[len - 1] == wxT('\"')) {
|
if (len >= 2 && s[0] == wxT('\"') && s[len - 1] == wxT('\"')) {
|
||||||
auto unquoted = s.Mid(1, len - 2);
|
auto unquoted = s.Mid(1, len - 2);
|
||||||
@ -1545,10 +1555,20 @@ wxString NyquistEffect::UnQuote(const wxString &s, bool allowParens)
|
|||||||
Tokenizer tzer;
|
Tokenizer tzer;
|
||||||
tzer.Tokenize(s, true, 1, 1);
|
tzer.Tokenize(s, true, 1, 1);
|
||||||
auto &tokens = tzer.tokens;
|
auto &tokens = tzer.tokens;
|
||||||
if (tokens.size() > 1)
|
if (tokens.size() > 1) {
|
||||||
|
if (pExtraString && tokens[1][0] == '(') {
|
||||||
|
// A choice with a distinct internal string form like
|
||||||
|
// ("InternalString" (_ "Visible string"))
|
||||||
|
// Recur to find the two strings
|
||||||
|
*pExtraString = UnQuote(tokens[0], false);
|
||||||
|
return UnQuote(tokens[1]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Assume the first token was _ -- we don't check that
|
// Assume the first token was _ -- we don't check that
|
||||||
// And the second is the string, which is internationalized
|
// And the second is the string, which is internationalized
|
||||||
return UnQuote( tokens[1], false );
|
return UnQuote( tokens[1], false );
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,8 @@ private:
|
|||||||
};
|
};
|
||||||
bool Parse(Tokenizer &tokenizer, const wxString &line, bool eof, bool first);
|
bool Parse(Tokenizer &tokenizer, const wxString &line, bool eof, bool first);
|
||||||
|
|
||||||
static wxString UnQuote(const wxString &s, bool allowParens = true);
|
static wxString UnQuote(const wxString &s, bool allowParens = true,
|
||||||
|
wxString *pExtraString = nullptr);
|
||||||
double GetCtrlValue(const wxString &s);
|
double GetCtrlValue(const wxString &s);
|
||||||
|
|
||||||
void OnLoad(wxCommandEvent & evt);
|
void OnLoad(wxCommandEvent & evt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user