From 01a6d4252b94c3b0a38faf32da1eea9b17cbf3c5 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 16 Dec 2012 15:49:42 +0100 Subject: [PATCH] Full delimiter support for llbracket and rrbracket stmaryrd.sty sets these symbols up as variable size math delimiters (i.e. they may be used with \left and \right). Now LyX knows about that and offers them in the delimiter dialog as well as single symbols. --- lib/Makefile.am | 2 ++ lib/images/math/llbracket.png | Bin 0 -> 143 bytes lib/images/math/rrbracket.png | Bin 0 -> 143 bytes src/frontends/qt4/GuiDelimiter.cpp | 5 +++++ src/mathed/InsetMathDelim.cpp | 27 +++++++++++++++++++++++++++ src/mathed/InsetMathDelim.h | 2 ++ src/mathed/MathSupport.cpp | 11 +++++++++++ 7 files changed, 47 insertions(+) create mode 100644 lib/images/math/llbracket.png create mode 100644 lib/images/math/rrbracket.png diff --git a/lib/Makefile.am b/lib/Makefile.am index 9888787772..ea2d1f4577 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -708,6 +708,7 @@ dist_imagesmath_DATA = \ images/math/lfloor.png \ images/math/lfloor_rfloor.png \ images/math/ll.png \ + images/math/llbracket.png \ images/math/llcorner.png \ images/math/Lleftarrow.png \ images/math/lll.png \ @@ -862,6 +863,7 @@ dist_imagesmath_DATA = \ images/math/risingdotseq.png \ images/math/root.png \ images/math/rparen.png \ + images/math/rrbracket.png \ images/math/Rrightarrow.png \ images/math/Rsh.png \ images/math/rtimes.png \ diff --git a/lib/images/math/llbracket.png b/lib/images/math/llbracket.png new file mode 100644 index 0000000000000000000000000000000000000000..3e4d957fce5185e4f0de06c449162fc0b6f44f62 GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^>_9BS!3HE91=ODbDYhhUcNd2LAh=-f^2tCE&H|6f zVg?3oVGw3ym^DWND5&r0;uxZFJ~`n4v&6zL^)^L3|AC<2$JhV_9vYX06g8+wUU>A` f{^Z17Q3i&G@jRkhM~uDzwK90R`njxgN@xNAqUI@4 literal 0 HcmV?d00001 diff --git a/lib/images/math/rrbracket.png b/lib/images/math/rrbracket.png new file mode 100644 index 0000000000000000000000000000000000000000..2082f6955ccbe9af147908f98228814b57c1bfaa GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^>_9BS!3HE91=ODbDYhhUcNd2LAh=-f^2tCE&H|6f zVg?3oVGw3ym^DWND5&r0;uxZFJ~`n4v&6zL^>d2;|No!<`c&ETBBaq%Q( kl}^5Y%9mS|rNtQ-j-TZhve;mE4ycvE)78&qol`;+03)U=mH+?% literal 0 HcmV?d00001 diff --git a/src/frontends/qt4/GuiDelimiter.cpp b/src/frontends/qt4/GuiDelimiter.cpp index 2736c2090c..8303fa6414 100644 --- a/src/frontends/qt4/GuiDelimiter.cpp +++ b/src/frontends/qt4/GuiDelimiter.cpp @@ -41,6 +41,7 @@ namespace { static char const * latex_delimiters[] = { "(", ")", "{", "}", "[", "]", "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle", + "llbracket", "rrbracket", "uparrow", "updownarrow", "Uparrow", "Updownarrow", "downarrow", "Downarrow", "|", "Vert", "/", "backslash", "" }; @@ -114,6 +115,8 @@ void initMathSymbols() math_symbols_["rfloor"] = MathSymbol(0x230B, 99, CMSY_FAMILY); math_symbols_["langle"] = MathSymbol(0x2329, 104, CMSY_FAMILY); math_symbols_["rangle"] = MathSymbol(0x232A, 105, CMSY_FAMILY); + math_symbols_["llbracket"] = MathSymbol(0x27e6, 74, STMARY_FAMILY); + math_symbols_["rrbracket"] = MathSymbol(0x27e7, 75, STMARY_FAMILY); math_symbols_["uparrow"] = MathSymbol(0x2191, 34, CMSY_FAMILY); math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, CMSY_FAMILY); math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, CMSY_FAMILY); @@ -233,6 +236,8 @@ char_type GuiDelimiter::doMatch(char_type const symbol) else if (str == "lfloor") match = "rfloor"; else if (str == "rangle") match = "langle"; else if (str == "langle") match = "rangle"; + else if (str == "llbracket") match = "rrbracket"; + else if (str == "rrbracket") match = "llbracket"; else if (str == "backslash") match = "/"; else if (str == "/") match = "backslash"; else return symbol; diff --git a/src/mathed/InsetMathDelim.cpp b/src/mathed/InsetMathDelim.cpp index 0d2fd97607..0653e88b8c 100644 --- a/src/mathed/InsetMathDelim.cpp +++ b/src/mathed/InsetMathDelim.cpp @@ -14,10 +14,13 @@ #include "InsetMathDelim.h" #include "MathData.h" +#include "MathFactory.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" +#include "LaTeXFeatures.h" + #include "support/docstring.h" #include "frontends/FontMetrics.h" @@ -58,6 +61,30 @@ Inset * InsetMathDelim::clone() const } +void InsetMathDelim::validate(LaTeXFeatures & features) const +{ + InsetMathNest::validate(features); + // The delimiters may be used without \left or \right as well. + // Therefore they are listed in lib/symbols, and if they have + // requirements, we need to add them here. + MathWordList const & words = mathedWordList(); + MathWordList::const_iterator it = words.find(left_); + if (it != words.end()) + { + docstring const req = it->second.requires; + if (!req.empty()) + features.require(to_ascii(req)); + } + it = words.find(right_); + if (it != words.end()) + { + docstring const req = it->second.requires; + if (!req.empty()) + features.require(to_ascii(req)); + } +} + + void InsetMathDelim::write(WriteStream & os) const { MathEnsurer ensurer(os); diff --git a/src/mathed/InsetMathDelim.h b/src/mathed/InsetMathDelim.h index cbea8ec01c..72e204ed11 100644 --- a/src/mathed/InsetMathDelim.h +++ b/src/mathed/InsetMathDelim.h @@ -45,6 +45,8 @@ public: /// void draw(PainterInfo &, int x, int y) const; + /// + void validate(LaTeXFeatures & features) const; /// void write(WriteStream & os) const; /// write normalized content diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index 95d27b4483..0a87fd69ba 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -160,6 +160,15 @@ double const brack[] = { }; +double const dbrack[] = { + 2, 4, + 0.95, 0.05, 0.05, 0.05, 0.05, 0.95, 0.95, 0.95, + 2, 2, + 0.50, 0.05, 0.50, 0.95, + 0 +}; + + double const corner[] = { 2, 3, 0.95, 0.05, 0.05, 0.05, 0.05, 0.95, @@ -299,6 +308,8 @@ named_deco_struct deco_table[] = { {"rbrace", brace, 2 }, {"[", brack, 0 }, {"]", brack, 2 }, + {"llbracket", dbrack, 0 }, + {"rrbracket", dbrack, 2 }, {"|", vert, 0 }, {"/", slash, 0 }, {"slash", slash, 0 },