]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.C
Georg Baum's vspace change
[lyx.git] / src / mathed / math_cursor.C
index 8225a9eef1082a700b2c937513997471ceeac730..2d3400a699c5ea23095d0320112874d657b13960 100644 (file)
 
 #include <config.h>
 
+#include "math_cursor.h"
 #include "lyxrc.h"
 #include "support/limited_stack.h"
+#include "dispatchresult.h"
 #include "debug.h"
 #include "support/std_sstream.h"
-#include "math_cursor.h"
 #include "formulabase.h"
 #include "funcrequest.h"
 #include "math_braceinset.h"
 
 //#define FILEDEBUG 1
 
+using std::string;
 using std::endl;
+#ifndef CXX_GLOBAL_CSTD
 using std::isalpha;
+#endif
 using std::min;
 using std::swap;
 
@@ -432,8 +436,14 @@ bool MathCursor::backspace()
                }
        }
 
-       --pos();
-       plainErase();
+       if (hasPrevAtom() && prevAtom()->nargs() > 0) {
+               // let's require two backspaces for 'big stuff' and
+               // highlight on the first
+               left(true);
+       } else {
+               --pos();
+               plainErase();
+       }
        return true;
 }
 
@@ -1403,7 +1413,7 @@ CursorPos MathCursor::normalAnchor() const
 }
 
 
-dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
+DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
 {
        // mouse clicks are somewhat special
        // check
@@ -1413,17 +1423,19 @@ dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
                case LFUN_MOUSE_RELEASE:
                case LFUN_MOUSE_DOUBLE: {
                        CursorPos & pos = Cursor_.back();
-                       dispatch_result res = UNDISPATCHED;
-                       int x = 0, y = 0;
+                       int x = 0;
+                       int y = 0;
                        getPos(x, y);
                        if (x < cmd.x && hasPrevAtom()) {
-                               res = prevAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
-                               if (res != UNDISPATCHED)
+                               DispatchResult const res =
+                                       prevAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
+                               if (res.dispatched())
                                        return res;
                        }
                        if (x > cmd.x && hasNextAtom()) {
-                               res = nextAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
-                               if (res != UNDISPATCHED)
+                               DispatchResult const res =
+                                       nextAtom().nucleus()->dispatch(cmd, pos.idx_, pos.pos_);
+                               if (res.dispatched())
                                        return res;
                        }
                }
@@ -1433,16 +1445,17 @@ dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
 
        for (int i = Cursor_.size() - 1; i >= 0; --i) {
                CursorPos & pos = Cursor_[i];
-               dispatch_result res = pos.inset_->dispatch(cmd, pos.idx_, pos.pos_);
-               if (res != UNDISPATCHED) {
-                       if (res == DISPATCHED_POP) {
+               DispatchResult const res =
+                       pos.inset_->dispatch(cmd, pos.idx_, pos.pos_);
+               if (res.dispatched()) {
+                       if (res.val() == FINISHED) {
                                Cursor_.shrink(i + 1);
                                selClear();
                        }
                        return res;
                }
        }
-       return UNDISPATCHED;
+       return DispatchResult(false);
 }