From 237193f8a888777192981136469a5d4febb8e9d8 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 24 Dec 2016 14:27:00 +0100 Subject: [PATCH] Some new quote styles * b `british' (``inner quotation'') * w >>swedishg>> ('inner quotation') ["g" = Guillemets] * f <> (``inner quotation'') * i <> (<>) ["in" = Imprimerie Nationale] * r <> (,,inner quotation``) Rename "french" to "swiss" Also rename "single/double" to "secondary/primary" ("inner/outer" in the UI) and "left/right" to "opening/closing". Note that the inset identifier string is left as is ("s/d" and "l/r") --- development/FORMAT | 12 +++ lib/languages | 65 +++++++++------ lib/lyx2lyx/lyx_2_3.py | 162 +++++++++++++++++++++++++++++++++++- lib/ui/stdmenus.inc | 4 +- src/BufferParams.cpp | 10 ++- src/LyXAction.cpp | 29 ++++--- src/Text3.cpp | 5 +- src/frontends/qt4/Menus.cpp | 57 +++++++++++-- src/insets/InsetQuotes.cpp | 114 ++++++++++++++++++------- src/insets/InsetQuotes.h | 22 +++-- src/tex2lyx/TODO.txt | 11 +++ src/version.h | 4 +- 12 files changed, 402 insertions(+), 93 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 9cc37edd84..76c9682505 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,18 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2016-12-24 Jürgen Spitzmüller + * Format incremented to 521: + Introduce new quote styles: + - british \begin_inset Quotes b.. + - swiss \begin_inset Quotes c.. + - swedishg \begin_inset Quotes w.. + - frenchin \begin_inset Quotes i.. + - russian \begin_inset Quotes r.. + Change default behavior of French quote style: + - Inner quotes are now ``..''. + - Former french style is now called "swiss" + 2016-12-21 Jürgen Spitzmüller * Format incremented to 520: Introduce plain quote style: \begin_inset Quotes qls => \textquotesingle diff --git a/lib/languages b/lib/languages index 2df8f0a824..3a0b6ad234 100644 --- a/lib/languages +++ b/lib/languages @@ -12,7 +12,8 @@ # PolyglossiaOpts "" # Encoding # FontEncoding -# QuoteStyle +# QuoteStyle # InternalEncoding # RTL # AsBabelOptions @@ -43,13 +44,19 @@ # (UK) -- try to select the entry that is most generic -- here # English. # * The QuoteStyle arguments correspond to the following styles: -# - danish: >>text<< >text< (inward guillemets) -# - english: ``text'' `text' (66_99) -# - french: <> (outward guillemets) -# - german: ,,text`` ,text` (99/66) -# - polish: ,,text'' ,text' (99/99) -# - swedish: ''text'' 'text' (99_99) -# - plain: "text" 'text' (straight non-typographical quotes) +# PRIMARY SECONDARY +# - british: `text' ``text'' (6_9 -- 66_99) +# - danish: >>text<< >text< (inward guillemets) +# - english: ``text'' `text' (66_99 -- 6_9) +# - french: <> ``text'' (outward guillemets -- 66_99) +# - frenchin: <> <> (French Imprimerie Nationale style) +# - german: ,,text`` ,text` (99/66 -- 9/6) +# - polish: ,,text'' ,text' (99/99 -- 9/9) +# - russian: <> ,,text`` (outward guillemets -- 99/66) +# - swedish: ''text'' 'text' (99_99 -- 9_9) +# - swedishg: >>text>> 'text' (Swedish Guillemets) +# - swiss: <> (outward guillemets) +# - plain: "text" 'text' (non-typographical quotes) # Note that the option names have been selected (rather arbitrarily) # because the respective styles are common in the respective countries. # Of course this does not imply any fixed relation to those countries. @@ -118,7 +125,7 @@ Language albanian GuiName "Albanian" BabelName albanian PolyglossiaName albanian - QuoteStyle french + QuoteStyle swiss Encoding iso8859-2 LangCode sq_AL End @@ -187,7 +194,7 @@ End Language armenian GuiName "Armenian" PolyglossiaName armenian - QuoteStyle french + QuoteStyle swiss Encoding utf8 LangCode hy_AM End @@ -259,7 +266,7 @@ Language basque HasGuiSupport true BabelName basque PolyglossiaName basque - QuoteStyle french + QuoteStyle swiss Encoding iso8859-15 LangCode eu_ES PostBabelPreamble @@ -310,7 +317,7 @@ Language british BabelName british PolyglossiaName english PolyglossiaOpts "variant=british" - QuoteStyle english + QuoteStyle british Encoding iso8859-15 LangCode en_GB End @@ -462,7 +469,7 @@ Language estonian GuiName "Estonian" BabelName estonian PolyglossiaName estonian - QuoteStyle polish + QuoteStyle german Encoding iso8859-15 LangCode et_EE PostBabelPreamble @@ -480,6 +487,7 @@ Language farsi FontEncoding "LFE,LAE" RTL true LangCode fa_IR + QuoteStyle english PostBabelPreamble \DeclareTextSymbol{\guillemotright}{LFE}{62} \DeclareTextSymbol{\guillemotleft}{LFE}{60} @@ -577,7 +585,7 @@ Language german-ch BabelName nswissgerman PolyglossiaName german PolyglossiaOpts "variant=swiss,spelling=new,babelshorthands=true" - QuoteStyle danish + QuoteStyle swiss Encoding iso8859-15 LangCode de_CH End @@ -590,7 +598,7 @@ Language german-ch-old BabelName swissgerman PolyglossiaName german PolyglossiaOpts "variant=swiss,spelling=old,babelshorthands=true" - QuoteStyle danish + QuoteStyle swiss Encoding iso8859-15 LangCode de_CH End @@ -652,6 +660,7 @@ End # BabelName hungarian # Encoding iso8859-2 # LangCode hu_HU +# QuoteStyle polish #End Language icelandic @@ -672,6 +681,7 @@ Language interlingua PolyglossiaName interlingua Encoding iso8859-15 LangCode ia_IA + QuoteStyle english End Language irish @@ -787,7 +797,7 @@ Language latvian GuiName "Latvian" BabelName latvian PolyglossiaName latvian - QuoteStyle danish + QuoteStyle german Encoding iso8859-4 # FontEncoding L7x # (required for hyphenation but not set by babel) LangCode lv_LV @@ -871,7 +881,7 @@ Language norsk HasGuiSupport true BabelName norsk PolyglossiaName norsk - QuoteStyle french + QuoteStyle swiss Encoding iso8859-15 LangCode nb_NO End @@ -881,7 +891,7 @@ Language nynorsk HasGuiSupport true BabelName nynorsk PolyglossiaName nynorsk - QuoteStyle french + QuoteStyle swiss Encoding iso8859-15 LangCode nn_NO End @@ -905,6 +915,7 @@ End # PolyglossiaName russian # PolyglossiaOpts "spelling=old" # LangCode ru_petr1708 +# QuoteStyle russian # End Language piedmontese @@ -933,7 +944,7 @@ Language portuguese HasGuiSupport true BabelName portuges PolyglossiaName portuges - QuoteStyle english + QuoteStyle french Encoding iso8859-15 LangCode pt_PT End @@ -963,7 +974,7 @@ Language russian HasGuiSupport true BabelName russian PolyglossiaName russian - QuoteStyle french + QuoteStyle russian Encoding koi8-r FontEncoding T2A LangCode ru_RU @@ -1002,7 +1013,7 @@ Language serbian BabelName serbianc PolyglossiaName serbian PolyglossiaOpts "script=Cyrillic" - QuoteStyle german + QuoteStyle polish Encoding utf8 FontEncoding T2A LangCode sr_RS @@ -1016,7 +1027,7 @@ Language serbian-latin BabelName serbian PolyglossiaName serbian PolyglossiaOpts "script=Latin" - QuoteStyle german + QuoteStyle polish Encoding iso8859-2 LangCode sr_RS-Latin End @@ -1127,7 +1138,7 @@ Language turkish HasGuiSupport true BabelName turkish PolyglossiaName turkish - QuoteStyle french + QuoteStyle english Encoding iso8859-9 LangCode tr_TR PostBabelPreamble @@ -1141,7 +1152,7 @@ Language turkmen GuiName "Turkmen" BabelName turkmen PolyglossiaName turkmen - QuoteStyle french + QuoteStyle swiss Encoding utf8 LangCode tk_TM AsBabelOptions true @@ -1152,7 +1163,7 @@ Language ukrainian HasGuiSupport true BabelName ukrainian PolyglossiaName ukrainian - QuoteStyle french + QuoteStyle russian Encoding koi8-u FontEncoding T2A LangCode uk_UA @@ -1183,7 +1194,7 @@ Language vietnamese GuiName "Vietnamese" BabelName vietnam PolyglossiaName vietnamese - QuoteStyle french + QuoteStyle english Encoding utf8 LangCode vi_VN AsBabelOptions true @@ -1194,7 +1205,7 @@ Language welsh GuiName "Welsh" BabelName welsh PolyglossiaName welsh - QuoteStyle english + QuoteStyle british Encoding iso8859-15 LangCode cy_GB End diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py index 6949364140..98eb4633fb 100644 --- a/lib/lyx2lyx/lyx_2_3.py +++ b/lib/lyx2lyx/lyx_2_3.py @@ -667,7 +667,7 @@ def revert_quotestyle(document): def revert_plainquote(document): - " Revert plain quote inset " + " Revert plain quote insets " # First, revert style setting i = find_token(document.header, "\\quotes_style plain", 0) @@ -693,6 +693,162 @@ def revert_plainquote(document): i = l +def convert_frenchquotes(document): + " Convert french quote insets to swiss " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style french", 0) + if i != -1: + document.header[i] = "\\quotes_style swiss" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes f', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + newval = val.replace("f", "c", 1) + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_swissquotes(document): + " Revert swiss quote insets to french " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style swiss", 0) + if i != -1: + document.header[i] = "\\quotes_style french" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes c', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + newval = val.replace("c", "f", 1) + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_britishquotes(document): + " Revert british quote insets to english " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style british", 0) + if i != -1: + document.header[i] = "\\quotes_style english" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes b', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + newval = val.replace("b", "e", 1) + if val[2] == "d": + # opening mark + newval = newval.replace("d", "s") + else: + # inner marks + newval = newval.replace("s", "d") + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_swedishgquotes(document): + " Revert swedish quote insets " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style swedishg", 0) + if i != -1: + document.header[i] = "\\quotes_style danish" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes w', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + if val[2] == "d": + # outer marks + newval = val.replace("w", "a", 1).replace("r", "l") + else: + # inner marks + newval = val.replace("w", "s", 1) + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_frenchquotes(document): + " Revert french inner quote insets " + + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes f', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + if val[2] == "s": + # inner marks + newval = val.replace("f", "e", 1).replace("s", "d") + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_frenchinquotes(document): + " Revert inner frenchin quote insets " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style frenchin", 0) + if i != -1: + document.header[i] = "\\quotes_style french" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes i', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + newval = val.replace("i", "f", 1) + if val[2] == "s": + # inner marks + newval = newval.replace("s", "d") + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + +def revert_russianquotes(document): + " Revert russian quote insets " + + # First, revert style setting + i = find_token(document.header, "\\quotes_style russian", 0) + if i != -1: + document.header[i] = "\\quotes_style french" + + # now the insets + i = 0 + while True: + i = find_token(document.body, '\\begin_inset Quotes r', i) + if i == -1: + return + val = get_value(document.body, "\\begin_inset Quotes", i)[7:] + newval = val + if val[2] == "s": + # inner marks + newval = val.replace("r", "g", 1).replace("s", "d") + else: + # outer marks + newval = val.replace("r", "f", 1) + document.body[i] = document.body[i].replace(val, newval) + i += 1 + + ## # Conversion hub # @@ -710,10 +866,12 @@ convert = [ [517, []], [518, [convert_iopart]], [519, [convert_quotestyle]], - [520, []] + [520, []], + [521, [convert_frenchquotes]] ] revert = [ + [520, [revert_britishquotes, revert_swedishgquotes, revert_frenchquotes, revert_frenchinquotes, revert_russianquotes, revert_swissquotes]], [519, [revert_plainquote]], [518, [revert_quotestyle]], [517, [revert_iopart]], diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index 47e7b61e81..6f2c0c744f 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -400,8 +400,8 @@ Menuset Item "Symbols...|b" "dialog-show symbols" Item "Ellipsis|i" "specialchar-insert dots" Item "End of Sentence|E" "specialchar-insert end-of-sentence" - Item "Plain Quotation Mark|Q" "quote-insert double auto plain" - Item "Single Quotation Mark|S" "quote-insert single" + Item "Plain Quotation Mark|Q" "quote-insert outer auto plain" + Item "Inner Quotation Mark|n" "quote-insert inner" Item "Protected Hyphen|y" "specialchar-insert nobreakdash" Item "Breakable Slash|a" "specialchar-insert slash" Item "Visible Space|V" "space-insert visible" diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 740bb6bde6..3bdfefba86 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -72,7 +72,8 @@ static char const * const string_paragraph_separation[] = { static char const * const string_quotes_style[] = { - "english", "swedish", "german", "polish", "french", "danish", "plain", "" + "english", "swedish", "german", "polish", "swiss", "danish", "plain", + "british", "swedishg", "french", "frenchin", "russian", "" }; @@ -138,9 +139,14 @@ QuotesStyleTranslator const init_quotesstyletranslator() translator.addPair(string_quotes_style[1], InsetQuotesParams::SwedishQuotes); translator.addPair(string_quotes_style[2], InsetQuotesParams::GermanQuotes); translator.addPair(string_quotes_style[3], InsetQuotesParams::PolishQuotes); - translator.addPair(string_quotes_style[4], InsetQuotesParams::FrenchQuotes); + translator.addPair(string_quotes_style[4], InsetQuotesParams::SwissQuotes); translator.addPair(string_quotes_style[5], InsetQuotesParams::DanishQuotes); translator.addPair(string_quotes_style[6], InsetQuotesParams::PlainQuotes); + translator.addPair(string_quotes_style[7], InsetQuotesParams::BritishQuotes); + translator.addPair(string_quotes_style[8], InsetQuotesParams::SwedishGQuotes); + translator.addPair(string_quotes_style[9], InsetQuotesParams::FrenchQuotes); + translator.addPair(string_quotes_style[10], InsetQuotesParams::FrenchINQuotes); + translator.addPair(string_quotes_style[11], InsetQuotesParams::RussianQuotes); return translator; } diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 63b4a69bee..89d12ec670 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -404,17 +404,22 @@ void LyXAction::init() * \li Notion: Currently English, Swedish, German, Polish, French, Danish quotes are distinguished. * \li Syntax: quote-insert [] [] [