]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.C
more cursor dispatch
[lyx.git] / src / bufferview_funcs.C
index c8445a2935251677e3f05345efa69e8496728eda..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,31 +147,29 @@ 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();
@@ -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->anchor());
-       }
-
-       bv->fitCursor();
-       bv->update();
-}
-
-
 } // namespace bv_funcs