]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
minimal effort implementation of:
[lyx.git] / src / BufferView.C
index 5009b2961d6d336541f9a8c1bbfd65498368432c..6c8f4bce793a55d69841219884feb0b52f52100a 100644 (file)
@@ -20,7 +20,6 @@
 #include "bufferlist.h"
 #include "bufferparams.h"
 #include "BufferView_pimpl.h"
-#include "CutAndPaste.h"
 #include "coordcache.h"
 #include "debug.h"
 #include "funcrequest.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 "insets/insetcommand.h" // ChangeRefs
-#include "insets/updatableinset.h"
 #include "insets/insettext.h"
 
-using lyx::support::bformat;
 
-using lyx::cap::setSelectionRange;
+using lyx::support::bformat;
 
 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))
 {}
 
 
@@ -85,36 +81,18 @@ 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);
 }
 
 
-void BufferView::newFile(string const & fn, string const & tn, bool named)
-{
-       pimpl_->newFile(fn, tn, named);
-}
-
-
 bool BufferView::loadLyXFile(string const & fn, bool tl)
 {
        return pimpl_->loadLyXFile(fn, tl);
@@ -142,9 +120,9 @@ bool BufferView::fitCursor()
 }
 
 
-void BufferView::update(Update::flags flags)
+bool BufferView::update(Update::flags flags)
 {
-       pimpl_->update(flags);
+       return pimpl_->update(flags);
 }
 
 
@@ -154,12 +132,24 @@ void BufferView::updateScrollbar()
 }
 
 
+ScrollbarParameters const & BufferView::scrollbarParameters() const
+{
+       return pimpl_->scrollbarParameters();
+}
+
+
 void BufferView::scrollDocView(int value)
 {
        pimpl_->scrollDocView(value);
 }
 
 
+void BufferView::setCursorFromScrollbar()
+{
+       pimpl_->setCursorFromScrollbar();
+}
+
+
 bool BufferView::available() const
 {
        return pimpl_->available();
@@ -189,6 +179,10 @@ bool BufferView::isSavedPosition(unsigned int i)
        return pimpl_->isSavedPosition(i);
 }
 
+void BufferView::saveSavedPositions()
+{
+       return pimpl_->saveSavedPositions();
+}
 
 void BufferView::switchKeyMap()
 {
@@ -198,7 +192,7 @@ void BufferView::switchKeyMap()
 
 int BufferView::workWidth() const
 {
-       return pimpl_->workarea().workWidth();
+       return pimpl_->width();
 }
 
 
@@ -208,50 +202,45 @@ void BufferView::center()
 }
 
 
-string const BufferView::getClipboard() const
+FuncStatus BufferView::getStatus(FuncRequest const & cmd)
 {
-       return pimpl_->workarea().getClipboard();
+       return pimpl_->getStatus(cmd);
 }
 
 
-void BufferView::stuffClipboard(string const & stuff) const
+bool BufferView::dispatch(FuncRequest const & ev)
 {
-       pimpl_->stuffClipboard(stuff);
+       return pimpl_->dispatch(ev);
 }
 
 
-FuncStatus BufferView::getStatus(FuncRequest const & cmd)
+void BufferView::selectionRequested()
 {
-       return pimpl_->getStatus(cmd);
+       pimpl_->selectionRequested();
 }
 
 
-bool BufferView::dispatch(FuncRequest const & ev)
+void BufferView::selectionLost()
 {
-       return pimpl_->dispatch(ev);
+       pimpl_->selectionLost();
 }
 
 
-void BufferView::scroll(int lines)
+void BufferView::workAreaResize(int width, int height)
 {
-       pimpl_->scroll(lines);
+       pimpl_->workAreaResize(width, height);
 }
 
 
-void BufferView::showErrorList(string const & action) const
+bool BufferView::workAreaDispatch(FuncRequest const & ev)
 {
-       if (getErrorList().size()) {
-               string const title = bformat(_("%1$s Errors (%2$s)"),
-                       action, buffer()->fileName());
-               owner()->getDialogs().show("errorlist", title);
-               pimpl_->errorlist_.clear();
-       }
+       return pimpl_->workAreaDispatch(ev);
 }
 
 
-ErrorList const & BufferView::getErrorList() const
+void BufferView::scroll(int lines)
 {
-       return pimpl_->errorlist_;
+       pimpl_->scroll(lines);
 }
 
 
@@ -283,11 +272,6 @@ void BufferView::gotoLabel(string const & label)
 }
 
 
-void BufferView::hideCursor()
-{
-       screen().hideCursor();
-}
-
 LyXText * BufferView::getLyXText()
 {
        LyXText * text = cursor().innerText();
@@ -304,15 +288,9 @@ LyXText const * BufferView::getLyXText() const
 }
 
 
-void BufferView::haveSelection(bool sel)
-{
-       pimpl_->workarea().haveSelection(sel);
-}
-
-
 int BufferView::workHeight() const
 {
-       return pimpl_->workarea().workHeight();
+       return pimpl_->height();
 }
 
 
@@ -333,6 +311,28 @@ void BufferView::setCursor(DocIterator const & dit)
 }
 
 
+void BufferView::mouseSetCursor(LCursor & cur)
+{
+       BOOST_ASSERT(&cur.bv() == this);
+
+       // Has the cursor just left the inset?
+       bool badcursor = false;
+       if (&cursor().inset() != &cur.inset())
+               badcursor = cursor().inset().notifyCursorLeaves(cursor());
+
+       // do the dEPM magic if needed
+       // FIXME: move this to InsetText::notifyCursorLeaves?
+       if (!badcursor && cursor().inTexted())
+               cursor().text()->deleteEmptyParagraphMechanism(cur, cursor());
+
+       cursor() = cur;
+       cursor().clearSelection();
+       cursor().setTargetX();
+       finishUndo();
+
+}
+
+
 void BufferView::putSelectionAt(DocIterator const & cur,
                                int length, bool backwards)
 {
@@ -372,3 +372,15 @@ int BufferView::offset_ref() const
 {
        return pimpl_->offset_ref_;
 }
+
+
+ViewMetricsInfo const & BufferView::viewMetricsInfo()
+{
+       return pimpl_->viewMetricsInfo();
+}
+
+
+void BufferView::updateMetrics(bool singlepar)
+{
+       pimpl_->updateMetrics(singlepar);
+}