]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
* remove various xforms relicts, in particular:
[lyx.git] / src / BufferView.C
index 8a74a8d42fc15f071bd52ee6b70e03e051694d33..f1c1834b1c24523ccbe437d3d69c161b1e5c78b2 100644 (file)
@@ -21,6 +21,7 @@
 #include "bufferparams.h"
 #include "BufferView_pimpl.h"
 #include "CutAndPaste.h"
+#include "coordcache.h"
 #include "debug.h"
 #include "funcrequest.h"
 #include "FuncStatus.h"
 #include "texrow.h"
 #include "undo.h"
 #include "WordLangTuple.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
+#include "frontends/Clipboard.h"
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
-#include "frontends/screen.h"
-#include "frontends/WorkArea.h"
+#include "frontends/Gui.h"
 
 #include "insets/insetcommand.h" // ChangeRefs
-#include "insets/updatableinset.h"
 #include "insets/insettext.h"
 
+
 using lyx::support::bformat;
 
 using lyx::cap::setSelectionRange;
@@ -54,15 +56,14 @@ using lyx::cap::setSelectionRange;
 using std::distance;
 using std::find;
 using std::string;
-using std::swap;
 using std::vector;
 
 
 extern BufferList bufferlist;
 
 
-BufferView::BufferView(LyXView * owner, int width, int height)
-       : pimpl_(new Pimpl(*this, owner, width, height))
+BufferView::BufferView(LyXView * owner)
+       : pimpl_(new Pimpl(*this, owner))
 {}
 
 
@@ -84,24 +85,12 @@ Buffer * BufferView::buffer() const
 }
 
 
-LyXScreen & BufferView::screen() const
-{
-       return pimpl_->screen();
-}
-
-
 LyXView * BufferView::owner() const
 {
        return pimpl_->owner_;
 }
 
 
-Painter & BufferView::painter() const
-{
-       return pimpl_->painter();
-}
-
-
 void BufferView::setBuffer(Buffer * b)
 {
        pimpl_->setBuffer(b);
@@ -141,9 +130,9 @@ bool BufferView::fitCursor()
 }
 
 
-void BufferView::update()
+void BufferView::update(Update::flags flags)
 {
-       pimpl_->update();
+       pimpl_->update(flags);
 }
 
 
@@ -153,15 +142,15 @@ void BufferView::updateScrollbar()
 }
 
 
-void BufferView::scrollDocView(int value)
+ScrollbarParameters const & BufferView::scrollbarParameters() const
 {
-       pimpl_->scrollDocView(value);
+       return pimpl_->scrollbarParameters();
 }
 
 
-void BufferView::redoCurrentBuffer()
+void BufferView::scrollDocView(int value)
 {
-       pimpl_->redoCurrentBuffer();
+       pimpl_->scrollDocView(value);
 }
 
 
@@ -194,6 +183,10 @@ bool BufferView::isSavedPosition(unsigned int i)
        return pimpl_->isSavedPosition(i);
 }
 
+void BufferView::saveSavedPositions()
+{
+       return pimpl_->saveSavedPositions();
+}
 
 void BufferView::switchKeyMap()
 {
@@ -203,7 +196,7 @@ void BufferView::switchKeyMap()
 
 int BufferView::workWidth() const
 {
-       return pimpl_->workarea().workWidth();
+       return pimpl_->width();
 }
 
 
@@ -213,39 +206,45 @@ void BufferView::center()
 }
 
 
-int BufferView::top_y() const
+FuncStatus BufferView::getStatus(FuncRequest const & cmd)
 {
-       return pimpl_->top_y();
+       return pimpl_->getStatus(cmd);
 }
 
 
-void BufferView::top_y(int y)
+bool BufferView::dispatch(FuncRequest const & ev)
 {
-       pimpl_->top_y(y);
+       return pimpl_->dispatch(ev);
 }
 
 
-string const BufferView::getClipboard() const
+void BufferView::selectionRequested()
 {
-       return pimpl_->workarea().getClipboard();
+       pimpl_->selectionRequested();
 }
 
 
-void BufferView::stuffClipboard(string const & stuff) const
+void BufferView::selectionLost()
 {
-       pimpl_->stuffClipboard(stuff);
+       pimpl_->selectionLost();
 }
 
 
-FuncStatus BufferView::getStatus(FuncRequest const & cmd)
+void BufferView::workAreaResize(int width, int height)
 {
-       return pimpl_->getStatus(cmd);
+       pimpl_->workAreaResize(width, height);
 }
 
 
