]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Buffer: Rename function names:
[lyx.git] / src / BufferView.cpp
index e7efc64c6f85eb8a7fa2a9c945afb49cf2704663..338a55aa5c3f9a1ce7e7fdeba159fec447ab9e83 100644 (file)
@@ -58,9 +58,9 @@
 #include "insets/InsetCommand.h" // ChangeRefs
 #include "insets/InsetExternal.h"
 #include "insets/InsetGraphics.h"
+#include "insets/InsetNote.h"
 #include "insets/InsetRef.h"
 #include "insets/InsetText.h"
-#include "insets/InsetNote.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -220,7 +220,8 @@ struct BufferView::Private
        Private(BufferView & bv): wh_(0), cursor_(bv),
                anchor_pit_(0), anchor_ypos_(0),
                inlineCompletionUniqueChars_(0),
-               last_inset_(0), mouse_position_cache_(),
+               last_inset_(0), clickable_inset_(false), 
+               mouse_position_cache_(),
                bookmark_edit_position_(-1), gui_(0)
        {}
 
@@ -263,6 +264,8 @@ struct BufferView::Private
          * Not owned, so don't delete.
          */
        Inset * last_inset_;
+       /// are we hovering something that we can click
+       bool clickable_inset_;
 
        /// position of the mouse at the time of the last mouse move
        /// This is used to update the hovering status of inset in
@@ -1513,9 +1516,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        DocIterator end = cur.selectionEnd();
                        if (beg.pit() == end.pit()) {
                                for (pos_type p = beg.pos() ; p < end.pos() ; ++p) {
-                                       if (!cur.inMathed()
-                                           && cur.paragraph().isDeleted(p))
+                                       if (!cur.inMathed() && cur.paragraph().isDeleted(p)) {
                                                has_deleted = true;
+                                               break;
+                                       }
                                }
                        }
                }
@@ -1531,9 +1535,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                istringstream iss(to_utf8(cmd.argument()));
                iss >> opt;
                if (findAdv(this, opt))
-                       cur.dispatched();
-               else
-                       cur.undispatched();
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
        }
 
@@ -1960,8 +1962,12 @@ Inset const * BufferView::getCoveringInset(Text const & text,
 void BufferView::updateHoveredInset() const
 {
        // Get inset under mouse, if there is one.
-       Inset const * covering_inset = getCoveringInset(buffer_.text(),
-                       d->mouse_position_cache_.x_, d->mouse_position_cache_.y_);
+       int const x = d->mouse_position_cache_.x_;
+       int const y = d->mouse_position_cache_.y_;
+       Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
+
+       d->clickable_inset_ = covering_inset && covering_inset->clickable(x, y);
+
        if (covering_inset == d->last_inset_)
                // Same inset, no need to do anything...
                return;
@@ -2343,9 +2349,6 @@ void BufferView::putSelectionAt(DocIterator const & cur,
                } else
                        d->cursor_.setSelection(d->cursor_, length);
        }
-       // Ensure a redraw happens in any case because the new selection could 
-       // possibly be on the same screen as the previous selection.
-       processUpdateFlags(Update::Force | Update::FitCursor);
 }
 
 
@@ -2504,7 +2507,7 @@ void BufferView::insertLyXFile(FileName const & fname)
 
        docstring res;
        Buffer buf("", false);
-       if (buf.loadLyXFile(filename)) {
+       if (buf.loadLyXFile(filename) == Buffer::ReadSuccess) {
                ErrorList & el = buffer_.errorList("Parse");
                // Copy the inserted document error list into the current buffer one.
                el = buf.errorList("Parse");
@@ -2892,4 +2895,10 @@ void BufferView::setInlineCompletion(Cursor & cur, DocIterator const & pos,
        }
 }
 
+
+bool BufferView::clickableInset() const
+{ 
+       return d->clickable_inset_; 
+}
+
 } // namespace lyx