]> git.lyx.org Git - features.git/commitdiff
Small BufferView cleanup
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 2 Oct 2015 13:25:09 +0000 (15:25 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 2 Oct 2015 13:25:09 +0000 (15:25 +0200)
Rename fitCursor() to needsFitCursor() to show that it does not do any
action. Constify.

Update a few comments.

src/BufferView.cpp
src/BufferView.h

index 625be3a81298eee6b3122827aeee6f8a761bf13c..0006be45ae2a07aab59e1ab2fbe382f208c0b824 100644 (file)
@@ -412,7 +412,7 @@ Buffer const & BufferView::buffer() const
 }
 
 
-bool BufferView::fitCursor()
+bool BufferView::needsFitCursor() const
 {
        if (cursorStatus(d->cursor_) == CUR_INSIDE) {
                frontend::FontMetrics const & fm =
@@ -443,6 +443,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
        // Now do the first drawing step if needed. This consists on updating
        // the CoordCache in updateMetrics().
        // The second drawing step is done in WorkArea::redraw() if needed.
+       // FIXME: is this still true now that Buffer::changed() is used all over?
 
        // Case when no explicit update is requested.
        if (!flags) {
@@ -460,7 +461,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
        if (flags == Update::FitCursor
                || flags == (Update::Decoration | Update::FitCursor)) {
                // tell the frontend to update the screen if needed.
-               if (fitCursor()) {
+               if (needsFitCursor()) {
                        showCursor();
                        return;
                }
@@ -492,7 +493,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
        // This is done at draw() time. So we need a redraw!
        buffer_.changed(false);
 
-       if (fitCursor()) {
+       if (needsFitCursor()) {
                // The cursor is off screen so ensure it is visible.
                // refresh it:
                showCursor();
@@ -808,7 +809,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, pos_type bottom_pos,
                // paragraph position which is computed at draw() time.
                // So we need a redraw!
                buffer_.changed(false);
-               if (fitCursor())
+               if (needsFitCursor())
                        showCursor();
        }
 
index 6aa2f067778cb41fe3d094a2fcd1c8cf520949e0..91167100ce9e1a143a87486da0f105647951e10a 100644 (file)
@@ -117,9 +117,9 @@ public:
         */
        void processUpdateFlags(Update::flags flags);
 
-       /// move the screen to fit the cursor.
+       /// return true if one shall move the screen to fit the cursor.
        /// Only to be called with good y coordinates (after a bv::metrics)
-       bool fitCursor();
+       bool needsFitCursor() const;
 
        // Returns the amount of horizontal scrolling applied to the
        // top-level row where the cursor lies
@@ -167,11 +167,11 @@ public:
        void recenter();
        /// Ensure that the BufferView cursor is visible.
        /// This method will automatically scroll and update the BufferView
-       /// if needed.
+       /// (metrics+drawing) if needed.
        void showCursor();
        /// Ensure the passed cursor \p dit is visible.
        /// This method will automatically scroll and update the BufferView
-       /// if needed.
+       /// (metrics+drawing) if needed.
        /// \param recenter Whether the cursor should be centered on screen
        void showCursor(DocIterator const & dit, bool recenter,
                bool update);