]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_nestinset.C
index 776d7ddb70612f389c79cab5b9276f91400db993..890fe5c017bd9c53ed0c9fc062837fcfa1143ca5 100644 (file)
@@ -1,6 +1,3 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "math_nestinset.h"
 #include "math_cursor.h"
@@ -8,6 +5,7 @@
 #include "math_parser.h"
 #include "funcrequest.h"
 #include "debug.h"
+#include "BufferView.h"
 #include "frontends/Painter.h"
 
 
@@ -44,6 +42,7 @@ void MathNestInset::getPos(idx_type idx, pos_type pos, int & x, int & y) const
                x += 2;
 }
 
+
 void MathNestInset::substitute(MathMacro const & m)
 {
        for (idx_type i = 0; i < nargs(); ++i)
@@ -292,10 +291,12 @@ void MathNestInset::write(WriteStream & os) const
        os << '\\' << name().c_str();
        for (unsigned i = 0; i < nargs(); ++i)
                os << '{' << cell(i) << '}';
-       if (lock_ && !os.latex())
-               os << "\\lyxlock ";
        if (nargs() == 0)
-               os << ' ';
+               os.pendingSpace(true);
+       if (lock_ && !os.latex()) {
+               os << "\\lyxlock";
+               os.pendingSpace(true);
+       }
 }
 
 
@@ -308,17 +309,20 @@ void MathNestInset::normalize(NormalStream & os) const
 }
 
 
-void MathNestInset::notifyCursorLeaves()
-{}
+void MathNestInset::notifyCursorLeaves(idx_type idx)
+{
+       cell(idx).notifyCursorLeaves();
+}
 
 
-MathInset::result_type MathNestInset::dispatch
+dispatch_result MathNestInset::dispatch
        (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
 {
+       BufferView * bv = cmd.view();
+
        switch (cmd.action) {
 
                case LFUN_PASTE: {
-                       //lyxerr << "pasting '" << cmd.argument << "'\n";
                        MathArray ar;
                        mathed_parse_cell(ar, cmd.argument);
                        cell(idx).insert(pos, ar);
@@ -326,7 +330,17 @@ MathInset::result_type MathNestInset::dispatch
                        return DISPATCHED;
                }
 
-               default:        
+               case LFUN_PASTESELECTION:
+                       return
+                               dispatch(
+                                       FuncRequest(bv, LFUN_PASTE, bv->getClipboard()), idx, pos);
+
+               case LFUN_MOUSE_PRESS:
+                       if (cmd.button() == mouse_button::button2)
+                               return dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
+                       return UNDISPATCHED;
+
+               default:
                        return MathInset::dispatch(cmd, idx, pos);
        }
        return UNDISPATCHED;