mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +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;
|
||||
tzer.Tokenize(text, true, 1, 1);
|
||||
auto &choices = tzer.tokens;
|
||||
for (auto &choice : choices)
|
||||
results.push_back( { UnQuote(choice) } );
|
||||
wxString extra;
|
||||
for (auto &choice : choices) {
|
||||
auto label = UnQuote(choice, true, &extra);
|
||||
if (extra.empty())
|
||||
results.push_back( { label } );
|
||||
else
|
||||
results.push_back( { extra, label } );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Old style: expecting a comma-separated list of
|
||||
@ -1533,8 +1539,12 @@ void NyquistEffect::Stop()
|
||||
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();
|
||||
if (len >= 2 && s[0] == wxT('\"') && s[len - 1] == wxT('\"')) {
|
||||
auto unquoted = s.Mid(1, len - 2);
|
||||
@ -1545,10 +1555,20 @@ wxString NyquistEffect::UnQuote(const wxString &s, bool allowParens)
|
||||
Tokenizer tzer;
|
||||
tzer.Tokenize(s, true, 1, 1);
|
||||
auto &tokens = tzer.tokens;
|
||||
if (tokens.size() > 1)
|
||||
// Assume the first token was _ -- we don't check that
|
||||
// And the second is the string, which is internationalized
|
||||
return UnQuote( tokens[1], false );
|
||||
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
|
||||
// And the second is the string, which is internationalized
|
||||
return UnQuote( tokens[1], false );
|
||||
}
|
||||
}
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
@ -177,7 +177,8 @@ private:
|
||||
};
|
||||
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);
|
||||
|
||||
void OnLoad(wxCommandEvent & evt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user