]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathPhantom.cpp
Fix #10778 (issue with CJK and language nesting)
[lyx.git] / src / mathed / InsetMathPhantom.cpp
index b8c965b21cfde45139b45abc08e6d6e2d654d7e3..9b1c80ad3287129b00e1a4f24859bf6959bf3eba 100644 (file)
@@ -16,6 +16,7 @@
 #include "MathStream.h"
 #include "frontends/Painter.h"
 
+#include <algorithm>
 #include <ostream>
 
 namespace lyx {
@@ -197,7 +198,7 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
                pi.pain.line(x1, y2, x3, y2, Color_added_space);
        }
 
-       else if (kind_ == smash) {
+       else if (kind_ == smash || kind_ == smasht || kind_ == smashb) {
                // y1---------
                //            |
                // y2-----  \ | /
@@ -222,15 +223,24 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
                int const y4 = std::min(y5, y3 + arrow_size);
 
                // top arrow
-               pi.pain.line(x1, y2, x2, y3, Color_added_space);
-               pi.pain.line(x3, y2, x2, y3, Color_added_space);
+               if (kind_ != smashb) {
+                       pi.pain.line(x1, y2, x2, y3, Color_added_space);
+                       pi.pain.line(x3, y2, x2, y3, Color_added_space);
+               }
 
                // bottom arrow
-               pi.pain.line(x1, y4, x2, y3, Color_added_space);
-               pi.pain.line(x3, y4, x2, y3, Color_added_space);
+               if (kind_ != smasht) {
+                       pi.pain.line(x1, y4, x2, y3, Color_added_space);
+                       pi.pain.line(x3, y4, x2, y3, Color_added_space);
+               }
 
                // joining line
-               pi.pain.line(x2, y1, x2, y5, Color_added_space);
+               if (kind_ == smasht)
+                       pi.pain.line(x2, y1, x2, y3, Color_added_space);
+               else if (kind_ == smashb)
+                       pi.pain.line(x2, y3, x2, y5, Color_added_space);
+               else
+                       pi.pain.line(x2, y1, x2, y5, Color_added_space);
        }
 
        drawMarkers(pi, x, y);
@@ -255,6 +265,12 @@ void InsetMathPhantom::write(WriteStream & os) const
        case smash:
                os << "\\smash{";
                break;
+       case smasht:
+               os << "\\smash[t]{";
+               break;
+       case smashb:
+               os << "\\smash[b]{";
+               break;
        case mathclap:
                os << "\\mathclap{";
                break;
@@ -284,6 +300,12 @@ void InsetMathPhantom::normalize(NormalStream & os) const
        case smash:
                os << "[smash ";
                break;
+       case smasht:
+               os << "[smasht ";
+               break;
+       case smashb:
+               os << "[smashb ";
+               break;
        case mathclap:
                os << "[mathclap ";
                break;
@@ -313,6 +335,12 @@ void InsetMathPhantom::infoize(odocstream & os) const
        case smash:
                os << "Smash";
                break;
+       case smasht:
+               os << "Smashtop";
+               break;
+       case smashb:
+               os << "Smashbottom";
+               break;
        case mathllap:
                os << "Mathllap";
                break;
@@ -335,6 +363,10 @@ void InsetMathPhantom::validate(LaTeXFeatures & features) const
        case hphantom:
        case smash:
                break;
+       case smasht:
+       case smashb:
+               features.require("amsmath");
+               break;
        case mathclap:
        case mathllap:
        case mathrlap: