]> git.lyx.org Git - features.git/commitdiff
reenable TAB and S-TAB in math, fixing a regression against 1.3
authorAndré Pönitz <poenitz@gmx.net>
Mon, 18 Jul 2005 00:09:20 +0000 (00:09 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 18 Jul 2005 00:09:20 +0000 (00:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10307 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_gridinset.C
src/mathed/math_hullinset.C
src/mathed/math_nestinset.C

index ece8d90158973779c70c3862d9c54241de2c1bdc..c9fcfcc5141aad10451d4638a5405db61aec1113 100644 (file)
@@ -1065,6 +1065,25 @@ void MathGridInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                splitCell(cur);
                break;
 
+       case LFUN_CELL_BACKWARD:
+               // See below.
+               cur.selection() = false;
+               if (!idxPrev(cur)) {
+                       cmd = FuncRequest(LFUN_FINISHED_LEFT);
+                       cur.undispatched();
+               }
+               break;
+       
+       case LFUN_CELL_FORWARD:
+               // Can't handle selection by additional 'shift' as this is
+               // hard bound to LFUN_CELL_BACKWARD
+               cur.selection() = false;
+               if (!idxNext(cur)) {
+                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
+               }
+               break;
+
        case LFUN_BREAKLINE: {
                recordUndoInset(cur);
                row_type const r = cur.row();
@@ -1262,28 +1281,28 @@ void MathGridInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 
 
 bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
-               FuncStatus & flag) const
+               FuncStatus & status) const
 {
        switch (cmd.action) {
        case LFUN_TABULAR_FEATURE: {
                string const s = cmd.argument;
                if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) {
-                       flag.enabled(false);
-                       flag.message(N_("Only one row"));
+                       status.enabled(false);
+                       status.message(N_("Only one row"));
                        return true;
                }
                if (ncols() <= 1 &&
                    (s == "delete-column" || s == "swap-column")) {
-                       flag.enabled(false);
-                       flag.message(N_("Only one column"));
+                       status.enabled(false);
+                       status.message(N_("Only one column"));
                        return true;
                }
                if ((rowinfo_[cur.row()].lines_ == 0 &&
                     s == "delete-hline-above") ||
                    (rowinfo_[cur.row() + 1].lines_ == 0 &&
                     s == "delete-hline-below")) {
-                       flag.enabled(false);
-                       flag.message(N_("No hline to delete"));
+                       status.enabled(false);
+                       status.message(N_("No hline to delete"));
                        return true;
                }
 
@@ -1291,8 +1310,8 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
                     s == "delete-vline-left") ||
                    (colinfo_[cur.col() + 1].lines_ == 0 &&
                     s == "delete-vline-right")) {
-                       flag.enabled(false);
-                       flag.message(N_("No vline to delete"));
+                       status.enabled(false);
+                       status.message(N_("No vline to delete"));
                        return true;
                }
                if (s == "valign-top" || s == "valign-middle" ||
@@ -1306,14 +1325,14 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
                    s == "copy-column" || s == "swap-column" ||
                    s == "add-vline-left" || s == "add-vline-right" ||
                    s == "delete-vline-left" || s == "delete-vline-right")
-                       flag.enabled(true);
+                       status.enabled(true);
                else {
-                       flag.enabled(false);
-                       flag.message(bformat(
+                       status.enabled(false);
+                       status.message(bformat(
                                N_("Unknown tabular feature '%1$s'"), s));
                }
 
-               flag.setOnOff(s == "align-left"    && halign(cur.col()) == 'l'
+               status.setOnOff(s == "align-left"    && halign(cur.col()) == 'l'
                           || s == "align-right"   && halign(cur.col()) == 'r'
                           || s == "align-center"  && halign(cur.col()) == 'c'
                           || s == "valign-top"    && valign() == 't'
@@ -1325,26 +1344,33 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
                // Please check whether it is still needed!
                // should be more precise
                if (v_align_ == '\0') {
-                       flag.enable(true);
+                       status.enable(true);
                        break;
                }
                if (cmd.argument.empty()) {
-                       flag.enable(false);
+                       status.enable(false);
                        break;
                }
                if (!lyx::support::contains("tcb", cmd.argument[0])) {
-                       flag.enable(false);
+                       status.enable(false);
                        break;
                }
-               flag.setOnOff(cmd.argument[0] == v_align_);
-               flag.enabled(true);
+               status.setOnOff(cmd.argument[0] == v_align_);
+               status.enabled(true);
 #endif
                return true;
        }
+
        case LFUN_CELL_SPLIT:
-               flag.enabled(true);
+               status.enabled(true);
                return true;
+
+       case LFUN_CELL_BACKWARD:
+       case LFUN_CELL_FORWARD:
+               status.enabled(true);
+               return true;
+
        default:
-               return MathNestInset::getStatus(cur, cmd, flag);
+               return MathNestInset::getStatus(cur, cmd, status);
        }
 }
index dcec2d249c4117d15f4ef2ac8daea570ccecd04d..70d2f71ea1fa17e4f4ed8ae91d7cc9b58cdc4f53 100644 (file)
@@ -1119,9 +1119,10 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 
 
 bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
-               FuncStatus & flag) const
+               FuncStatus & status) const
 {
        switch (cmd.action) {
+       // These are only enabled inside tabular
        case LFUN_BREAKLINE:
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_NONUMBER:
@@ -1129,10 +1130,10 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
        case LFUN_MATH_MUTATE:
        case LFUN_MATH_DISPLAY:
                // we handle these
-               flag.enabled(true);
+               status.enabled(true);
                return true;
        case LFUN_INSERT_LABEL:
-               flag.enabled(type_ != "simple");
+               status.enabled(type_ != "simple");
                return true;
        case LFUN_TABULAR_FEATURE: {
                istringstream is(cmd.argument);
@@ -1142,49 +1143,49 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
                    && (s == "append-row"
                        || s == "delete-row"
                        || s == "copy-row")) {
-                       flag.message(bformat(
+                       status.message(bformat(
                                N_("Can't change number of rows in '%1$s'"),
                                type_));
-                       flag.enabled(false);
+                       status.enabled(false);
                        return true;
                }
                if (!colChangeOK()
                    && (s == "append-column"
                        || s == "delete-column"
                        || s == "copy-column")) {
-                       flag.message(bformat(
+                       status.message(bformat(
                                N_("Can't change number of columns in '%1$s'"),
                                type_));
-                       flag.enabled(false);
+                       status.enabled(false);
                        return true;
                }
                if ((type_ == "simple"
                  || type_ == "equation"
                  || type_ == "none") &&
                    (s == "add-hline-above" || s == "add-hline-below")) {
-                       flag.message(bformat(
+                       status.message(bformat(
                                N_("Can't add horizontal grid lines in '%1$s'"),
                                type_));
-                       flag.enabled(false);
+                       status.enabled(false);
                        return true;
                }
                if (s == "add-vline-left" || s == "add-vline-right") {
-                       flag.message(bformat(
+                       status.message(bformat(
                                N_("Can't add vertical grid lines in '%1$s'"),
                                type_));
-                       flag.enabled(false);
+                       status.enabled(false);
                        return true;
                }
                if (s == "valign-top" || s == "valign-middle"
                 || s == "valign-bottom" || s == "align-left"
                 || s == "align-center" || s == "align-right") {
-                       flag.enabled(false);
+                       status.enabled(false);
                        return true;
                }
-               return MathGridInset::getStatus(cur, cmd, flag);
+               return MathGridInset::getStatus(cur, cmd, status);
        }
        default:
-               return MathGridInset::getStatus(cur, cmd, flag);
+               return MathGridInset::getStatus(cur, cmd, status);
        }
 }
 
index a342701abb716da61f50af653d4dc2df453003cc..db2e556b305c1d61cc61ffa2f014025030cc8d97 100644 (file)
@@ -473,8 +473,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                } else if (cur.posRight() || idxRight(cur)
                        || cur.popRight() || cur.selection())
                        ;
-               else
+               else {
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_LEFTSEL:
@@ -490,8 +492,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                } else if (cur.posLeft() || idxLeft(cur)
                        || cur.popLeft() || cur.selection())
                        ;
-               else
+               else {
                        cmd = FuncRequest(LFUN_FINISHED_LEFT);
+                       cur.undispatched();
+               }
                break;
 
        case LFUN_UPSEL:
@@ -503,8 +507,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        break;
                }
                cur.selHandle(cmd.action == LFUN_UPSEL);
-               if (!cur.up())
+               if (!cur.up()) {
                        cmd = FuncRequest(LFUN_FINISHED_UP);
+                       cur.undispatched();
+               }
                // fixes bug 1598. Please check!
                cur.normalize();
                break;
@@ -516,8 +522,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        break;
                }
                cur.selHandle(cmd.action == LFUN_DOWNSEL);
-               if (!cur.down())
+               if (!cur.down()) {
                        cmd = FuncRequest(LFUN_FINISHED_DOWN);
+                       cur.undispatched();
+               }
                // fixes bug 1598. Please check!
                cur.normalize();
                break;
@@ -642,8 +650,10 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
                        cur.insert(cmd.argument);
                        break;
                }
-               if (!interpret(cur, cmd.argument[0]))
+               if (!interpret(cur, cmd.argument[0])) {
                        cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
+               }
                break;
 
        //case LFUN_GETXY: