]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
Get rid of Inset::setPosCache
[lyx.git] / src / mathed / InsetMathNest.cpp
index 9d90c1959ddab418722fbaad5bf0f89176424d2f..ecd823063e092fc357c7b9a4075c16623852671f 100644 (file)
 #include "Encoding.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
+#include "LaTeXFeatures.h"
 #include "LyX.h"
 #include "LyXRC.h"
+#include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "TexRow.h"
 #include "Text.h"
 
 #include "frontends/Application.h"
 #include "frontends/Painter.h"
 #include "frontends/Selection.h"
 
-#include "support/lassert.h"
 #include "support/debug.h"
+#include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
-#include "support/docstream.h"
 
 #include <algorithm>
 #include <sstream>
@@ -250,8 +253,7 @@ bool InsetMathNest::idxLast(Cursor & cur) const
 void InsetMathNest::dump() const
 {
        odocstringstream oss;
-       TexRow texrow(false);
-       otexrowstream ots(oss,texrow);
+       otexrowstream ots(oss);
        WriteStream os(ots);
        os << "---------------------------------------------\n";
        write(os);
@@ -263,14 +265,13 @@ void InsetMathNest::dump() const
 }
 
 
-void InsetMathNest::draw(PainterInfo & pi, int x, int y) const
+void InsetMathNest::draw(PainterInfo &, int, int) const
 {
 #if 0
        if (lock_)
                pi.pain.fillRectangle(x, y - ascent(), width(), height(),
                                        Color_mathlockbg);
 #endif
-       setPosCache(pi, x, y);
 }
 
 
@@ -379,9 +380,8 @@ void InsetMathNest::write(WriteStream & os) const
        docstring const latex_name = name();
        os << '\\' << latex_name;
        for (size_t i = 0; i < nargs(); ++i) {
-               os.pushRowEntry(TexRow::mathEntry(id(),i));
+               Changer dummy = os.changeRowEntry(TexRow::mathEntry(id(),i));
                os << '{' << cell(i) << '}';
-               os.popRowEntry();
        }
        if (nargs() == 0)
                os.pendingSpace(true);
@@ -406,14 +406,22 @@ void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
        WriteStream wi(os, runparams.moving_arg, true,
                        runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
                        runparams.encoding);
+       wi.strikeoutMath(runparams.inDeletedInset
+                        && (!LaTeXFeatures::isAvailable("dvipost")
+                               || (runparams.flavor != OutputParams::LATEX
+                                   && runparams.flavor != OutputParams::DVILUATEX)));
+       if (runparams.inulemcmd) {
+               wi.ulemCmd(WriteStream::UNDERLINE);
+               if (runparams.local_font) {
+                       FontInfo f = runparams.local_font->fontInfo();
+                       if (f.strikeout() == FONT_ON)
+                               wi.ulemCmd(WriteStream::STRIKEOUT);
+               }
+       }
        wi.canBreakLine(os.canBreakLine());
-       if (runparams.lastid != -1) {
-               wi.pushRowEntry(os.texrow().textEntry(runparams.lastid,
-                                                                                         runparams.lastpos));
-               write(wi);
-               wi.popRowEntry();
-       } else
-               write(wi);
+       Changer dummy = wi.changeRowEntry(TexRow::textEntry(runparams.lastid,
+                                                           runparams.lastpos));
+       write(wi);
        // Reset parbreak status after a math inset.
        os.lastChar(0);
        os.canBreakLine(wi.canBreakLine());
@@ -582,7 +590,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                replaceSelection(cur);
                docstring topaste;
                if (cmd.argument().empty() && !theClipboard().isInternal())
-                       topaste = theClipboard().getAsText(Clipboard::PlainTextType);
+                       topaste = theClipboard().getAsText(frontend::Clipboard::PlainTextType);
                else {
                        size_t n = 0;
                        idocstringstream is(cmd.argument());
@@ -740,7 +748,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_WORD_SELECT:
                cur.pos() = 0;
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cur.pos() = cur.lastpos();
                cur.bv().cursor() = cur;
                break;
@@ -749,7 +757,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.idx() = 0;
                cur.pos() = 0;
                cur.resetAnchor();
-               cur.setSelection(true);
+               cur.selection(true);
                cur.idx() = cur.lastidx();
                cur.pos() = cur.lastpos();
                cur.bv().cursor() = cur;
@@ -1554,7 +1562,7 @@ void InsetMathNest::lfunMousePress(Cursor & cur, FuncRequest & cmd)
                }
        }
        bool do_selection = cmd.button() == mouse_button::button1
-               && cmd.argument() == "region-select";
+               && cmd.modifier() == ShiftModifier;
        bv.mouseSetCursor(cur, do_selection);
        if (cmd.button() == mouse_button::button1) {
                //lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl;
@@ -1621,7 +1629,7 @@ void InsetMathNest::lfunMouseRelease(Cursor & cur, FuncRequest & cmd)
                        cur.noScreenUpdate();
                else {
                        Cursor & bvcur = cur.bv().cursor();
-                       bvcur.setSelection(true);
+                       bvcur.selection(true);
                }
                return;
        }
@@ -1762,7 +1770,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
 
        // just clear selection on pressing the space bar
        if (cur.selection() && c == ' ') {
-               cur.setSelection(false);
+               cur.selection(false);
                return true;
        }
 
@@ -1860,7 +1868,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        cur.niceInsert(createInsetMath("sim", buf));
                        return true;
                }
-               if (currentMode() == InsetMath::MATH_MODE && !isAsciiOrMathAlpha(c)) {
+               if (currentMode() == InsetMath::MATH_MODE && Encodings::isUnicodeTextOnly(c)) {
                        MathAtom at = createInsetMath("text", buf);
                        at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
                        cur.niceInsert(at);