]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
... and sanitize the simplified code...
[lyx.git] / src / text2.C
index 1e1e0a9e4fa137eed7e80014c561eb2b80365654..f2480b9adb984bc00add5f0562449687c2c655dc 100644 (file)
@@ -280,18 +280,19 @@ void LyXText::setLayout(LCursor & cur, string const & layout)
 {
        BOOST_ASSERT(this == cur.text());
        // special handling of new environment insets
-       BufferParams const & params = bv()->buffer()->params();
+       BufferView & bv = cur.bv();
+       BufferParams const & params = bv.buffer()->params();
        LyXLayout_ptr const & lyxlayout = params.getLyXTextClass()[layout];
        if (lyxlayout->is_environment) {
                // move everything in a new environment inset
                lyxerr << "setting layout " << layout << endl;
-               bv()->owner()->dispatch(FuncRequest(LFUN_HOME));
-               bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL));
-               bv()->owner()->dispatch(FuncRequest(LFUN_CUT));
+               bv.owner()->dispatch(FuncRequest(LFUN_HOME));
+               bv.owner()->dispatch(FuncRequest(LFUN_ENDSEL));
+               bv.owner()->dispatch(FuncRequest(LFUN_CUT));
                InsetBase * inset = new InsetEnvironment(params, layout);
                insertInset(cur, inset);
                //inset->edit(cur, true);
-               //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
+               //bv.owner()->dispatch(FuncRequest(LFUN_PASTE));
                return;
        }
 
@@ -396,7 +397,7 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
 
                // Update current font
                real_current_font.update(font,
-                                        bv()->buffer()->params().language,
+                                        cur.buffer().params().language,
                                         toggleall);
 
                // Reduce to implicit settings
@@ -419,7 +420,7 @@ void LyXText::setFont(LCursor & cur, LyXFont const & font, bool toggleall)
 
        lyxerr << "pos: " << pos << " posend: " << posend << endl;
 
-       BufferParams const & params = bv()->buffer()->params();
+       BufferParams const & params = cur.buffer().params();
 
        // Don't use forwardChar here as posend might have
        // pos() == lastpos() and forwardChar would miss it.
@@ -775,10 +776,8 @@ void LyXText::setCounter(Buffer const & buf, par_type pit)
                        par_type tmppit = pit;
                        InsetBase * in = 0;
                        bool isOK = false;
-                       while (tmppit != end && pars_[tmppit].inInset()
-                              // the single '=' is intended below
-                              && (in = pars_[tmppit].inInset()))
-                       {
+                       while (tmppit != end) {
+                               in = pars_[tmppit].inInset();
                                if (in->lyxCode() == InsetBase::FLOAT_CODE ||
                                    in->lyxCode() == InsetBase::WRAP_CODE) {
                                        isOK = true;
@@ -872,7 +871,7 @@ void LyXText::insertStringAsLines(LCursor & cur, string const & str)
 
        // only to be sure, should not be neccessary
        cur.clearSelection();
-       bv()->buffer()->insertStringAsLines(pars_, pit, pos, current_font, str);
+       cur.buffer().insertStringAsLines(pars_, pit, pos, current_font, str);
 
        redoParagraphs(cur.par(), endpit);
        cur.resetAnchor();
@@ -1001,12 +1000,12 @@ void LyXText::setCurrentFont(LCursor & cur)
                        }
        }
 
-       BufferParams const & bufparams = bv()->buffer()->params();
+       BufferParams const & bufparams = cur.buffer().params();
        current_font = pars_[pit].getFontSettings(bufparams, pos);
        real_current_font = getFont(pit, pos);
 
        if (cur.pos() == cur.lastpos()
-           && bidi.isBoundary(*bv()->buffer(), pars_[pit], cur.pos())
+           && bidi.isBoundary(cur.buffer(), pars_[pit], cur.pos())
            && !cur.boundary()) {
                Language const * lang = pars_[pit].getParLanguage(bufparams);
                current_font.setLanguage(lang);
@@ -1125,7 +1124,7 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
        x -= xo_;
        y -= yo_;
        par_type pit;
-       Row const & row = *getRowNearY(y, pit);
+       Row const & row = getRowNearY(y, pit);
        lyxerr << "setCursorFromCoordinates:: hit row at: " << row.pos() << endl;
        bool bound = false;
        int xx = x + xo_; // getRowNearX get absolute x coords
@@ -1138,7 +1137,7 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
 InsetBase * LyXText::editXY(LCursor & cur, int x, int y)
 {
        par_type pit;
-       Row const & row = *getRowNearY(y - yo_, pit);
+       Row const & row = getRowNearY(y - yo_, pit);
        bool bound = false;
 
        int xx = x; // is modified by getColumnNearX
@@ -1149,6 +1148,7 @@ InsetBase * LyXText::editXY(LCursor & cur, int x, int y)
 
        // try to descend into nested insets
        InsetBase * inset = checkInsetHit(x, y);
+       lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << endl;
        if (!inset)
                return 0;
 
@@ -1185,10 +1185,10 @@ void LyXText::cursorLeft(LCursor & cur)
                setCursor(cur, cur.par(), cur.pos() - 1, true, false);
                if (!checkAndActivateInset(cur, false)) {
                        if (false && !boundary &&
-                                       bidi.isBoundary(*bv()->buffer(), cur.paragraph(), cur.pos() + 1))
+                                       bidi.isBoundary(cur.buffer(), cur.paragraph(), cur.pos() + 1))
                                setCursor(cur, cur.par(), cur.pos() + 1, true, true);
-                       return;
                }
+               return;
        }
 
        if (cur.par() != 0) {
@@ -1208,7 +1208,7 @@ void LyXText::cursorRight(LCursor & cur)
        if (cur.pos() != cur.lastpos()) {
                if (!checkAndActivateInset(cur, true)) {
                        setCursor(cur, cur.par(), cur.pos() + 1, true, false);
-                       if (false && bidi.isBoundary(*bv()->buffer(), cur.paragraph(),
+                       if (false && bidi.isBoundary(cur.buffer(), cur.paragraph(),
                                                         cur.pos()))
                                setCursor(cur, cur.par(), cur.pos(), true, true);
                }
@@ -1342,7 +1342,10 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old)
 #endif
                        // correct all cursor parts
                        fixCursorAfterDelete(cur.top(), old.top());
-                       fixCursorAfterDelete(cur.anchor(), old.top());
+#ifdef WITH_WARNINGS
+#warning DEPM, look here
+#endif
+                       //fixCursorAfterDelete(cur.anchor(), old.top());
                        return false;
                }
        }
@@ -1384,8 +1387,11 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor const & old)
                // such events. Maybe even signal/slot?
                if (cur.par() > old.par())
                        --cur.par();
-               if (cur.anchor().par() > old.par())
-                       --cur.anchor().par();
+#ifdef WITH_WARNINGS
+#warning DEPM, look here
+#endif
+//             if (cur.anchor().par() > old.par())
+//                     --cur.anchor().par();
 
                if (selection_position_was_oldcursor_position) {
                        // correct selection