]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
GuiBox.cpp: fix this issue: horizontal box alignment is only possible without inner...
[lyx.git] / src / BufferView.cpp
index 0d852f500e11da857257b974340d76f17a946c3c..148e3b447f63eb2c134c6f8152eee0c7b88d3101 100644 (file)
@@ -221,7 +221,7 @@ struct BufferView::Private
                anchor_pit_(0), anchor_ypos_(0),
                inlineCompletionUniqueChars_(0),
                last_inset_(0), mouse_position_cache_(),
-               bookmark_edit_position_(0), gui_(0)
+               bookmark_edit_position_(-1), gui_(0)
        {}
 
        ///
@@ -315,6 +315,9 @@ BufferView::~BufferView()
        fp.pit = d->cursor_.bottom().pit();
        fp.pos = d->cursor_.bottom().pos();
        theSession().lastFilePos().save(buffer_.fileName(), fp);
+       
+       if (d->last_inset_)
+               d->last_inset_->setMouseHover(this, false);     
 
        delete d;
 }
@@ -565,7 +568,7 @@ docstring BufferView::contextMenu(int x, int y) const
 }
 
 
-void BufferView::scrollDocView(int value)
+void BufferView::scrollDocView(int value, bool update)
 {
        int const offset = value - d->scrollbarParameters_.position;
 
@@ -584,7 +587,7 @@ void BufferView::scrollDocView(int value)
        // cut off at the top
        if (value <= d->scrollbarParameters_.min) {
                DocIterator dit = doc_iterator_begin(&buffer_);
-               showCursor(dit);
+               showCursor(dit, false, update);
                LYXERR(Debug::SCROLLING, "scroll to top");
                return;
        }
@@ -593,7 +596,7 @@ void BufferView::scrollDocView(int value)
        if (value >= d->scrollbarParameters_.max) {
                DocIterator dit = doc_iterator_end(&buffer_);
                dit.backwardPos();
-               showCursor(dit);
+               showCursor(dit, false, update);
                LYXERR(Debug::SCROLLING, "scroll to bottom");
                return;
        }
@@ -611,14 +614,14 @@ void BufferView::scrollDocView(int value)
                // It seems we didn't find the correct pit so stay on the safe side and
                // scroll to bottom.
                LYXERR0("scrolling position not found!");
-               scrollDocView(d->scrollbarParameters_.max);
+               scrollDocView(d->scrollbarParameters_.max, update);
                return;
        }
 
        DocIterator dit = doc_iterator_begin(&buffer_);
        dit.pit() = i;
        LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
-       showCursor(dit);
+       showCursor(dit, false, update);
 }
 
 
@@ -803,19 +806,20 @@ int BufferView::workWidth() const
 
 void BufferView::recenter()
 {
-       showCursor(d->cursor_, true);
+       showCursor(d->cursor_, true, true);
 }
 
 
 void BufferView::showCursor()
 {
-       showCursor(d->cursor_, false);
+       showCursor(d->cursor_, false, true);
 }
 
 
-void BufferView::showCursor(DocIterator const & dit, bool recenter)
+void BufferView::showCursor(DocIterator const & dit,
+       bool recenter, bool update)
 {
-       if (scrollToCursor(dit, recenter)) {
+       if (scrollToCursor(dit, recenter) && update) {
                buffer_.changed(true);
                updateHoveredInset();
        }
@@ -1075,7 +1079,12 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                flag.setOnOff(buffer_.params().compressed);
                break;
        }
-       
+
+       case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC: {
+               flag.setOnOff(buffer_.params().output_sync);
+               break;
+       }
+
        case LFUN_SCREEN_UP:
        case LFUN_SCREEN_DOWN:
        case LFUN_SCROLL:
@@ -1585,6 +1594,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                buffer_.params().compressed = !buffer_.params().compressed;
                break;
 
+       case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
+               buffer_.params().output_sync = !buffer_.params().output_sync;
+               break;
+
        case LFUN_SCREEN_UP:
        case LFUN_SCREEN_DOWN: {
                Point p = getPos(cur);
@@ -1718,7 +1731,14 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        Alert::warning(_("Branch already exists"), drtmp.message());
                        break;
                }
-               lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
+               BranchList & branch_list = buffer_.params().branchlist();
+               vector<docstring> const branches =
+                       getVectorFromString(branch_name, branch_list.separator());
+               for (vector<docstring>::const_iterator it = branches.begin();
+                    it != branches.end(); ++it) {
+                       branch_name = *it;
+                       lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
+               }
                break;
        }
 
@@ -1895,18 +1915,22 @@ void BufferView::updateHoveredInset() const
                return;
 
        bool need_redraw = false;
-       if (d->last_inset_)
+       if (d->last_inset_) {
                // Remove the hint on the last hovered inset (if any).
                need_redraw |= d->last_inset_->setMouseHover(this, false);
+               d->last_inset_ = 0;
+       }
        
        // const_cast because of setMouseHover().
        Inset * inset = const_cast<Inset *>(covering_inset);
-       if (inset)
-               // Highlight the newly hovered inset (if any).
-               need_redraw |= inset->setMouseHover(this, true);
+       if (inset && inset->setMouseHover(this, true)) {
+               need_redraw = true;
+               // Only the insets that accept the hover state, do 
+               // clear the last_inset_, so only set the last_inset_
+               // member if the hovered setting is accepted.
+               d->last_inset_ = inset;
+       }
 
-       d->last_inset_ = inset;
-       
        if (need_redraw) {
                LYXERR(Debug::PAINTING, "Mouse hover detected at: ("
                                << d->mouse_position_cache_.x_ << ", "