Small BufferView cleanup

Rename fitCursor() to needsFitCursor() to show that it does not do any
action. Constify.

Update a few comments.
This commit is contained in:
Jean-Marc Lasgouttes 2015-10-02 15:25:09 +02:00
parent 24ae209358
commit ca3e4e1494
2 changed files with 9 additions and 8 deletions

View 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();
}

View 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);