]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.C
more cursor dispatch
[lyx.git] / src / bufferview_funcs.C
index 2c28e2b81a1c885ebfbc990f65dd0db3be83b06e..634ed5f9c4342190530f8823a651a36c1778f67d 100644 (file)
@@ -19,6 +19,7 @@
 #include "buffer.h"
 #include "bufferparams.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "gettext.h"
 #include "language.h"
 #include "LColor.h"
@@ -26,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;
@@ -148,38 +145,38 @@ bool string2font(string const & data, LyXFont & font, bool & toggle)
 }
 
 
-bool changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE type, bool test_only)
+bool changeDepthAllowed(BufferView * bv, LyXText * text, DEPTH_CHANGE type)
 {
-       if (!bv->available() || !text)
-               return false;
+       return bv->available() && text && text->changeDepthAllowed(type);
+}
 
-       if (test_only)
-               return text->changeDepth(type, true);
 
-       bool const changed = text->changeDepth(type, false);
-       if (text->inset_owner)
-               bv->updateInset(text->inset_owner);
-       return changed;
+void changeDepth(BufferView * bv, LyXText * text, DEPTH_CHANGE 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) {
@@ -239,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();
@@ -253,39 +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();
        }
 }
 
-
-void put_selection_at(BufferView * bv, PosIterator const & cur,
-                     int length, bool backwards)
-{
-       ParIterator par(cur);
-       
-       bv->getLyXText()->clearSelection();
-
-       LyXText * text = par.text(bv);
-       par.lockPath(bv);
-
-       text->setCursor(cur.pit(), cur.pos());
-
-       if (length) {
-               text->setSelectionRange(length);
-               text->setSelection();
-               if (backwards)
-                       text->cursor = text->selection.start;
-       }
-       
-       bv->fitCursor();
-       bv->update();
-}
-
-
-}; // namespace bv_funcs
+} // namespace bv_funcs