]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
The previous commit was actually a fix for bug #9158.
[lyx.git] / src / mathed / InsetMathNest.cpp
index 94b4d68e581d70f0e72de69ab91131c0048cb388..87b7f42d293946424d76d5102d85c675b9b9239c 100644 (file)
@@ -50,6 +50,7 @@
 #include "FuncStatus.h"
 #include "LyX.h"
 #include "LyXRC.h"
+#include "MetricsInfo.h"
 #include "OutputParams.h"
 #include "Text.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,7 +251,9 @@ bool InsetMathNest::idxLast(Cursor & cur) const
 void InsetMathNest::dump() const
 {
        odocstringstream oss;
-       WriteStream os(oss);
+       TexRow texrow(false);
+       otexrowstream ots(oss,texrow);
+       WriteStream os(ots);
        os << "---------------------------------------------\n";
        write(os);
        os << "\n";
@@ -376,8 +379,10 @@ void InsetMathNest::write(WriteStream & os) const
        ModeSpecifier specifier(os, currentMode(), lockedMode());
        docstring const latex_name = name();
        os << '\\' << latex_name;
-       for (size_t i = 0; i < nargs(); ++i)
+       for (size_t i = 0; i < nargs(); ++i) {
+               Changer dummy = os.changeRowEntry(TexRow::mathEntry(id(),i));
                os << '{' << cell(i) << '}';
+       }
        if (nargs() == 0)
                os.pendingSpace(true);
        if (lock_ && !os.latex()) {
@@ -398,22 +403,16 @@ void InsetMathNest::normalize(NormalStream & os) const
 
 void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
 {
-       WriteStream wi(os.os(), runparams.moving_arg, true,
-                      runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
-                      runparams.encoding);
+       WriteStream wi(os, runparams.moving_arg, true,
+                       runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
+                       runparams.encoding);
        wi.canBreakLine(os.canBreakLine());
+       Changer dummy = wi.changeRowEntry(os.texrow().textEntry(runparams.lastid,
+                                                               runparams.lastpos));
        write(wi);
        // Reset parbreak status after a math inset.
        os.lastChar(0);
        os.canBreakLine(wi.canBreakLine());
-
-       int lf = wi.line();
-       if (lf > 0 && runparams.lastid != -1) {
-               --lf;
-               os.texrow().newline();
-               os.texrow().start(runparams.lastid, runparams.lastpos);
-       }
-       os.texrow().newlines(lf);
 }
 
 
@@ -579,7 +578,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());
@@ -712,8 +711,10 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.selHandle(select);
 
                // handle autocorrect:
-               cur.autocorrect() = false;
-               cur.message(_("Autocorrect Off ('!' to enter)"));
+               if (lyxrc.autocorrection_math && cur.autocorrect()) {
+                       cur.autocorrect() = false;
+                       cur.message(_("Autocorrect Off ('!' to enter)"));
+               }
 
                // go up/down
                bool up = act == LFUN_UP || act == LFUN_UP_SELECT;
@@ -732,12 +733,19 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_MOUSE_DOUBLE:
-       case LFUN_MOUSE_TRIPLE:
        case LFUN_WORD_SELECT:
                cur.pos() = 0;
+               cur.resetAnchor();
+               cur.selection(true);
+               cur.pos() = cur.lastpos();
+               cur.bv().cursor() = cur;
+               break;
+
+       case LFUN_MOUSE_TRIPLE:
                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;
@@ -1542,7 +1550,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;
@@ -1609,7 +1617,7 @@ void InsetMathNest::lfunMouseRelease(Cursor & cur, FuncRequest & cmd)
                        cur.noScreenUpdate();
                else {
                        Cursor & bvcur = cur.bv().cursor();
-                       bvcur.setSelection(true);
+                       bvcur.selection(true);
                }
                return;
        }
@@ -1750,7 +1758,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;
        }
 
@@ -2161,6 +2169,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        globals.push_back(from_ascii("\\sqrt"));
        globals.push_back(from_ascii("\\root"));
        globals.push_back(from_ascii("\\tabular"));
+       globals.push_back(from_ascii("\\sideset"));
        globals.push_back(from_ascii("\\stackrel"));
        globals.push_back(from_ascii("\\stackrelthree"));
        globals.push_back(from_ascii("\\binom"));