From cce4639b557ed9b7f6233948490eb6f9eda90cda Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 20 Dec 2016 17:55:43 +0100 Subject: [PATCH] Rename some quote-related params Quote Language -> Quote Style Quote Times-> Quote Level No change in functionality. --- src/BufferParams.cpp | 42 +++++----- src/BufferParams.h | 4 +- src/Text3.cpp | 4 +- src/frontends/qt4/GuiDocument.cpp | 4 +- src/insets/InsetQuotes.cpp | 122 +++++++++++++++--------------- src/insets/InsetQuotes.h | 16 ++-- src/tex2lyx/Preamble.cpp | 16 ++-- src/tex2lyx/Preamble.h | 2 +- 8 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 7832b268d2..ef12e2ccbb 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -71,7 +71,7 @@ static char const * const string_paragraph_separation[] = { }; -static char const * const string_quotes_language[] = { +static char const * const string_quotes_style[] = { "english", "swedish", "german", "polish", "french", "danish", "" }; @@ -127,27 +127,27 @@ ParSepTranslator const & parseptranslator() } -// Quotes language -typedef Translator QuotesLangTranslator; +// Quotes style +typedef Translator QuotesStyleTranslator; -QuotesLangTranslator const init_quoteslangtranslator() +QuotesStyleTranslator const init_quotesstyletranslator() { - QuotesLangTranslator translator - (string_quotes_language[0], InsetQuotes::EnglishQuotes); - translator.addPair(string_quotes_language[1], InsetQuotes::SwedishQuotes); - translator.addPair(string_quotes_language[2], InsetQuotes::GermanQuotes); - translator.addPair(string_quotes_language[3], InsetQuotes::PolishQuotes); - translator.addPair(string_quotes_language[4], InsetQuotes::FrenchQuotes); - translator.addPair(string_quotes_language[5], InsetQuotes::DanishQuotes); + QuotesStyleTranslator translator + (string_quotes_style[0], InsetQuotes::EnglishQuotes); + translator.addPair(string_quotes_style[1], InsetQuotes::SwedishQuotes); + translator.addPair(string_quotes_style[2], InsetQuotes::GermanQuotes); + translator.addPair(string_quotes_style[3], InsetQuotes::PolishQuotes); + translator.addPair(string_quotes_style[4], InsetQuotes::FrenchQuotes); + translator.addPair(string_quotes_style[5], InsetQuotes::DanishQuotes); return translator; } -QuotesLangTranslator const & quoteslangtranslator() +QuotesStyleTranslator const & quotesstyletranslator() { - static QuotesLangTranslator const translator = - init_quoteslangtranslator(); + static QuotesStyleTranslator const translator = + init_quotesstyletranslator(); return translator; } @@ -394,7 +394,7 @@ BufferParams::BufferParams() cite_engine_type_ = ENGINE_TYPE_DEFAULT; makeDocumentClass(); paragraph_separation = ParagraphIndentSeparation; - quotes_language = InsetQuotes::EnglishQuotes; + quotes_style = InsetQuotes::EnglishQuotes; fontsize = "default"; /* PaperLayout */ @@ -829,9 +829,9 @@ string BufferParams::readToken(Lexer & lex, string const & token, // that is invalid pimpl_->defskip = VSpace(VSpace::MEDSKIP); } else if (token == "\\quotes_language") { - string quotes_lang; - lex >> quotes_lang; - quotes_language = quoteslangtranslator().find(quotes_lang); + string quotes_style; + lex >> quotes_style; + quotes_style = quotesstyletranslator().find(quotes_style); } else if (token == "\\papersize") { string ppsize; lex >> ppsize; @@ -1300,7 +1300,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const else os << "\n\\defskip " << getDefSkip().asLyXCommand(); os << "\n\\quotes_language " - << string_quotes_language[quotes_language] + << string_quotes_style[quotes_style] << "\n\\papercolumns " << columns << "\n\\papersides " << sides << "\n\\paperpagestyle " << pagestyle << '\n'; @@ -2547,9 +2547,9 @@ Font const BufferParams::getFont() const } -InsetQuotes::QuoteLanguage BufferParams::getQuoteStyle(string const & qs) const +InsetQuotes::QuoteStyle BufferParams::getQuoteStyle(string const & qs) const { - return quoteslangtranslator().find(qs); + return quotesstyletranslator().find(qs); } diff --git a/src/BufferParams.h b/src/BufferParams.h index f1e8eacfec..d3b6327e31 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -106,7 +106,7 @@ public: */ ParagraphSeparation paragraph_separation; /// - InsetQuotes::QuoteLanguage quotes_language; + InsetQuotes::QuoteStyle quotes_style; /// std::string fontsize; /// Get the LayoutFile this document is using. @@ -201,7 +201,7 @@ public: Font const getFont() const; /// translate quote style string to enum value - InsetQuotes::QuoteLanguage getQuoteStyle(std::string const & qs) const; + InsetQuotes::QuoteStyle getQuoteStyle(std::string const & qs) const; /* these are for the PaperLayout */ /// the papersize diff --git a/src/Text3.cpp b/src/Text3.cpp index ac1743964c..8da40fc7d7 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1551,9 +1551,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) char_type c = ' '; if (pos > 0 && (!cur.prevInset() || !cur.prevInset()->isSpace())) c = par.getChar(pos - 1); - InsetQuotes::QuoteTimes const quote_type = (cmd.getArg(0) == "single") + InsetQuotes::QuoteLevel const quote_level = (cmd.getArg(0) == "single") ? InsetQuotes::SingleQuotes : InsetQuotes::DoubleQuotes; - cur.insert(new InsetQuotes(cur.buffer(), c, quote_type, cmd.getArg(1), cmd.getArg(2))); + cur.insert(new InsetQuotes(cur.buffer(), c, quote_level, cmd.getArg(1), cmd.getArg(2))); cur.buffer()->updateBuffer(); cur.posForward(); break; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 09503272bc..97d4d205eb 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2658,7 +2658,7 @@ void GuiDocument::applyView() } } - bp_.quotes_language = (InsetQuotes::QuoteLanguage) langModule->quoteStyleCO->itemData( + bp_.quotes_style = (InsetQuotes::QuoteStyle) langModule->quoteStyleCO->itemData( langModule->quoteStyleCO->currentIndex()).toInt(); QString const langname = langModule->languageCO->itemData( @@ -3071,7 +3071,7 @@ void GuiDocument::paramsToDialog() langModule->languageCO->setCurrentIndex(pos); langModule->quoteStyleCO->setCurrentIndex( - bp_.quotes_language); + bp_.quotes_style); bool default_enc = true; if (bp_.inputenc != "auto") { diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index ef9629ff6c..1247499180 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -55,9 +55,9 @@ namespace { * a >>danish<< */ -char const * const language_char = "esgpfa"; +char const * const style_char = "esgpfa"; char const * const side_char = "lr" ; -char const * const times_char = "sd"; +char const * const level_char = "sd"; // List of known quote chars char const * const quote_char = ",'`<>"; @@ -68,7 +68,7 @@ char_type const display_quote_char[2][5] = { { 0x201e, 0x201d, 0x201c, 0x00ab, 0x00bb} }; -// Index of chars used for the quote. Index is [side, language] +// Index of chars used for the quote. Index is [side, style] int quote_index[2][6] = { { 2, 1, 0, 0, 3, 4 }, // "'',,<>" { 1, 1, 2, 1, 4, 3 } // "`'`'><" @@ -115,22 +115,22 @@ InsetQuotes::InsetQuotes(Buffer * buf, string const & str) : Inset(buf) } -InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteTimes t, - string const & s, string const & l) - : Inset(buf), times_(t), pass_thru_(false) +InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteLevel level, + string const & side, string const & style) + : Inset(buf), level_(level), pass_thru_(false) { if (buf) { - language_ = l.empty() ? buf->params().quotes_language : getLanguage(l); + style_ = style.empty() ? buf->params().quotes_style : getStyle(style); fontenc_ = (buf->params().fontenc == "global") ? lyxrc.fontenc : buf->params().fontenc; } else { - language_ = l.empty() ? EnglishQuotes : getLanguage(l); + style_ = style.empty() ? EnglishQuotes : getStyle(style); fontenc_ = lyxrc.fontenc; } - if (s == "left") + if (side == "left") side_ = LeftQuote; - else if (s == "right") + else if (side == "right") side_ = RightQuote; else setSide(c); @@ -169,18 +169,18 @@ void InsetQuotes::parseString(string const & s, bool const allow_wildcards) int i; - // '.' wildcard means: keep current language + // '.' wildcard means: keep current stylee if (!allow_wildcards || str[0] != '.') { for (i = 0; i < 6; ++i) { - if (str[0] == language_char[i]) { - language_ = QuoteLanguage(i); + if (str[0] == style_char[i]) { + style_ = QuoteStyle(i); break; } } if (i >= 6) { lyxerr << "ERROR (InsetQuotes::InsetQuotes):" - " bad language specification." << endl; - language_ = EnglishQuotes; + " bad style specification." << endl; + style_ = EnglishQuotes; } } @@ -199,41 +199,41 @@ void InsetQuotes::parseString(string const & s, bool const allow_wildcards) } } - // '.' wildcard means: keep current times + // '.' wildcard means: keep current level if (!allow_wildcards || str[2] != '.') { for (i = 0; i < 2; ++i) { - if (str[2] == times_char[i]) { - times_ = QuoteTimes(i); + if (str[2] == level_char[i]) { + level_ = QuoteLevel(i); break; } } if (i >= 2) { lyxerr << "ERROR (InsetQuotes::InsetQuotes):" - " bad times specification." << endl; - times_ = DoubleQuotes; + " bad level specification." << endl; + level_ = DoubleQuotes; } } } -InsetQuotes::QuoteLanguage InsetQuotes::getLanguage(string const & s) +InsetQuotes::QuoteStyle InsetQuotes::getStyle(string const & s) { - QuoteLanguage ql = EnglishQuotes; + QuoteStyle qs = EnglishQuotes; if (s == "english") - ql = EnglishQuotes; + qs = EnglishQuotes; else if (s == "swedish") - ql = SwedishQuotes; + qs = SwedishQuotes; else if (s == "german") - ql = GermanQuotes; + qs = GermanQuotes; else if (s == "polish") - ql = PolishQuotes; + qs = PolishQuotes; else if (s == "french") - ql = FrenchQuotes; + qs = FrenchQuotes; else if (s == "danish") - ql = DanishQuotes; + qs = DanishQuotes; - return ql; + return qs; } @@ -241,23 +241,23 @@ map InsetQuotes::getTypes() const { map res; - int l, s, t; - QuoteLanguage lang; + int sty, sid, lev; + QuoteStyle style; QuoteSide side; - QuoteTimes times; + QuoteLevel level; string type; // get all quote types - for (l = 0; l < 6; ++l) { - lang = QuoteLanguage(l); - for (s = 0; s < 2; ++s) { - side = QuoteSide(s); - for (t = 0; t < 2; ++t) { - type += language_char[lang]; - type += side_char[s]; - times = QuoteTimes(t); - type += times_char[t]; - res[type] = docstring(1, display_quote_char[times][quote_index[side][lang]]); + for (sty = 0; sty < 6; ++sty) { + style = QuoteStyle(sty); + for (sid = 0; sid < 2; ++sid) { + side = QuoteSide(sid); + for (lev = 0; lev < 2; ++lev) { + type += style_char[style]; + type += side_char[sid]; + level = QuoteLevel(lev); + type += level_char[lev]; + res[type] = docstring(1, display_quote_char[level][quote_index[side][style]]); type.clear(); } } @@ -270,15 +270,15 @@ docstring InsetQuotes::displayString() const { // In PassThru, we use straight quotes if (pass_thru_) - return (times_ == DoubleQuotes) ? from_ascii("\"") : from_ascii("'"); + return (level_ == DoubleQuotes) ? from_ascii("\"") : from_ascii("'"); - int const index = quote_index[side_][language_]; - docstring retdisp = docstring(1, display_quote_char[times_][index]); + int const index = quote_index[side_][style_]; + docstring retdisp = docstring(1, display_quote_char[level_][index]); // in French, thin spaces are added inside double guillemets // FIXME: this should be done by a separate quote type. if (prefixIs(context_lang_, "fr") - && times_ == DoubleQuotes && language_ == FrenchQuotes) { + && level_ == DoubleQuotes && style_ == FrenchQuotes) { // THIN SPACE (U+2009) char_type const thin_space = 0x2009; if (side_ == LeftQuote) @@ -312,9 +312,9 @@ void InsetQuotes::draw(PainterInfo & pi, int x, int y) const string InsetQuotes::getType() const { string text; - text += language_char[language_]; + text += style_char[style_]; text += side_char[side_]; - text += times_char[times_]; + text += level_char[level_]; return text; } @@ -382,18 +382,18 @@ bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const { - const int quoteind = quote_index[side_][language_]; + const int quoteind = quote_index[side_][style_]; docstring qstr; // In pass-thru context, we output plain quotes if (runparams.pass_thru) - qstr = (times_ == DoubleQuotes) ? from_ascii("\"") : from_ascii("'"); + qstr = (level_ == DoubleQuotes) ? from_ascii("\"") : from_ascii("'"); else if (runparams.use_polyglossia) { // For polyglossia, we directly output the respective unicode chars // (spacing and kerning is then handled respectively) - qstr = docstring(1, display_quote_char[times_][quoteind]); + qstr = docstring(1, display_quote_char[level_][quoteind]); } - else if (language_ == FrenchQuotes && times_ == DoubleQuotes + else if (style_ == FrenchQuotes && level_ == DoubleQuotes && prefixIs(runparams.local_font->language()->code(), "fr")) { // Specific guillemets of French babel // including correct French spacing @@ -405,11 +405,11 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const && !runparams.local_font->language()->internalFontEncoding()) { // Quotation marks for T1 font encoding // (using ligatures) - qstr = from_ascii(latex_quote_t1[times_][quoteind]); + qstr = from_ascii(latex_quote_t1[level_][quoteind]); } else if (runparams.local_font->language()->internalFontEncoding()) { // Quotation marks for internal font encodings // (ligatures not featured) - qstr = from_ascii(latex_quote_noligatures[times_][quoteind]); + qstr = from_ascii(latex_quote_noligatures[level_][quoteind]); #ifdef DO_USE_DEFAULT_LANGUAGE } else if (doclang == "default") { #else @@ -418,10 +418,10 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const // Standard quotation mark macros // These are also used by babel // without fontenc (XeTeX/LuaTeX) - qstr = from_ascii(latex_quote_ot1[times_][quoteind]); + qstr = from_ascii(latex_quote_ot1[level_][quoteind]); } else { // Babel shorthand quotation marks (for T1/OT1) - qstr = from_ascii(latex_quote_babel[times_][quoteind]); + qstr = from_ascii(latex_quote_babel[level_][quoteind]); } if (!runparams.pass_thru) { @@ -456,12 +456,12 @@ int InsetQuotes::plaintext(odocstringstream & os, docstring InsetQuotes::getQuoteEntity() const { - const int quoteind = quote_index[side_][language_]; - docstring res = from_ascii(html_quote[times_][quoteind]); + const int quoteind = quote_index[side_][style_]; + docstring res = from_ascii(html_quote[level_][quoteind]); // in French, thin spaces are added inside double guillemets // FIXME: this should be done by a separate quote type. if (prefixIs(context_lang_, "fr") - && times_ == DoubleQuotes && language_ == FrenchQuotes) { + && level_ == DoubleQuotes && style_ == FrenchQuotes) { // THIN SPACE (U+2009) docstring const thin_space = from_ascii(" "); if (side_ == LeftQuote) @@ -509,7 +509,7 @@ void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/) void InsetQuotes::validate(LaTeXFeatures & features) const { - char type = quote_char[quote_index[side_][language_]]; + char type = quote_char[quote_index[side_][style_]]; #ifdef DO_USE_DEFAULT_LANGUAGE if (features.bufferParams().language->lang() == "default" @@ -517,7 +517,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const if (!features.useBabel() #endif && !features.usePolyglossia() && fontenc_ != "T1") { - if (times_ == SingleQuotes) + if (level_ == SingleQuotes) switch (type) { case ',': features.require("quotesinglbase"); break; case '<': features.require("guilsinglleft"); break; diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h index 9bb217952c..0d50c1299c 100644 --- a/src/insets/InsetQuotes.h +++ b/src/insets/InsetQuotes.h @@ -26,7 +26,7 @@ class InsetQuotes : public Inset { public: /// - enum QuoteLanguage { + enum QuoteStyle { /// EnglishQuotes, /// @@ -48,7 +48,7 @@ public: RightQuote }; /// - enum QuoteTimes { + enum QuoteLevel { /// SingleQuotes, /// @@ -64,9 +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, - std::string const & s = std::string(), - std::string const & l = std::string()); + InsetQuotes(Buffer * buf, char_type c, QuoteLevel level, + std::string const & side = std::string(), + std::string const & style = std::string()); /// docstring layoutName() const; /// @@ -125,14 +125,14 @@ private: /// docstring getQuoteEntity() const; /// - QuoteLanguage getLanguage(std::string const &); + QuoteStyle getStyle(std::string const &); /// - QuoteLanguage language_; + QuoteStyle style_; /// QuoteSide side_; /// - QuoteTimes times_; + QuoteLevel level_; /// std::string fontenc_; /// Code of the contextual language diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 7d6a07c974..93a3b044fa 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -533,7 +533,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false), h_pdf_pdfusetitle = "0"; //h_pdf_pagemode; //h_pdf_quoted_options; - h_quotes_language = "english"; + h_quotes_style = "english"; h_secnumdepth = "3"; h_shortcut[0] = "idx"; h_spacing = "single"; @@ -1079,22 +1079,22 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled // (quotes for kazakh and interlingua are unknown) // danish if (is_known(h_language, known_danish_quotes_languages)) - h_quotes_language = "danish"; + h_quotes_style = "danish"; // french else if (is_known(h_language, known_french_quotes_languages)) - h_quotes_language = "french"; + h_quotes_style = "french"; // german else if (is_known(h_language, known_german_quotes_languages)) - h_quotes_language = "german"; + h_quotes_style = "german"; // polish else if (is_known(h_language, known_polish_quotes_languages)) - h_quotes_language = "polish"; + h_quotes_style = "polish"; // swedish else if (is_known(h_language, known_swedish_quotes_languages)) - h_quotes_language = "swedish"; + h_quotes_style = "swedish"; //english else if (is_known(h_language, known_english_quotes_languages)) - h_quotes_language = "english"; + h_quotes_style = "english"; if (contains(h_float_placement, "H")) registerAutomaticallyLoadedPackage("float"); @@ -1253,7 +1253,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled os << "\\defskip " << h_defskip << "\n"; else os << "\\paragraph_indentation " << h_paragraph_indentation << "\n"; - os << "\\quotes_language " << h_quotes_language << "\n" + os << "\\quotes_language " << h_quotes_style << "\n" << "\\papercolumns " << h_papercolumns << "\n" << "\\papersides " << h_papersides << "\n" << "\\paperpagestyle " << h_paperpagestyle << "\n"; diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h index 350644d305..bf12b7b1e3 100644 --- a/src/tex2lyx/Preamble.h +++ b/src/tex2lyx/Preamble.h @@ -195,7 +195,7 @@ private: std::string h_pdf_pdfusetitle; std::string h_pdf_pagemode; std::string h_pdf_quoted_options; - std::string h_quotes_language; + std::string h_quotes_style; std::string h_secnumdepth; std::string h_shortcut[99]; std::string h_spacing; -- 2.39.5