]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Compile fix.
[lyx.git] / src / BufferView.cpp
index 12f9c4600e6226158f99d759d4688f46cf41a862..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
@@ -1484,7 +1487,9 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                bool const fw = act == LFUN_WORD_FIND_FORWARD;
                docstring const data =
                        find2string(searched_string, true, false, fw);
-               find(this, FuncRequest(LFUN_WORD_FIND, data));
+               bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
+               if (found)
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
        }
 
@@ -1496,8 +1501,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "findreplace"));
                        break;
                }
-               if (find(this, req))
-                       showCursor();
+               if (lyxfind(this, req))
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
                else
                        message(_("String not found!"));
                d->search_request_cache_ = req;
@@ -1511,14 +1516,17 @@ 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;
+                                       }
                                }
                        }
                }
-               replace(this, cmd, has_deleted);
-               dr.forceBufferUpdate();
+               if (lyxreplace(this, cmd, has_deleted)) {
+                       dr.forceBufferUpdate();
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
+               }
                break;
        }
 
@@ -1527,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;
        }
 
@@ -1854,12 +1860,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
                cur.recordUndo();
                FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
-               // FIXME There may be some cases where the inset knows that
-               // single par update would be good enough, but it has no way
-               // to tell us that at the moment.
                inset->dispatch(cur, fr);
-               dr.screenUpdate(Update::Force | Update::FitCursor);
-               dr.forceBufferUpdate();
+               dr.screenUpdate(cur.result().screenUpdate());
+               if (cur.result().needBufferUpdate())
+                       dr.forceBufferUpdate();
                break;
        }
 
@@ -1958,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;
@@ -2341,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);
 }
 
 
@@ -2502,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");
@@ -2890,4 +2895,10 @@ void BufferView::setInlineCompletion(Cursor & cur, DocIterator const & pos,
        }
 }
 
+
+bool BufferView::clickableInset() const
+{ 
+       return d->clickable_inset_; 
+}
+
 } // namespace lyx