]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Add commented-out code that might prove useful one day
[lyx.git] / src / Text3.cpp
index 3abc6a2ec26a00694ee35bead81e5750869b48d5..148b1d4f8bb53ded73420b51af2ecc37e19ebcde 100644 (file)
@@ -750,7 +750,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (cur.selection())
                        cutSelection(cur, false);
                else
-                       deleteWordForward(cur, cmd.getArg(0) == "force");
+                       deleteWordForward(cur, cmd.getArg(0) != "confirm");
                finishChange(cur, false);
                break;
 
@@ -758,7 +758,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (cur.selection())
                        cutSelection(cur, false);
                else
-                       deleteWordBackward(cur, cmd.getArg(0) == "force");
+                       deleteWordBackward(cur, cmd.getArg(0) != "confirm");
                finishChange(cur, false);
                break;
 
@@ -915,12 +915,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UP:
        case LFUN_DOWN: {
                // stop/start the selection
-               bool const select = cmd.action() == LFUN_DOWN_SELECT
-                                       || cmd.action() == LFUN_UP_SELECT;
+               bool select = cmd.action() == LFUN_DOWN_SELECT ||
+                       cmd.action() == LFUN_UP_SELECT;
+
                // move cursor up/down
-               bool const up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
+               bool up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
+               bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
 
-               if (!cur.atFirstOrLastRow(up)) {
+               if (!atFirstOrLastRow) {
                        needsUpdate |= cur.selHandle(select);
                        cur.upDownInText(up, needsUpdate);
                        needsUpdate |= cur.beforeDispatchCursor().inMathed();
@@ -936,35 +938,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                        cur.forceBufferUpdate();
                                break;
                        }
-                       needsUpdate |= cur.selHandle(select);
-                       bool const can_move = cur.upDownInText(up, needsUpdate);
-                       // if the cursor can be moved up or down at an upper level,
-                       // delegate the dispatch to next level. Otherwise, we are
-                       // done.
-                       if (can_move) {
-                               cmd = FuncRequest(up ? LFUN_FINISHED_UP : LFUN_FINISHED_DOWN);
-                               cur.undispatched();
-                       }
-               }
-
-               break;
-       }
 
-       case LFUN_FINISHED_UP:
-       case LFUN_FINISHED_DOWN: {
-               // move cursor up/down
-               bool const up = cmd.action() == LFUN_FINISHED_UP;
-
-               if (!cur.atFirstOrLastRow(up)) {
+                       // if the cursor cannot be moved up or down do not remove
+                       // the selection right now, but wait for the next dispatch.
+                       if (select)
+                               needsUpdate |= cur.selHandle(select);
                        cur.upDownInText(up, needsUpdate);
-                       needsUpdate |= cur.beforeDispatchCursor().inMathed();
-               } else {
-                       bool const can_move = cur.upDownInText(up, needsUpdate);
-                       // if the cursor can be moved up or down and we are not
-                       // moving cusor at top level, wait for the next dispatch.
-                       // Otherwise, we are done.
-                       if (can_move)
-                               cur.undispatched();
+                       cur.undispatched();
                }
 
                break;
@@ -1245,7 +1225,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        if (cur.pos() == cur.paragraph().size())
                                // Par boundary, force full-screen update
                                singleParUpdate = false;
-                       else if (cmd.getArg(0) != "force" && cur.confirmDeletion()) {
+                       else if (cmd.getArg(0) == "confirm" && cur.confirmDeletion()) {
                                cur.resetAnchor();
                                cur.selection(true);
                                cur.posForward();
@@ -1270,7 +1250,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                // Par boundary, full-screen update
                                if (par_boundary)
                                        singleParUpdate = false;
-                               else if (cmd.getArg(0) != "force" && cur.confirmDeletion(true)) {
+                               else if (cmd.getArg(0) == "confirm" && cur.confirmDeletion(true)) {
                                        cur.resetAnchor();
                                        cur.selection(true);
                                        cur.posBackward();
@@ -2531,7 +2511,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                string const lang_arg = cmd.getArg(0);
                bool const reset = (lang_arg.empty() || lang_arg == "reset");
                Language const * lang =
-                       reset ? reset_language
+                       reset ? cur.bv().buffer().params().language
                              : languages.getLanguage(lang_arg);
                // we allow reset_language, which is 0, but only if it
                // was requested via empty or "reset" arg.