mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Allow wildcards in inset-modify for quotes
A dot in the <lang><side><times> string means: keep current value. This expert feature allows to change arbitrary quote features in one step. E.g., inset-forall Quotes inset-modify changetype f.. => change all quote insets to French style, maintaining current side and times setting inset-forall Quotes inset-modify changetype ..s => change all quote insets to single quotes, keeping style and times inset-forall Quotes inset-modify changetype g.s => change all quote insets to German single quotes, keeping left/right setting Any idea where to document this?
This commit is contained in:
parent
e4ca4a564d
commit
a3bb0db658
@ -158,7 +158,7 @@ void InsetQuotes::setSide(char_type c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetQuotes::parseString(string const & s)
|
void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
|
||||||
{
|
{
|
||||||
string str = s;
|
string str = s;
|
||||||
if (str.length() != 3) {
|
if (str.length() != 3) {
|
||||||
@ -169,40 +169,49 @@ void InsetQuotes::parseString(string const & s)
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 6; ++i) {
|
// '.' wildcard means: keep current language
|
||||||
if (str[0] == language_char[i]) {
|
if (!allow_wildcards || str[0] != '.') {
|
||||||
language_ = QuoteLanguage(i);
|
for (i = 0; i < 6; ++i) {
|
||||||
break;
|
if (str[0] == language_char[i]) {
|
||||||
|
language_ = QuoteLanguage(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i >= 6) {
|
||||||
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
||||||
|
" bad language specification." << endl;
|
||||||
|
language_ = EnglishQuotes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (i >= 6) {
|
|
||||||
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
||||||
" bad language specification." << endl;
|
|
||||||
language_ = EnglishQuotes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
// '.' wildcard means: keep current side
|
||||||
if (str[1] == side_char[i]) {
|
if (!allow_wildcards || str[1] != '.') {
|
||||||
side_ = QuoteSide(i);
|
for (i = 0; i < 2; ++i) {
|
||||||
break;
|
if (str[1] == side_char[i]) {
|
||||||
|
side_ = QuoteSide(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i >= 2) {
|
||||||
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
||||||
|
" bad side specification." << endl;
|
||||||
|
side_ = LeftQuote;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (i >= 2) {
|
|
||||||
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
||||||
" bad side specification." << endl;
|
|
||||||
side_ = LeftQuote;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
// '.' wildcard means: keep current times
|
||||||
if (str[2] == times_char[i]) {
|
if (!allow_wildcards || str[2] != '.') {
|
||||||
times_ = QuoteTimes(i);
|
for (i = 0; i < 2; ++i) {
|
||||||
break;
|
if (str[2] == times_char[i]) {
|
||||||
|
times_ = QuoteTimes(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i >= 2) {
|
||||||
|
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
||||||
|
" bad times specification." << endl;
|
||||||
|
times_ = DoubleQuotes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (i >= 2) {
|
|
||||||
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
|
|
||||||
" bad times specification." << endl;
|
|
||||||
times_ = DoubleQuotes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +347,7 @@ void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur.recordUndoInset(this);
|
cur.recordUndoInset(this);
|
||||||
parseString(cmd.getArg(1));
|
parseString(cmd.getArg(1), true);
|
||||||
cur.buffer()->updateBuffer();
|
cur.buffer()->updateBuffer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,8 @@ private:
|
|||||||
/// Decide whether we need left or right quotation marks
|
/// Decide whether we need left or right quotation marks
|
||||||
void setSide(char_type c);
|
void setSide(char_type c);
|
||||||
///
|
///
|
||||||
void parseString(std::string const &);
|
void parseString(std::string const &,
|
||||||
|
bool const allow_wildcards = false);
|
||||||
///
|
///
|
||||||
docstring displayString() const;
|
docstring displayString() const;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user