]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Streamlining CollapseStatus stuff
[lyx.git] / src / BufferView.cpp
index 42fbc2dbe5a009d447c7bb404551edebf1c2944c..5ee6410efc07b7966b239be7dac4aaabb7bf598c 100644 (file)
@@ -63,6 +63,7 @@
 #include "frontends/alert.h"
 #include "frontends/FileDialog.h"
 #include "frontends/FontMetrics.h"
+#include "frontends/Selection.h"
 
 #include "graphics/Previews.h"
 
 #include <functional>
 #include <vector>
 
+using std::distance;
+using std::endl;
+using std::istringstream;
+using std::make_pair;
+using std::min;
+using std::max;
+using std::mem_fun_ref;
+using std::string;
+using std::vector;
+
 
 namespace lyx {
 
@@ -91,16 +102,6 @@ using support::isFileReadable;
 using support::makeDisplayPath;
 using support::package;
 
-using std::distance;
-using std::endl;
-using std::istringstream;
-using std::make_pair;
-using std::min;
-using std::max;
-using std::mem_fun_ref;
-using std::string;
-using std::vector;
-
 namespace Alert = frontend::Alert;
 
 namespace {
@@ -143,7 +144,7 @@ Buffer * BufferView::buffer() const
 }
 
 
-void BufferView::setBuffer(Buffer * b)
+Buffer * BufferView::setBuffer(Buffer * b)
 {
        LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
                            << "[ b = " << b << "]" << endl;
@@ -182,7 +183,7 @@ void BufferView::setBuffer(Buffer * b)
        // If we're quitting lyx, don't bother updating stuff
        if (quitting) {
                buffer_ = 0;
-               return;
+               return 0;
        }
 
        //FIXME Fix for bug 3440 is here.
@@ -209,7 +210,7 @@ void BufferView::setBuffer(Buffer * b)
        offset_ref_ = 0;
 
        if (!buffer_)
-               return;
+               return 0;
 
        LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
                                        << "Buffer addr: " << buffer_ << endl;
@@ -243,6 +244,7 @@ void BufferView::setBuffer(Buffer * b)
 
        if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
                graphics::Previews::get().generateBufferPreviews(*buffer_);
+       return buffer_;
 }
 
 
@@ -1224,6 +1226,9 @@ bool BufferView::workAreaDispatch(FuncRequest const & cmd0)
        if (!cur.result().dispatched())
                cur.dispatch(cmd);
 
+       //Do we have a selection?
+       theSelection().haveSelection(cursor().selection());
+
        // Redraw if requested and necessary.
        if (cur.result().dispatched() && cur.result().update())
                return update(cur.result().update());
@@ -1259,6 +1264,7 @@ void BufferView::setCursorFromRow(int row)
 
        buffer_->texrow().getIdFromRow(row, tmpid, tmppos);
 
+       cursor_.reset(buffer_->inset());
        if (tmpid == -1)
                buffer_->text().setCursor(cursor_, 0, 0);
        else