mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Extend quote-insert
Two more optional arguments to specify side and quote style. GUI support follows.
This commit is contained in:
parent
14dbaa7608
commit
7bf6d2b9ce
@ -40,6 +40,11 @@
|
||||
|
||||
!!!The following LyX functions have been changed in 2.3:
|
||||
|
||||
* quote-insert
|
||||
The function now has a second and third optional argument to specify
|
||||
the side (left, right, auto) and quotation mark style (english, swedish,
|
||||
german, polish, french, danish).
|
||||
|
||||
|
||||
!!!The following LyX documents have been moved in 2.3:
|
||||
|
||||
|
@ -403,8 +403,17 @@ void LyXAction::init()
|
||||
* \li Action: Inserts quotes according to the type and quote-language preference.
|
||||
* \li Notion: Currently English, Swedish, German, Polish, French, Danish quotes
|
||||
are distinguished.
|
||||
* \li Syntax: quote-insert [<TYPE>]
|
||||
* \li Syntax: quote-insert [<TYPE>] [<SIDE>] [<LANG>]
|
||||
* \li Params: <TYPE>: 'single' for single quotes, otherwise double quotes will be used.
|
||||
* <SIDE>: 'left' for opening quotes, 'right' for closing quotes, otherwise
|
||||
* the side will be guessed from the context.
|
||||
* <STYLE>: 'english' for ``English'' quote style
|
||||
* 'swedish' for ''Swedish'' quote style
|
||||
* 'german' for ,,German`` quote style
|
||||
* 'polish' for ,,Polish'' quote style
|
||||
* 'french' for <<French>> quote style
|
||||
* 'danish' for >>Danish<< quote style
|
||||
* If no quote style is specified, the document-wide will be used.
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_QUOTE_INSERT, "quote-insert", Noop, Edit },
|
||||
|
@ -1548,13 +1548,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
while (pos > 0 && par.isDeleted(pos - 1))
|
||||
--pos;
|
||||
|
||||
string const arg = to_utf8(cmd.argument());
|
||||
char_type c = ' ';
|
||||
if (pos > 0 && (!cur.prevInset() || !cur.prevInset()->isSpace()))
|
||||
c = par.getChar(pos - 1);
|
||||
InsetQuotes::QuoteTimes const quote_type = (arg == "single")
|
||||
InsetQuotes::QuoteTimes const quote_type = (cmd.getArg(0) == "single")
|
||||
? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes;
|
||||
cur.insert(new InsetQuotes(cur.buffer(), c, quote_type));
|
||||
cur.insert(new InsetQuotes(cur.buffer(), c, quote_type, cmd.getArg(1), cmd.getArg(2)));
|
||||
cur.buffer()->updateBuffer();
|
||||
cur.posForward();
|
||||
break;
|
||||
|
@ -111,19 +111,25 @@ InsetQuotes::InsetQuotes(Buffer * buf, string const & str) : Inset(buf)
|
||||
parseString(str);
|
||||
}
|
||||
|
||||
InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteTimes t)
|
||||
InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteTimes t,
|
||||
string const & s, string const & l)
|
||||
: Inset(buf), times_(t), pass_thru_(false)
|
||||
{
|
||||
if (buf) {
|
||||
language_ = buf->params().quotes_language;
|
||||
language_ = l.empty() ? buf->params().quotes_language : getLanguage(l);
|
||||
fontenc_ = (buf->params().fontenc == "global")
|
||||
? lyxrc.fontenc : buf->params().fontenc;
|
||||
} else {
|
||||
language_ = EnglishQuotes;
|
||||
language_ = l.empty() ? EnglishQuotes : getLanguage(l);
|
||||
fontenc_ = lyxrc.fontenc;
|
||||
}
|
||||
|
||||
setSide(c);
|
||||
if (s == "left")
|
||||
side_ = LeftQuote;
|
||||
else if (s == "right")
|
||||
side_ = RightQuote;
|
||||
else
|
||||
setSide(c);
|
||||
}
|
||||
|
||||
|
||||
@ -196,6 +202,26 @@ void InsetQuotes::parseString(string const & s)
|
||||
}
|
||||
}
|
||||
|
||||
InsetQuotes::QuoteLanguage InsetQuotes::getLanguage(string const & s)
|
||||
{
|
||||
QuoteLanguage ql = EnglishQuotes;
|
||||
|
||||
if (s == "english")
|
||||
ql = EnglishQuotes;
|
||||
else if (s == "swedish")
|
||||
ql = SwedishQuotes;
|
||||
else if (s == "german")
|
||||
ql = GermanQuotes;
|
||||
else if (s == "polish")
|
||||
ql = PolishQuotes;
|
||||
else if (s == "french")
|
||||
ql = FrenchQuotes;
|
||||
else if (s == "danish")
|
||||
ql = DanishQuotes;
|
||||
|
||||
return ql;
|
||||
}
|
||||
|
||||
|
||||
docstring InsetQuotes::displayString() const
|
||||
{
|
||||
|
@ -64,7 +64,9 @@ public:
|
||||
*/
|
||||
explicit InsetQuotes(Buffer * buf, std::string const & str = "eld");
|
||||
/// Direct access to inner/outer quotation marks
|
||||
InsetQuotes(Buffer * buf, char_type c, QuoteTimes t);
|
||||
InsetQuotes(Buffer * buf, char_type c, QuoteTimes t,
|
||||
std::string const & s = std::string(),
|
||||
std::string const & l = std::string());
|
||||
///
|
||||
docstring layoutName() const;
|
||||
///
|
||||
@ -112,6 +114,8 @@ private:
|
||||
docstring displayString() const;
|
||||
///
|
||||
docstring getQuoteEntity() const;
|
||||
///
|
||||
QuoteLanguage getLanguage(std::string const &);
|
||||
|
||||
///
|
||||
QuoteLanguage language_;
|
||||
|
Loading…
Reference in New Issue
Block a user