]> git.lyx.org Git - features.git/commitdiff
Full delimiter support for llbracket and rrbracket
authorGeorg Baum <baum@lyx.org>
Sun, 16 Dec 2012 14:49:42 +0000 (15:49 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 16 Dec 2012 14:49:42 +0000 (15:49 +0100)
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
lib/images/math/llbracket.png [new file with mode: 0644]
lib/images/math/rrbracket.png [new file with mode: 0644]
src/frontends/qt4/GuiDelimiter.cpp
src/mathed/InsetMathDelim.cpp
src/mathed/InsetMathDelim.h
src/mathed/MathSupport.cpp

index 98887877720658a7b6cdace3c04f88d5b3acca0a..ea2d1f457723ff07ff3441a21fd97c8b58b51828 100644 (file)
@@ -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 (file)
index 0000000..3e4d957
Binary files /dev/null and b/lib/images/math/llbracket.png differ
diff --git a/lib/images/math/rrbracket.png b/lib/images/math/rrbracket.png
new file mode 100644 (file)
index 0000000..2082f69
Binary files /dev/null and b/lib/images/math/rrbracket.png differ
index 2736c2090cffc26c369f898fcb13fc5b0e44f701..8303fa64140783ed24b136acbb5b6c544c88feb7 100644 (file)
@@ -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;
index 0d2fd9760748d4c551285c4520af9b804b1affcf..0653e88b8c4f8e05631a83b30b8f1f2acab120a5 100644 (file)
 #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);
index cbea8ec01c10552af748430f6c6c7ae4e92628a7..72e204ed116df3652383a4635ee38e28ecad199e 100644 (file)
@@ -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
index 95d27b448307cfd558963d175f70430f85703e85..0a87fd69bae3c90f67a8a812eba790a2a3831ef6 100644 (file)
@@ -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 },