lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION
<< "[ b = " << b << "]" << endl;
- if (buffer_)
+ if (buffer_) {
disconnectBuffer();
+ // Save the actual cursor position and anchor inside the
+ // buffer so that it can be restored in case we rechange
+ // to this buffer later on.
+ buffer_->saveCursor(cursor_.selectionBegin(),
+ cursor_.selectionEnd());
+ }
// If we are closing current buffer, switch to the first in
// buffer list.
lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION
<< "Buffer addr: " << buffer_ << endl;
connectBuffer(*buffer_);
-
cursor_.push(buffer_->inset());
cursor_.resetAnchor();
buffer_->text().init(bv_);
buffer_->text().setCurrentFont(cursor_);
+ if (buffer_->getCursor().size() > 0 &&
+ buffer_->getAnchor().size() > 0)
+ {
+ cursor_.setCursor(buffer_->getAnchor().asDocIterator(&(buffer_->inset())));
+ cursor_.resetAnchor();
+ cursor_.setCursor(buffer_->getCursor().asDocIterator(&(buffer_->inset())));
+ cursor_.setSelection();
+ }
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
+2005-07-17 Juergen Vigna <jug@lyx.org>
+
+ * BufferView_pimpl.C (setBuffer): save/restore the
+ cursor/selection when switching buffers
+
+ * buffer.h:
+ * buffer.C (saveCursor): add saveDocumentIterators to save the
+ cursor when switching buffer.
+
+
2005-07-17 Michael Schmitt <michqel.schmitt@teststep.org>
* debug.C: fix typo
}
}
}
+
+void Buffer::saveCursor(StableDocIterator cur, StableDocIterator anc)
+{
+ cursor_ = cur;
+ anchor_ = anc;
+}
#include "InsetList.h"
+#include "dociterator.h"
+
#include "support/limited_stack.h"
#include "support/types.h"
class TeXErrors;
class TexRow;
class Undo;
+class StableDocIterator;
/** The buffer object.
/// Set by buffer_funcs' newFile.
void fully_loaded(bool);
- ///
+ /// Our main text (inside the top InsetText)
LyXText & text() const;
- ///
+
+ /// Our top InsetText!
InsetBase & inset() const;
//
MacroData const & getMacro(std::string const & name) const;
///
void insertMacro(std::string const & name, MacroData const & data);
+ ///
+ void saveCursor(StableDocIterator cursor, StableDocIterator anchor);
+ ///
+ StableDocIterator getCursor() const { return cursor_; }
+ ///
+ StableDocIterator getAnchor() const { return anchor_; }
private:
/** Inserts a file into a document
class Impl;
/// The pointer never changes although *pimpl_'s contents may.
boost::scoped_ptr<Impl> const pimpl_;
+
+ /// Save the cursor Position on Buffer switch
+ /// this would not be needed if every Buffer would have
+ /// it's BufferView, this should be FIXED in future.
+ StableDocIterator cursor_;
+ StableDocIterator anchor_;
};
#endif