]> git.lyx.org Git - features.git/blobdiff - src/BufferView.cpp
move updateLables to buffer
[features.git] / src / BufferView.cpp
index 314631cadd0ec344868a6bee54ab2156f19879e8..b463778ef31567e31ec08a0b7a50da8be749f9be 100644 (file)
@@ -4,10 +4,10 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Alfredo Braunstein
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author John Levon
- * \author André Pönitz
- * \author Jürgen Vigna
+ * \author André Pönitz
+ * \author Jürgen Vigna
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -549,9 +549,14 @@ docstring BufferView::contextMenu(int x, int y) const
 void BufferView::scrollDocView(int value)
 {
        int const offset = value - d->scrollbarParameters_.position;
+
+       // No scrolling at all? No need to redraw anything
+       if (offset == 0)
+               return;
+
        // If the offset is less than 2 screen height, prefer to scroll instead.
        if (abs(offset) <= 2 * height_) {
-               scroll(offset);
+               d->anchor_ypos_ -= offset;
                updateMetrics();
                buffer_.changed();
                return;
@@ -627,7 +632,14 @@ void BufferView::setCursorFromScrollbar()
        Cursor cur(*this);
        cur.reset(buffer_.inset());
        tm.setCursorFromCoordinates(cur, 0, newy);
+
+       // update the bufferview cursor and notify insets
+       // FIXME: Care about the d->cursor_ flags to redraw if needed
+       Cursor old = d->cursor_;
        mouseSetCursor(cur);
+       bool badcursor = notifyCursorLeavesOrEnters(old, d->cursor_);
+       if (badcursor)
+               d->cursor_.fixIfBroken();
 }
 
 
@@ -866,6 +878,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
        case LFUN_NOTE_NEXT:
        case LFUN_REFERENCE_NEXT:
        case LFUN_WORD_FIND:
+       case LFUN_WORD_FINDADV:
        case LFUN_WORD_REPLACE:
        case LFUN_MARK_OFF:
        case LFUN_MARK_ON:
@@ -879,6 +892,11 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
                flag.setEnabled(true);
                break;
 
+       // @todo Test if current WorkArea is the search WorkArea
+       case LFUN_REGEXP_MODE:
+               flag.setEnabled(! this->cursor().inRegexped());
+               break;
+
        case LFUN_NEXT_INSET_TOGGLE: 
        case LFUN_NEXT_INSET_MODIFY: {
                // this is the real function we want to invoke
@@ -1220,6 +1238,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
        }
 
+       case LFUN_WORD_FINDADV:
+               findAdv(this, cmd);
+               break;
+
        case LFUN_MARK_OFF:
                cur.clearSelection();
                cur.resetAnchor();
@@ -1635,7 +1657,7 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
        // Notify left insets
        if (cur != old) {
                old.fixIfBroken();
-               bool badcursor = notifyCursorLeaves(old, cur);
+               bool badcursor = notifyCursorLeavesOrEnters(old, cur);
                if (badcursor)
                        cursor().fixIfBroken();
        }
@@ -1836,7 +1858,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
 
        d->cursor_ = cur;
 
-       updateLabels(buffer_);
+       buffer_.updateLabels();
 
        updateMetrics();
        buffer_.changed();
@@ -1854,14 +1876,9 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
                cap::saveSelection(cursor());
 
        // Has the cursor just left the inset?
-       bool badcursor = false;
        bool leftinset = (&d->cursor_.inset() != &cur.inset());
-       if (leftinset) {
+       if (leftinset)
                d->cursor_.fixIfBroken();
-               badcursor = notifyCursorLeaves(d->cursor_, cur);
-               if (badcursor)
-                       cur.fixIfBroken();
-       }
 
        // FIXME: shift-mouse selection doesn't work well across insets.
        bool do_selection = select && &d->cursor_.anchor().inset() == &cur.inset();
@@ -1871,7 +1888,7 @@ bool BufferView::mouseSetCursor(Cursor & cur, bool select)
        // FIXME: (2) if we had a working InsetText::notifyCursorLeaves,
        // the leftinset bool would not be necessary (badcursor instead).
        bool update = leftinset;
-       if (!do_selection && !badcursor && d->cursor_.inTexted())
+       if (!do_selection && d->cursor_.inTexted())
                update |= checkDepm(cur, d->cursor_);
 
        d->cursor_.setCursor(cur);
@@ -2190,6 +2207,7 @@ void BufferView::draw(frontend::Painter & pain)
        if (height_ == 0 || width_ == 0)
                return;
        LYXERR(Debug::PAINTING, "\t\t*** START DRAWING ***");
+
        Text & text = buffer_.text();
        TextMetrics const & tm = d->text_metrics_[&text];
        int const y = tm.first().second->position();