-bool BufferView::dispatch(FuncRequest const & ev)
+void BufferView::workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state)
 {
-       return pimpl_->dispatch(ev);
+       pimpl_->workAreaKeyPress(key, state);
+}
+
+
+bool BufferView::workAreaDispatch(FuncRequest const & ev)
+{
+       return pimpl_->workAreaDispatch(ev);
 }
 
 
@@ -258,7 +257,7 @@ void BufferView::scroll(int lines)
 void BufferView::showErrorList(string const & action) const
 {
        if (getErrorList().size()) {
-               string const title = bformat(_("LyX: %1$s errors (%2$s)"),
+               string const title = bformat(_("%1$s Errors (%2$s)"),
                        action, buffer()->fileName());
                owner()->getDialogs().show("errorlist", title);
                pimpl_->errorlist_.clear();
@@ -292,9 +291,7 @@ void BufferView::gotoLabel(string const & label)
                vector<string> labels;
                it->getLabelList(*buffer(), labels);
                if (find(labels.begin(),labels.end(),label) != labels.end()) {
-                       cursor().clearSelection();
-                       text()->setCursor(cursor(), it.pit(), it.pos());
-                       cursor().resetAnchor();
+                       setCursor(it);
                        update();
                        return;
                }
@@ -304,11 +301,10 @@ void BufferView::gotoLabel(string const & label)
 
 void BufferView::hideCursor()
 {
-       screen().hideCursor();
+       pimpl_->gui().guiCursor().hide();
 }
 
-
-LyXText * BufferView::getLyXText() const
+LyXText * BufferView::getLyXText()
 {
        LyXText * text = cursor().innerText();
        BOOST_ASSERT(text);
@@ -316,15 +312,17 @@ LyXText * BufferView::getLyXText() const
 }
 
 
-void BufferView::haveSelection(bool sel)
+LyXText const * BufferView::getLyXText() const
 {
-       pimpl_->workarea().haveSelection(sel);
+       LyXText const * text = cursor().innerText();
+       BOOST_ASSERT(text);
+       return text;
 }
 
 
 int BufferView::workHeight() const
 {
-       return pimpl_->workarea().workHeight();
+       return pimpl_->height();
 }
 
 
@@ -334,26 +332,43 @@ LyXText * BufferView::text() const
 }
 
 
-void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
+void BufferView::setCursor(DocIterator const & dit)
 {
-       int const last = par.size();
-       for (int i = 0; i < last; ++i)
-               par[i].inset().edit(cursor(), true);
+       size_t const n = dit.depth();
+       for (size_t i = 0; i < n; ++i)
+               dit[i].inset().edit(cursor(), true);
 
-       cursor().setCursor(makeDocIterator(par, pos));
+       cursor().setCursor(dit);
        cursor().selection() = false;
-       par.bottom().text()->redoParagraph(par.bottom().pit());
+}
+
+
+void BufferView::mouseSetCursor(LCursor & cur)
+{
+       BOOST_ASSERT(&cur.bv() == this);
+
+       // Has the cursor just left the inset?
+       if (&cursor().inset() != &cur.inset())
+               cursor().inset().notifyCursorLeaves(cursor());
+
+       // do the dEPM magic if needed
+       if (cursor().inTexted())
+               cursor().text()->deleteEmptyParagraphMechanism(cur, cursor());
+
+       cursor() = cur;
+       cursor().clearSelection();
+       cursor().setTargetX();
+       finishUndo();
+
 }
 
 
 void BufferView::putSelectionAt(DocIterator const & cur,
                                int length, bool backwards)
 {
-       ParIterator par(cur);
-
        cursor().clearSelection();
 
-       setCursor(par, cur.pos());
+       setCursor(cur);
 
        if (length) {
                if (backwards) {
@@ -375,3 +390,21 @@ LCursor const & BufferView::cursor() const
 {
        return pimpl_->cursor_;
 }
+
+
+lyx::pit_type BufferView::anchor_ref() const
+{
+       return pimpl_->anchor_ref_;
+}
+
+
+int BufferView::offset_ref() const
+{
+       return pimpl_->offset_ref_;
+}
+
+
+ViewMetricsInfo const & BufferView::viewMetricsInfo()
+{
+       return pimpl_->viewMetricsInfo();
+}