From 2cf5de28a9ebd192da359777d9bcc1019cab4ad9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 10 Mar 2012 13:34:42 +0000 Subject: [PATCH] Add "notermination" flag to unicodesymbols. This tells us not to try any termination of the command (such as '{}' or ' ' ). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40905 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/unicodesymbols | 85 +++++++++++++++++++++++----------------------- src/Encoding.cpp | 14 ++++++++ src/Encoding.h | 5 +++ src/Paragraph.cpp | 3 +- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/lib/unicodesymbols b/lib/unicodesymbols index 25f10519b1..420de46a93 100644 --- a/lib/unicodesymbols +++ b/lib/unicodesymbols @@ -31,12 +31,13 @@ # textpreamble and mathpreamble can either be a feature known by the LaTeXFeatures # class (e.g. tipa), or a LaTeX command (e.g. \\usepackage{bla}). # Known flags: -# - combining This is a combining char that will get combined with a base char -# - force Always output replacement command -# - mathalpha This character is considered as a math variable in mathmode +# - combining This is a combining char that will get combined with a base char +# - force Always output replacement command +# - mathalpha This character is considered as a math variable in mathmode +# - notermination Do not terminate this command (by {} or space). # - tipashortcut= Shortcut notation for TIPA -0x00a0 "~" "" "" "~" "" # NO-BREAK SPACE +0x00a0 "~" "" "notermination" "~" "" # NO-BREAK SPACE 0x00a1 "\\textexclamdown" "" "" # INVERTED EXCLAMATION MARK 0x00a2 "\\textcent" "textcomp" "" #"\\mathcent" "txfonts|pxfonts" # CENT SIGN 0x00a3 "\\pounds" "" "" "\\pounds" "" # £ POUND SIGN @@ -49,7 +50,7 @@ 0x00aa "\\textordfeminine" "textcomp" "" # FEMININE ORDINAL INDICATOR 0x00ab "\\guillemotleft" "" "" # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00ac "\\textlnot" "textcomp" "force" "\\neg" "" # ¬ NOT SIGN -0x00ad "\\-" "" "" # SOFT HYPHEN +0x00ad "\\-" "" "notermination" # SOFT HYPHEN 0x00ae "\\textregistered" "textcomp" "force" "\\circledR" "amssymb" # REGISTERED SIGN # the force flag is only needed due to a bug in teTeX 3 / TeXLive 2005 0x00af "\\textasciimacron" "textcomp" "" # MACRON 0x00b0 "\\textdegree" "textcomp" "force" "{^\\circ}" "" # DEGREE SIGN # the force flag is only needed due to a bug in teTeX 3 / TeXLive 2005 @@ -60,7 +61,7 @@ 0x00b5 "\\textmu" "textcomp" "force" "\\mu" "" # µ MICRO SIGN 0x00b6 "\\textparagraph" "textcomp" "" # PILCROW SIGN # not equal to \textpilcrow 0x00b7 "\\textperiodcentered" "" "" "\cdot" # MIDDLE DOT -0x00b8 "\\c\\ " "" "" # CEDILLA (command from latin1.def) +0x00b8 "\\c\\ " "" "notermination" # CEDILLA (command from latin1.def) 0x00b9 "\\textonesuperior" "textcomp" "force" "{{}^1}" "" # ¹ SUPERSCRIPT ONE 0x00ba "\\textordmasculine" "textcomp" "" # MASCULINE ORDINAL INDICATOR 0x00bb "\\guillemotright" "" "" # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK @@ -167,7 +168,7 @@ 0x0120 "\\.{G}" "" "mathalpha" "\\dot{G}" # LATIN CAPITAL LETTER G WITH DOT ABOVE 0x0121 "\\.{g}" "" "mathalpha" "\\dot{g}" # LATIN SMALL LETTER G WITH DOT ABOVE 0x0122 "\\c{G}" "" "mathalpha" "\\cedilla{G}" "accents,cedilla" # LATIN CAPITAL LETTER G WITH CEDILLA -0x0123 "\\accent96 g" "" "mathalpha" "\\mathaccent96 g" # LATIN SMALL LETTER G WITH CEDILLA +0x0123 "\\accent96 g" "" "mathalpha,notermination" "\\mathaccent96 g" # LATIN SMALL LETTER G WITH CEDILLA 0x0124 "\\^{H}" "" "mathalpha" "\\hat{H}" # LATIN CAPITAL LETTER H WITH CIRCUMFLEX 0x0125 "\\^{h}" "" "mathalpha" "\\hat{h}" # LATIN SMALL LETTER H WITH CIRCUMFLEX #0x0126 "" "" "" "" "" # LATIN CAPITAL LETTER H WITH STROKE @@ -182,8 +183,8 @@ 0x012f "\\k{i}" "" "mathalpha" "\\ogonek{i}" "accents,tipasymb,ogonek" # LATIN SMALL LETTER I WITH OGONEK 0x0130 "\\.{I}" "" "mathalpha" "\\dot{I}" # LATIN CAPITAL LETTER I WITH DOT ABOVE 0x0131 "\\i" "" "mathalpha" "\\imath" # LATIN SMALL LETTER DOTLESS I -0x0132 "IJ" "" "mathalpha" "IJ" # LATIN CAPITAL LIGATURE IJ -0x0133 "ij" "" "mathalpha" "ij" # LATIN SMALL LIGATURE IJ +0x0132 "IJ" "" "mathalpha,notermination" "IJ" # LATIN CAPITAL LIGATURE IJ +0x0133 "ij" "" "mathalpha,notermination" "ij" # LATIN SMALL LIGATURE IJ 0x0134 "\\^{J}" "" "mathalpha" "\\hat{J}" # LATIN CAPITAL LETTER J WITH CIRCUMFLEX 0x0135 "\\^{\\j}" "" "mathalpha" "\\hat{\\jmath}" # LATIN SMALL LETTER J WITH CIRCUMFLEX 0x0136 "\\c{K}" "" "mathalpha" "\\cedilla{K}" "accents,cedilla" # LATIN CAPITAL LETTER K WITH CEDILLA @@ -330,7 +331,7 @@ 0x01c0 "\\textpipe" "tipa" "force,tipashortcut=|" # LATIN LETTER DENTAL CLICK 0x01c1 "\\textdoublepipe" "tipa" "force,tipashortcut=||" # LATIN LETTER LATERAL CLICK 0x01c2 "\\textdoublebarpipe" "tipa" "force" # LATIN LETTER ALVEOLAR CLICK -0x01c3 "!" "" "" # LATIN LETTER RETROFLEX CLICK +0x01c3 "!" "" "notermination" # LATIN LETTER RETROFLEX CLICK #0x01c4 "" "" "" # LATIN CAPITAL LETTER DZ WITH CARON #0x01c5 "" "" "" # LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON #0x01c6 "" "" "" # LATIN SMALL LETTER DZ WITH CARON @@ -1579,9 +1580,9 @@ 0x2001 "\\quad" "" "" "\\quad" "" # EM QUAD 0x2002 "\\enskip" "" "" "\\enskip" "" # EN SPACE 0x2003 "\\quad" "" "" "\\quad" "" # EM SPACE -0x2004 "\\;" "" "" "\\;" "" # THREE-PER-EM SPACE -0x2005 "\\:" "" "" "\\:" "" # FOUR-PER-EM SPACE -0x2006 "\\," "" "" "\\," "" # SIX-PER-EM SPACE +0x2004 "\\;" "" "notermination" "\\;" "" # THREE-PER-EM SPACE +0x2005 "\\:" "" "notermination" "\\:" "" # FOUR-PER-EM SPACE +0x2006 "\\," "" "notermination" "\\," "" # SIX-PER-EM SPACE 0x2007 "\\LyXFigureSpace" "\\newcommand*\\LyXFigureSpace{\\hphantom{0}}" "" "\\LyXFigureSpace" "\\newcommand*\\LyXFigureSpace{\\hphantom{0}}" # FIGURE SPACE 0x2008 "\\LyXPunctSpace" "\\newcommand*\\LyXPunctSpace{\\hphantom{,}}" "" "\\LyXPunctSpace" "\\newcommand*\\LyXPunctSpace{\\hphantom{,}}" # PUNCTUATION SPACE 0x2009 "\\LyXThinSpace" "\\newcommand*\\LyXThinSpace{\\,\\hspace{0pt}}" "" "\\LyXThinSpace" "\\newcommand*\\LyXThinSpace{\\,\\hspace{0pt}}" # THIN SPACE @@ -1591,9 +1592,9 @@ #0x200d "" "" "" "" "" # ZERO WIDTH JOINER #0x200e "" "" "" "" "" # LEFT-TO-RIGHT MARK #0x200f "" "" "" "" "" # RIGHT-TO-LEFT MARK -0x2010 "-" "" "" "" "" # HYPHEN # identic in LaTeX to FIGURE DASH -0x2011 "\\nobreakdash-" "amsmath" "" "" "" # NON-BREAKING HYPHEN -0x2012 "-" "" "" # FIGURE DASH +0x2010 "-" "" "notermination" "" "" # HYPHEN # identic in LaTeX to FIGURE DASH +0x2011 "\\nobreakdash-" "amsmath" "notermination" "" "" # NON-BREAKING HYPHEN +0x2012 "-" "" "notermination" # FIGURE DASH 0x2013 "\\textendash" "" "" # EN DASH 0x2014 "\\textemdash" "" "" # EM DASH # use the following macro for the character HORIZONTAL BAR @@ -1612,10 +1613,10 @@ 0x2021 "\\ddag" "" "" "\\ddagger" "" # DOUBLE DAGGER 0x2022 "\\textbullet" "textcomp" "" # BULLET 0x2023 "\\textifsymbol[ifgeo]{116}" "ifsym" "" # TRIANGULAR BULLET # ≈ 0x25b8 -0x2024 "." "" "" # ONE DOT LEADER # ≈ FULL STOP -0x2025 ".\\,." "" "" # TWO DOT LEADER +0x2024 "." "" "notermination" # ONE DOT LEADER # ≈ FULL STOP +0x2025 ".\\,." "" "notermination" # TWO DOT LEADER 0x2026 "\\ldots" "" "" "\\ldots" "" # HORIZONTAL ELLIPSIS -0x2027 "\\-" "" "" "" "" # HYPHENATION POINT +0x2027 "\\-" "" "notermination" "" "" # HYPHENATION POINT #0x2028 "" "" "" "" "" # LINE SEPARATOR #0x2029 "" "" "" "" "" # PARAGRAPH SEPARATOR #0x202a "" "" "" "" "" # LEFT-TO-RIGHT EMBEDDING @@ -1623,7 +1624,7 @@ #0x202c "" "" "" "" "" # POP DIRECTIONAL FORMATTING #0x202d "" "" "" "" "" # LEFT-TO-RIGHT OVERRIDE #0x202e "" "" "" "" "" # RIGHT-TO-LEFT OVERRIDE -0x202f "\\," "" "" "\\," "" # NARROW NO-BREAK SPACE +0x202f "\\," "" "notermination" "\\," "" # NARROW NO-BREAK SPACE 0x2030 "\\textperthousand" "textcomp" "" # PER MILLE SIGN 0x2031 "\\textpertenthousand" "textcomp" "" # PER TEN THOUSAND SIGN 0x2032 "\\textasciiacute" "textcomp" "" "\\prime" "" # PRIME @@ -1632,20 +1633,20 @@ 0x2035 "\\textasciigrave" "textcomp" "" "\\backprime" "amssymb" # REVERSED PRIME 0x2036 "\\textgravedbl" "textcomp" "" # REVERSED DOUBLE PRIME #0x2037 "" "" "" # REVERSED TRIPLE PRIME -0x2038 "\\^{}" "" "" # CARET +0x2038 "\\^{}" "" "notermination" # CARET 0x2039 "\\guilsinglleft" "" "" # SINGLE LEFT-POINTING ANGLE QUOTATION MARK 0x203a "\\guilsinglright" "" "" # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK 0x203b "\\textreferencemark" "textcomp" "" # REFERENCE MARK -0x203c "!!" "" "" # DOUBLE EXCLAMATION MARK # ≈ 2×EXCLAMATION MARK +0x203c "!!" "" "notermination" # DOUBLE EXCLAMATION MARK # ≈ 2×EXCLAMATION MARK 0x203d "\\textinterrobang" "textcomp" "" # INTERROBANG # use the following macro for the character OVERLINE 0x203e "\\LyXoverline" "\\newcommand*\\LyXoverline{\\raisebox{2.6ex}{\\_}}" "" 0x2044 "\\textfractionsolidus" "textcomp" "" # FRACTION SLASH 0x2045 "\\textlquill" "textcomp" "" # LEFT SQUARE BRACKET WITH QUILL 0x2046 "\\textrquill" "textcomp" "" # RIGHT SQUARE BRACKET WITH QUILL -0x2047 "??" "" "" # DOUBLE QUESTION MARK # ≈ 2×QUESTION MARK -0x2048 "?!" "" "" # QUESTION EXCLAMATION MARK -0x2049 "!?" "" "" # EXCLAMATION QUESTION MARK +0x2047 "??" "" "notermination" # DOUBLE QUESTION MARK # ≈ 2×QUESTION MARK +0x2048 "?!" "" "notermination" # QUESTION EXCLAMATION MARK +0x2049 "!?" "" "notermination" # EXCLAMATION QUESTION MARK 0x2052 "\\textdiscount" "textcomp" "" # COMMERCIAL MINUS SIGN 0x205d "\\vdots" "" "" # TRICOLON # ≈ VERTICAL ELLIPSIS #0x205e "" "" "" "" "" # VERTICAL FOUR DOTS @@ -1715,7 +1716,7 @@ 0x2105 "\\LyXcareof" "\\newcommand*\\LyXcareof{\\mbox{\\raisebox{.8ex}{c}\\kern-.175em\\raisebox{.2ex}{/}\\kern-.18em\\raisebox{-.2ex}{o}}}" "" # use the following macro for the character CADA UNA 0x2106 "\\LyXcadauna" "\\newcommand*\\LyXcadauna{\\mbox{\\raisebox{.8ex}{c}\\kern-.175em\\raisebox{.2ex}{/}\\kern-.18em\\raisebox{-.2ex}{u}}}" "" -0x2109 "°{}F" "" "" # DEGREE FARENHEIT +0x2109 "°{}F" "" "notermination" # DEGREE FARENHEIT # mathrsfs has no small letters #0x210a "" "" "" "\\mathscr{g}" "mathrsfs" # SCRIPT SMALL G 0x210b "" "" "" "\\mathscr{H}" "mathrsfs" # SCRIPT CAPITAL H @@ -1747,7 +1748,7 @@ 0x2127 "\\textmho" "textcomp" "" "\\mho" "amssymb" # INVERTED OHM SIGN 0x2128 "" "" "" "\\mathfrak{Z}" "amssymb" # BLACK-LETTER CAPITAL Z #0x2129 "" "" "" "" "" # TURNED GREEK SMALL LETTER IOTA -0x212a "K" "" "" # KELVIN SIGN +0x212a "K" "" "notermination" # KELVIN SIGN 0x212b "\\AA" "" "" # ANGSTROM SIGN 0x212c "" "" "" "\\mathscr{B}" "mathrsfs" # SCRIPT CAPITAL B 0x212d "" "" "" "\\mathfrak{C}" "amssymb" # BLACK-LETTER CAPITAL C @@ -1842,15 +1843,15 @@ 0x2193 "\\textdownarrow" "textcomp" "" "\\downarrow" # DOWNWARDS ARROW 0x2194 "" "" "" "\\leftrightarrow" # LEFT RIGHT ARROW 0x2195 "" "" "" "\\updownarrow" # UP DOWN ARROW -0x2196 "Home" "" "" "\\nwarrow" "amssymb" # Qt::Key_Home, NORTH WEST ARROW -0x2198 "End" "" "" "\\searrow" "" # Qt::Key_End, SOUTH EAST ARROW +0x2196 "Home" "" "notermination" "\\nwarrow" "amssymb" # Qt::Key_Home, NORTH WEST ARROW +0x2198 "End" "" "notermination" "\\searrow" "" # Qt::Key_End, SOUTH EAST ARROW 0x21a8 "{\\ascii\\ETB}" "ascii" "" # UP DOWN ARROW WITH BASE 0x21b5 "{\\Pisymbol{psy}{191}}" "pifont" "" # DOWNWARDS ARROW WITH CORNER LEFTWARDS, Return key -0x21de "Option-Up Arrow" "" "" "" # Qt::Key_PageUp, UPWARDS ARROW WITH DOUBLE STROKE = page up -0x21df "Option-Down Arrow" "" "" "" # Qt::Key_PageDown, DOWNWARDS ARROW WITH DOUBLE STROKE = page down -0x21e4 "Shift-Tab" "" "" "" # Qt::Key_Backtab, LEFTWARDS ARROW TO BAR = leftward tab -0x21e5 "Tab" "" "" "" # Qt::Key_Tab, RIGHTWARDS ARROW TO BAR = rightward tab -0x21ea "Caps Lock" "" "" "" # Qt::Key_CapsLock, UPWARDS WHITE ARROW FROM BAR = caps lock +0x21de "Option-Up Arrow" "" "notermination" "" # Qt::Key_PageUp, UPWARDS ARROW WITH DOUBLE STROKE = page up +0x21df "Option-Down Arrow" "" "notermination" "" # Qt::Key_PageDown, DOWNWARDS ARROW WITH DOUBLE STROKE = page down +0x21e4 "Shift-Tab" "" "notermination" "" # Qt::Key_Backtab, LEFTWARDS ARROW TO BAR = leftward tab +0x21e5 "Tab" "" "notermination" "" # Qt::Key_Tab, RIGHTWARDS ARROW TO BAR = rightward tab +0x21ea "Caps Lock" "" "notermination" "" # Qt::Key_CapsLock, UPWARDS WHITE ARROW FROM BAR = caps lock # # mathematical operators # @@ -1966,10 +1967,10 @@ 0x231a "\\Clocklogo" "marvosym" "" # WATCH #0x2320 "" "" "" # TOP HALF INTEGRAL #0x2321 "" "" "" # BOTTOM HALF INTEGRAL -0x2326 "Delete" "" "" "" # Qt::Key_Delete, ERASE TO THE RIGHT = delete to the right key +0x2326 "Delete" "" "notermination" "" # Qt::Key_Delete, ERASE TO THE RIGHT = delete to the right key 0x2328 "\\Keyboard" "marvosym" "" # KEYBOARD -0x232b "Backspace" "" "" "" # Qt::Key_Backspace, ERASE TO THE LEFT = delete to the left key -0x238b "Escape" "" "" "" # Qt::Key_Escape, BROKEN CIRCLE WITH NORTHWEST ARROW = escape +0x232b "Backspace" "" "notermination" "" # Qt::Key_Backspace, ERASE TO THE LEFT = delete to the left key +0x238b "Escape" "" "notermination" "" # Qt::Key_Escape, BROKEN CIRCLE WITH NORTHWEST ARROW = escape # # control pictures # @@ -2266,11 +2267,11 @@ # # ligatures # -0xfb00 "ff" "" "force" # LATIN SMALL LIGATURE FF -0xfb01 "fi" "" "force" # LATIN SMALL LIGATURE FI -0xfb02 "fl" "" "force" # LATIN SMALL LIGATURE FL -0xfb03 "ffi" "" "force" # LATIN SMALL LIGATURE FFI -0xfb04 "ffl" "" "force" # LATIN SMALL LIGATURE FFL +0xfb00 "ff" "" "force,notermination" # LATIN SMALL LIGATURE FF +0xfb01 "fi" "" "force,notermination" # LATIN SMALL LIGATURE FI +0xfb02 "fl" "" "force,notermination" # LATIN SMALL LIGATURE FL +0xfb03 "ffi" "" "force,notermination" # LATIN SMALL LIGATURE FFI +0xfb04 "ffl" "" "force,notermination" # LATIN SMALL LIGATURE FFL # # mathematical alphanumeric symbols # diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 8b1eaca96d..b7c3f7dc55 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -251,6 +251,8 @@ struct CharInfo { bool force; /// TIPA shortcut string tipashortcut; + /// This macro needs no termination (such as {} or space). + bool notermination; }; @@ -726,6 +728,15 @@ bool Encodings::isMathAlpha(char_type c) } +bool Encodings::needsTermination(char_type c) +{ + CharInfoMap::const_iterator const it = unicodesymbols.find(c); + if (it != unicodesymbols.end()) + return !it->second.notermination; + return true; +} + + Encoding const * Encodings::fromLyXName(string const & name) const { EncodingList::const_iterator const it = encodinglist.find(name); @@ -798,6 +809,7 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) info.combining = false; info.textfeature = false; info.force = false; + info.notermination = false; while (!flags.empty()) { string flag; flags = split(flags, flag, ','); @@ -808,6 +820,8 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) forced.insert(symbol); } else if (flag == "mathalpha") { mathalpha.insert(symbol); + } else if (flag == "notermination") { + info.notermination = true; } else if (contains(flag, "tipashortcut=")) { info.tipashortcut = split(flag, '='); } else { diff --git a/src/Encoding.h b/src/Encoding.h index 4d68c3b721..7b0fa8ec19 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -195,6 +195,11 @@ public: * letters and accented characters that are output as math commands. */ static bool isMathAlpha(char_type c); + /** + * Do we need to terminate this command (by {} or space)? + * This is true if the "notermination" flag is not set. + */ + static bool needsTermination(char_type c); /** * Register \p c as a mathmode command. */ diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 976218bed7..7a513aad64 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1289,7 +1289,8 @@ void Paragraph::Private::latexSpecialChar(otexstream & os, && prefixIs(latex, from_ascii("\\" + script))) column += writeScriptChars(os, latex, running_change, encoding, i) - 1; - else if (!prefixIs(nextlatex, from_ascii("\\")) + else if (Encodings::needsTermination(c) + && !prefixIs(nextlatex, from_ascii("\\")) && !prefixIs(nextlatex, from_ascii("{")) && !prefixIs(nextlatex, from_ascii("}")) && latex.length() > 1 && latex[latex.length() - 1] != '}' -- 2.39.5