]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.C
more cursor dispatch
[lyx.git] / src / bufferview_funcs.C
index cf40ca5d35aee2e06bbd5e0b2e220d3de0b67076..634ed5f9c4342190530f8823a651a36c1778f67d 100644 (file)
@@ -27,7 +27,6 @@
 #include "lyxrow.h"
 #include "paragraph.h"
 #include "ParagraphParameters.h"
-#include "PosIterator.h"
 #include "iterators.h"
 
 #include "frontends/Alert.h"
 
 #include "insets/insettext.h"
 
-#include "mathed/math_cursor.h"
-
 #include "support/tostr.h"
-
 #include "support/std_sstream.h"
 
 using lyx::support::bformat;
@@ -151,38 +147,36 @@ bool string2font(string const & data, LyXFont & font, bool & toggle)
 
 bool changeDepthAllowed(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
 {
-       if (!bv->available() || !text)
-               return false;
-
-       return text->changeDepthAllowed(type);
+       return bv->available() && text && text->changeDepthAllowed(type);
 }
 
 
 void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
 {
-       if (!bv->available() || !text)
-               return;
-       text->changeDepth(type);
+       if (bv->available() && text)
+               text->changeDepth(type);
 }
 
 
 // Returns the current font and depth as a message.
 string const currentState(BufferView * bv)
 {
+       ostringstream state;
+
        if (!bv->available())
                return string();
 
-       if (mathcursor)
-               return mathcursor->info();
-
-       ostringstream state;
+       if (bv->cursor().inMathed()) {
+               bv->cursor().info(state);
+               return state.str();
+       }
 
        LyXText * text = bv->getLyXText();
        Buffer * buffer = bv->buffer();
-       LyXCursor const & c = text->cursor;
+       CursorSlice const & c = text->cursor();
 
        bool const show_change = buffer->params().tracking_changes
-               && text->cursor.pos() != text->cursorPar()->size()
+               && text->cursor().pos() != text->cursorPar()->size()
                && text->cursorPar()->lookupChange(c.pos()) != Change::UNCHANGED;
 
        if (show_change) {
@@ -242,8 +236,8 @@ string const currentState(BufferView * bv)
 #ifdef DEVEL_VERSION
        ParagraphList::iterator pit = text->cursorPar();
        state << _(", Paragraph: ") << pit->id();
-       state << _(", Position: ") << text->cursor.pos();
-       RowList::iterator rit = pit->getRow(text->cursor.pos());
+       state << _(", Position: ") << text->cursor().pos();
+       RowList::iterator rit = pit->getRow(text->cursor().pos());
        state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->endpos());
        state << _(", Inset: ");
        InsetOld * inset = pit->inInset();
@@ -256,57 +250,13 @@ string const currentState(BufferView * bv)
 }
 
 
-
 // deletes a selection during an insertion
 void replaceSelection(LyXText * text)
 {
-       if (text->selection.set()) {
+       if (text->bv()->cursor().selection()) {
                text->cutSelection(true, false);
                text->bv()->update();
        }
 }
 
-
-/*
-if the fitCursor call refers to some point in never-explored-land, then we
-don't have y information in insets there, then we cannot even do an update
-to get it (because we need the y infomation for setting top_y first). So
-this is solved in put_selection_at with:
-
-- setting top_y to the y of the outerPar (that has good info)
-- calling update
-- calling cursor().updatePos()
-- then call fitCursor()
-
-Ab.
-*/
-
-void put_selection_at(BufferView * bv, PosIterator const & cur,
-                     int length, bool backwards)
-{
-       ParIterator par(cur);
-       
-       bv->getLyXText()->clearSelection();
-
-       LyXText * text = par.text(*bv->buffer());
-       par.lockPath(bv);
-       //hack for the chicken and egg problem
-       if (par.inset())
-               bv->top_y(par.outerPar()->y);
-       bv->update();
-       text->setCursor(cur.pit(), cur.pos());
-       bv->cursor().updatePos();
-
-       if (length) {
-               text->setSelectionRange(length);
-               text->setSelection();
-               if (backwards)
-                       std::swap(text->cursor, text->selection.cursor);
-       }
-
-       bv->fitCursor();
-       bv->update();
-}
-
-
 } // namespace bv_funcs