#include "insets/Inset.h"
#include "insets/InsetCitation.h"
#include "insets/InsetGraphics.h"
+#include "insets/InsetQuotes.h"
#include "support/lassert.h"
#include "support/convert.h"
in the InsetCaption context menu. */
SwitchCaptions,
/** Commands to separate environments. */
- EnvironmentSeparators
+ EnvironmentSeparators,
+ /** This is the list of quotation marks available */
+ SwitchQuotes
};
explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
void expandArguments(BufferView const *, bool switcharg = false);
void expandCaptions(Buffer const * buf, bool switchcap = false);
void expandEnvironmentSeparators(BufferView const *);
+ void expandQuotes(BufferView const *);
///
ItemList items_;
///
md_switcharguments,
md_captions,
md_switchcaptions,
- md_env_separators
+ md_env_separators,
+ md_switchquotes
};
LexerKeyword menutags[] = {
{ "submenu", md_submenu },
{ "switcharguments", md_switcharguments },
{ "switchcaptions", md_switchcaptions },
+ { "switchquotes", md_switchquotes },
{ "toc", md_toc },
{ "toolbars", md_toolbars },
{ "updateformats", md_updateformats },
add(MenuItem(MenuItem::EnvironmentSeparators));
break;
+ case md_switchquotes:
+ add(MenuItem(MenuItem::SwitchQuotes));
+ break;
+
case md_optsubmenu:
case md_submenu: {
lex.next(true);
}
+void MenuDefinition::expandQuotes(BufferView const * bv)
+{
+ if (!bv)
+ return;
+
+ if (!bv->cursor().inTexted())
+ return;
+
+ Inset const * inset = bv->cursor().nextInset();
+ if (!inset || inset->lyxCode() != QUOTE_CODE) {
+ add(MenuItem(MenuItem::Command,
+ qt_("No Quote in Scope!"),
+ FuncRequest(LFUN_NOACTION)));
+ return;
+ }
+ InsetQuotes const * qinset =
+ static_cast<InsetQuotes const *>(inset);
+
+ map<string, docstring> styles = quoteparams.getTypes();
+ string const qtype = qinset->getType();
+
+ map<string, docstring>::const_iterator qq = styles.begin();
+ map<string, docstring>::const_iterator end = styles.end();
+
+ MenuDefinition eqs;
+ MenuDefinition sqs;
+ MenuDefinition gqs;
+ MenuDefinition pqs;
+ MenuDefinition cqs;
+ MenuDefinition aqs;
+ MenuDefinition qqs;
+ MenuDefinition bqs;
+ MenuDefinition wqs;
+ MenuDefinition fqs;
+ MenuDefinition iqs;
+ MenuDefinition rqs;
+ MenuDefinition xqs;
+ InsetQuotesParams::QuoteStyle globalqs =
+ bv->buffer().masterBuffer()->params().quotes_style;
+ FuncRequest cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xld"));
+ docstring desc = bformat(_("%1$stext (dynamic)"),
+ docstring(1, quoteparams.getQuoteChar(globalqs,
+ InsetQuotesParams::PrimaryQuotes,
+ InsetQuotesParams::OpeningQuote)));
+ if (prefixIs(qtype, "x"))
+ add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else
+ xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xls"));
+ desc = bformat(_("%1$stext (dynamic)"),
+ docstring(1, quoteparams.getQuoteChar(globalqs,
+ InsetQuotesParams::SecondaryQuotes,
+ InsetQuotesParams::OpeningQuote)));
+ if (prefixIs(qtype, "x"))
+ add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else
+ xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xrd"));
+ desc = bformat(_("text%1$s (dynamic)"),
+ docstring(1, quoteparams.getQuoteChar(globalqs,
+ InsetQuotesParams::PrimaryQuotes,
+ InsetQuotesParams::ClosingQuote)));
+ if (prefixIs(qtype, "x"))
+ add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else
+ xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype xrs"));
+ desc = bformat(_("text%1$s (dynamic)"),
+ docstring(1, quoteparams.getQuoteChar(globalqs,
+ InsetQuotesParams::SecondaryQuotes,
+ InsetQuotesParams::ClosingQuote)));
+ if (prefixIs(qtype, "x"))
+ add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else
+ xqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+
+ for (; qq != end; ++qq) {
+ docstring const style = from_ascii(qq->first);
+ cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype ") + style);
+ desc = contains(style, 'l') ?
+ bformat(_("%1$stext"), qq->second) : bformat(_("text%1$s"), qq->second);
+ if (prefixIs(style, qtype[0]))
+ add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'e') && !prefixIs(qtype, "e"))
+ eqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 's') && !prefixIs(qtype, "s"))
+ sqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'g') && !prefixIs(qtype, "g"))
+ gqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'p') && !prefixIs(qtype, "p"))
+ pqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'c') && !prefixIs(qtype, "c"))
+ cqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'a') && !prefixIs(qtype, "a"))
+ aqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'q') && !prefixIs(qtype, "q"))
+ qqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'b') && !prefixIs(qtype, "b"))
+ bqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'w') && !prefixIs(qtype, "w"))
+ wqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'f') && !prefixIs(qtype, "f"))
+ fqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'i') && !prefixIs(qtype, "i"))
+ iqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ else if (prefixIs(style, 'r') && !prefixIs(qtype, "r"))
+ rqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+ }
+
+ if (!xqs.empty()) {
+ MenuItem item(MenuItem::Submenu, qt_("Dynamic Quotation Marks"));
+ item.setSubmenu(xqs);
+ add(item);
+ }
+ if (!eqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::EnglishQuotes)));
+ item.setSubmenu(eqs);
+ add(item);
+ }
+ if (!sqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwedishQuotes)));
+ item.setSubmenu(sqs);
+ add(item);
+ }
+ if (!gqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::GermanQuotes)));
+ item.setSubmenu(gqs);
+ add(item);
+ }
+ if (!pqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::PolishQuotes)));
+ item.setSubmenu(pqs);
+ add(item);
+ }
+ if (!cqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwissQuotes)));
+ item.setSubmenu(cqs);
+ add(item);
+ }
+ if (!aqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::DanishQuotes)));
+ item.setSubmenu(aqs);
+ add(item);
+ }
+ if (!qqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::PlainQuotes)));
+ item.setSubmenu(qqs);
+ add(item);
+ }
+ if (!bqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::BritishQuotes)));
+ item.setSubmenu(bqs);
+ add(item);
+ }
+ if (!wqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::SwedishGQuotes)));
+ item.setSubmenu(wqs);
+ add(item);
+ }
+ if (!fqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::FrenchQuotes)));
+ item.setSubmenu(fqs);
+ add(item);
+ }
+ if (!iqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::FrenchINQuotes)));
+ item.setSubmenu(iqs);
+ add(item);
+ }
+ if (!rqs.empty()) {
+ MenuItem item(MenuItem::Submenu,
+ toqstr(quoteparams.getGuiLabel(InsetQuotesParams::RussianQuotes)));
+ item.setSubmenu(rqs);
+ add(item);
+ }
+}
+
+
void MenuDefinition::expandEnvironmentSeparators(BufferView const * bv)
{
if (!bv)
tomenu.expandEnvironmentSeparators(bv);
break;
+ case MenuItem::SwitchQuotes:
+ tomenu.expandQuotes(bv);
+ break;
+
case MenuItem::Submenu: {
MenuItem item(*cit);
item.setSubmenu(MenuDefinition(cit->submenuname()));