]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Check path of Qt tools if qtchooser is detected
[lyx.git] / src / Cursor.cpp
index 6733aaedfad58d3beb14d92a43a121a7498d8a82..8d5c63b55e67c182dc658536df9d3914d28805b6 100644 (file)
@@ -31,6 +31,7 @@
 #include "Paragraph.h"
 #include "ParIterator.h"
 #include "Row.h"
+#include "texstream.h"
 #include "Text.h"
 #include "TextMetrics.h"
 #include "TocBackend.h"
@@ -51,8 +52,6 @@
 #include "mathed/MathData.h"
 #include "mathed/MathMacro.h"
 
-#include "support/bind.h"
-
 #include <sstream>
 #include <limits>
 #include <map>
@@ -73,25 +72,25 @@ DocIterator bruteFind(Cursor const & c, int x, int y)
        DocIterator result;
 
        DocIterator it = c;
-       it.top().pos() = 0;
+       it.pos() = 0;
        DocIterator et = c;
-       et.top().pos() = et.top().asInsetMath()->cell(et.top().idx()).size();
+       et.pos() = et.lastpos();
        for (size_t i = 0;; ++i) {
                int xo;
                int yo;
                Inset const * inset = &it.inset();
-               CoordCache const & cache = c.bv().coordCache();
+               CoordCache::Insets const & insetCache = c.bv().coordCache().getInsets();
 
                // FIXME: in the case where the inset is not in the cache, this
                // means that no part of it is visible on screen. In this case
                // we don't do elaborate search and we just return the forwarded
                // DocIterator at its beginning.
-               if (!cache.getInsets().has(inset)) {
+               if (!insetCache.has(inset)) {
                        it.top().pos() = 0;
                        return it;
                }
 
-               Point const o = cache.getInsets().xy(inset);
+               Point const o = insetCache.xy(inset);
                inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
                // Convert to absolute
                xo += o.x_;
@@ -997,18 +996,18 @@ DocIterator Cursor::selectionEnd() const
 
 void Cursor::setSelection()
 {
-       setSelection(true);
+       selection(true);
        if (idx() == normalAnchor().idx() &&
            pit() == normalAnchor().pit() &&
            pos() == normalAnchor().pos())
-               setSelection(false);
+               selection(false);
 }
 
 
 void Cursor::setSelection(DocIterator const & where, int n)
 {
        setCursor(where);
-       setSelection(true);
+       selection(true);
        anchor_ = where;
        pos() += n;
 }
@@ -1016,7 +1015,7 @@ void Cursor::setSelection(DocIterator const & where, int n)
 
 void Cursor::clearSelection()
 {
-       setSelection(false);
+       selection(false);
        setWordSelection(false);
        setMark(false);
        resetAnchor();
@@ -1079,7 +1078,7 @@ bool Cursor::selHandle(bool sel)
                cap::saveSelection(*this);
 
        resetAnchor();
-       setSelection(sel);
+       selection(sel);
        return true;
 }
 } // namespace lyx
@@ -1184,9 +1183,8 @@ void Cursor::plainInsert(MathAtom const & t)
 
 void Cursor::insert(docstring const & str)
 {
-       for_each(str.begin(), str.end(),
-                bind(static_cast<void(Cursor::*)(char_type)>
-                            (&Cursor::insert), this, _1));
+       for (char_type c : str)
+               insert(c);
 }
 
 
@@ -1319,7 +1317,7 @@ bool Cursor::backspace()
                // let's require two backspaces for 'big stuff' and
                // highlight on the first
                resetAnchor();
-               setSelection(true);
+               selection(true);
                --pos();
        } else {
                --pos();
@@ -1366,7 +1364,7 @@ bool Cursor::erase()
        // 'clever' UI hack: only erase large items if previously slected
        if (pos() != lastpos() && nextAtom()->nargs() > 0) {
                resetAnchor();
-               setSelection(true);
+               selection(true);
                ++pos();
        } else {
                plainErase();
@@ -1569,8 +1567,7 @@ void Cursor::normalize()
                        << pos() << ' ' << lastpos() <<  " in idx: " << idx()
                       << " in atom: '";
                odocstringstream os;
-               TexRow texrow(false);
-               otexrowstream ots(os,texrow);
+               otexrowstream ots(os, false);
                WriteStream wi(ots, false, true, WriteStream::wsDefault);
                inset().asInsetMath()->write(wi);
                lyxerr << to_utf8(os.str()) << endl;