]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / Cursor.cpp
index 7147f8152a0b1b358bdd62109ea417935003189e..111434b6c89bbf17559f9c54e65a820ff00803c8 100644 (file)
@@ -206,7 +206,7 @@ namespace {
                //      << " xlow: " << xlow << " xhigh: " << xhigh
                //      << " ylow: " << ylow << " yhigh: " << yhigh
                //      << endl;
-               Inset & inset = bv.buffer()->inset();
+               Inset & inset = bv.buffer().inset();
                DocIterator it = doc_iterator_begin(inset);
                it.pit() = from;
                DocIterator et = doc_iterator_end(inset);
@@ -351,8 +351,7 @@ BufferView & Cursor::bv() const
 Buffer & Cursor::buffer() const
 {
        BOOST_ASSERT(bv_);
-       BOOST_ASSERT(bv_->buffer());
-       return *bv_->buffer();
+       return bv_->buffer();
 }
 
 
@@ -1077,7 +1076,7 @@ bool Cursor::upDownInMath(bool up)
                
                // We want to keep the x-target on subsequent up/down movements
                // that cross beyond the end of short lines. Thus a special
-               // handling when the cursor is at the end of line: Use the new 
+               // handling when the cursor is at the end of line: Use the new
                // x-target only if the old one was before the end of line
                // or the old one was after the beginning of the line
                bool inRTL = isWithinRtlParagraph(*this);
@@ -1091,12 +1090,12 @@ bool Cursor::upDownInMath(bool up)
                        right = pos() == textRow().endpos();
                }
                if ((!left && !right) ||
-                               (left && !right && xo < x_target_) || 
+                               (left && !right && xo < x_target_) ||
                                (!left && right && x_target_ < xo))
                        setTargetX(xo);
                else
                        xo = targetX();
-       } else 
+       } else
                xo = targetX();
 
        // try neigbouring script insets
@@ -1169,7 +1168,7 @@ bool Cursor::upDownInMath(bool up)
 }
 
 
-bool Cursor::upDownInText(bool up, bool & updateNeeded) 
+bool Cursor::upDownInText(bool up, bool & updateNeeded)
 {
        BOOST_ASSERT(text());
 
@@ -1184,14 +1183,14 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
        // if we cannot move up/down inside this inset anymore
        if (x_target_ == -1)
                setTargetX(xo);
-       else if (xo - textTargetOffset() != x_target() && 
+       else if (xo - textTargetOffset() != x_target() &&
                                         depth() == beforeDispatchCursor_.depth()) {
                // In text mode inside the line (not left or right) possibly set a new target_x,
                // but only if we are somewhere else than the previous target-offset.
                
                // We want to keep the x-target on subsequent up/down movements
                // that cross beyond the end of short lines. Thus a special
-               // handling when the cursor is at the end of line: Use the new 
+               // handling when the cursor is at the end of line: Use the new
                // x-target only if the old one was before the end of line
                // or the old one was after the beginning of the line
                bool inRTL = isWithinRtlParagraph(*this);
@@ -1205,12 +1204,12 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        right = pos() == textRow().endpos();
                }
                if ((!left && !right) ||
-                               (left && !right && xo < x_target_) || 
+                               (left && !right && xo < x_target_) ||
                                (!left && right && x_target_ < xo))
                        setTargetX(xo);
                else
                        xo = targetX();
-       } else 
+       } else
                xo = targetX();
                
        // first get the current line
@@ -1227,7 +1226,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                if (pit() == 0 && row == 0)
                        return false;
        } else {
-               if (pit() + 1 >= int(text()->paragraphs().size()) && 
+               if (pit() + 1 >= int(text()->paragraphs().size()) &&
                                row + 1 >= int(pm.rows().size()))
                        return false;
        }       
@@ -1336,7 +1335,7 @@ docstring Cursor::selectionAsString(bool label) const
                return docstring();
 
        if (inTexted()) {
-               Buffer const & buffer = *bv().buffer();
+               Buffer const & buffer = bv().buffer();
                ParagraphList const & pars = text()->paragraphs();
 
                // should be const ...
@@ -1398,8 +1397,6 @@ Encoding const * Cursor::getEncoding() const
 {
        if (empty())
                return 0;
-       if (!bv().buffer())
-               return 0;
        int s = 0;
        // go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
@@ -1409,7 +1406,7 @@ Encoding const * Cursor::getEncoding() const
        CursorSlice const & sl = operator[](s);
        Text const & text = *sl.text();
        Font font = text.getPar(sl.pit()).getFont(
-               bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
+               bv().buffer().params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
        return font.language()->encoding();
 }
 
@@ -1463,25 +1460,27 @@ Font Cursor::getFont() const
        // on space? Take the font before (only for RTL boundary stay)
        if (pos > 0) {
                if (pos == sl.lastpos()
-                               || (par.isSeparator(pos) && 
+                               || (par.isSeparator(pos) &&
                                                !text.isRTLBoundary(buffer(), par, pos)))
                        --pos;
        }
        
        // get font at the position
-       Font font = par.getFont(bv().buffer()->params(), pos,
+       Font font = par.getFont(bv().buffer().params(), pos,
                outerFont(sl.pit(), text.paragraphs()));
 
        return font;
 }
 
 
-void Cursor::fixIfBroken()
+bool Cursor::fixIfBroken()
 {
        if (DocIterator::fixIfBroken()) {
                        clearSelection();
                        resetAnchor();
+                       return true;
        }
+       return false;
 }