]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Some more cleanup of LyXView:
[lyx.git] / src / Text3.cpp
index f6e4e4a923d6fcff819215d780226de33a26bd20..f400794e985a21345107f10e813f1d89638bb896 100644 (file)
@@ -388,7 +388,7 @@ bool Text::isRTL(Buffer const & buffer, Paragraph const & par) const
 
 void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 {
-       LYXERR(Debug::ACTION) << "Text::dispatch: cmd: " << cmd << endl;
+       LYXERR(Debug::ACTION, "Text::dispatch: cmd: " << cmd);
 
        // FIXME: We use the update flag to indicates wether a singlePar or a
        // full screen update is needed. We reset it here but shall we restore it
@@ -955,7 +955,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_LAYOUT: {
                docstring layout = cmd.argument();
-               LYXERR(Debug::INFO) << "LFUN_LAYOUT: (arg) " << to_utf8(layout) << endl;
+               LYXERR(Debug::INFO, "LFUN_LAYOUT: (arg) " << to_utf8(layout));
 
                docstring const old_layout = cur.paragraph().layout()->name();
 
@@ -1137,37 +1137,40 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
                // ignore motions deeper nested than the real anchor
                Cursor & bvcur = cur.bv().cursor();
-               if (bvcur.anchor_.hasPart(cur)) {
-                       CursorSlice old = bvcur.top();
-
-                       int const wh = bv->workHeight();
-                       int const y = std::max(0, std::min(wh - 1, cmd.y));
-
-                       tm.setCursorFromCoordinates(cur, cmd.x, y);
-                       cur.setTargetX(cmd.x);
+               if (!bvcur.anchor_.hasPart(cur)) {
+                       cur.undispatched();
+                       break;
+               }
+               CursorSlice old = bvcur.top();
+
+               int const wh = bv->workHeight();
+               int const y = std::max(0, std::min(wh - 1, cmd.y));
+
+               tm.setCursorFromCoordinates(cur, cmd.x, y);
+               cur.setTargetX(cmd.x);
+               if (cmd.y >= wh)
+                       lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT));
+               else if (cmd.y < 0)
+                       lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
+               // This is to allow jumping over large insets
+               if (cur.top() == old) {
                        if (cmd.y >= wh)
                                lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT));
                        else if (cmd.y < 0)
                                lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
-                       // This is to allow jumping over large insets
-                       if (cur.top() == old) {
-                               if (cmd.y >= wh)
-                                       lyx::dispatch(FuncRequest(LFUN_DOWN_SELECT));
-                               else if (cmd.y < 0)
-                                       lyx::dispatch(FuncRequest(LFUN_UP_SELECT));
-                       }
-
-                       if (cur.top() == old)
-                               cur.noUpdate();
-                       else {
-                               // don't set anchor_
-                               bvcur.setCursor(cur);
-                               bvcur.selection() = true;
-                               //lyxerr << "MOTION: " << bv->cursor() << endl;
-                       }
+               }
 
-               } else
-                       cur.undispatched();
+               if (cur.top() == old)
+                       cur.noUpdate();
+               else {
+                       // FIXME: This is brute force! But without it the selected
+                       // area is not corrected updated while moving the mouse.
+                       cur.updateFlags(Update::Force | Update::FitCursor);
+                       // don't set anchor_
+                       bvcur.setCursor(cur);
+                       bvcur.selection() = true;
+                       //lyxerr << "MOTION: " << bv->cursor() << endl;
+               }
                break;
        }
 
@@ -1203,17 +1206,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // "auto_region_delete", which defaults to
                // true (on).
 
-               if (lyxrc.auto_region_delete && cur.selection()) {
-                       pit_type const begpit = cur.selBegin().pit();
-                       pit_type const endpit = cur.selEnd().pit();
+               if (lyxrc.auto_region_delete && cur.selection())
                        cutSelection(cur, false, false);
-                       // When a selection spans multiple paragraphs, the metrics update
-                       // mechanism sometimes fail to detect that a full update is needed.
-                       // In this case, we force the full update:
-                       // (see http://bugzilla.lyx.org/show_bug.cgi?id=4317)
-                       if (isMainText(cur.bv().buffer()) && begpit != endpit)
-                               cur.updateFlags(Update::Force);
-               }
 
                cur.clearSelection();
                Font const old_font = cur.real_current_font;
@@ -1239,7 +1233,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        content : cmd.argument();
                string const data = InsetCommandMailer::params2string("href", p);
                if (p["target"].empty()) {
-                       bv->showInsetDialog("href", data, 0);
+                       bv->showDialog("href", data);
                } else {
                        FuncRequest fr(LFUN_INSET_INSERT, data);
                        dispatch(cur, fr);
@@ -1256,7 +1250,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                string const data = InsetCommandMailer::params2string("label", p);
 
                if (cmd.argument().empty()) {
-                       bv->showInsetDialog("label", data, 0);
+                       bv->showDialog("label", data);
                } else {
                        FuncRequest fr(LFUN_INSET_INSERT, data);
                        dispatch(cur, fr);
@@ -1551,7 +1545,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_FINISHED_LEFT:
-               LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
+               LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_LEFT:\n" << cur);
                if (reverseDirectionNeeded(cur)) {
                        ++cur.pos();
                        cur.setCurrentFont();
@@ -1559,7 +1553,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_FINISHED_RIGHT:
-               LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
+               LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_RIGHT:\n" << cur);
                if (!reverseDirectionNeeded(cur)) {
                        ++cur.pos();
                        cur.setCurrentFont();
@@ -1567,11 +1561,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_FINISHED_BACKWARD:
-               LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_BACKWARD:\n" << cur << endl;
+               LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_BACKWARD:\n" << cur);
                break;
 
        case LFUN_FINISHED_FORWARD:
-               LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_FORWARD:\n" << cur << endl;
+               LYXERR(Debug::DEBUG, "handle LFUN_FINISHED_FORWARD:\n" << cur);
                ++cur.pos();
                cur.setCurrentFont();
                break;
@@ -1580,7 +1574,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                string data;
                params2string(cur.paragraph(), data);
                data = "show\n" + data;
-               bv->showDialogWithData("paragraph", data);
+               bv->showDialog("paragraph", data);
                break;
        }
 
@@ -1665,7 +1659,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                arg = cur.selectionAsString(false);
                        }
                }
-               bv->showDialogWithData("thesaurus", to_utf8(arg));
+               bv->showDialog("thesaurus", to_utf8(arg));
                break;
        }
 
@@ -1729,10 +1723,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        default:
-               LYXERR(Debug::ACTION)
-                       << BOOST_CURRENT_FUNCTION
-                       << ": Command " << cmd
-                       << " not DISPATCHED by Text" << endl;
+               LYXERR(Debug::ACTION, BOOST_CURRENT_FUNCTION
+                       << ": Command " << cmd << " not DISPATCHED by Text");
                cur.undispatched();
                break;
        }
@@ -1755,14 +1747,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // Inserting characters does not change par height
                ParagraphMetrics const & pms
                        = cur.bv().parMetrics(cur.bottom().text(), cur.bottom().pit());
-               if (pms.dim().height()
-                   == olddim.height()) {
+               if (pms.dim().height() == olddim.height()) {
                        // if so, update _only_ this paragraph
                        cur.updateFlags(Update::SinglePar |
                                Update::FitCursor);
                        return;
-               } else
-                       needsUpdate = true;
+               }
+               needsUpdate = true;
        }
 
        if (!needsUpdate