#include "Bidi.h"
#include "BufferView.h"
-#include "bufferview_funcs.h"
#include "Buffer.h"
#include "Cursor.h"
#include "CoordCache.h"
#include "Paragraph.h"
#include "paragraph_funcs.h"
#include "ParIterator.h"
+#include "TextMetrics.h"
#include "insets/InsetTabular.h"
#include "insets/InsetText.h"
#include "mathed/InsetMathScript.h"
#include "mathed/MacroTable.h"
-#include "support/limited_stack.h"
-
#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/current_function.hpp>
int xo;
int yo;
Inset const * inset = &it.inset();
- std::map<Inset const *, Point> const & data =
+ std::map<Inset const *, Geometry> const & data =
c.bv().coordCache().getInsets().getData();
- std::map<Inset const *, Point>::const_iterator I = data.find(inset);
+ std::map<Inset const *, Geometry>::const_iterator I = data.find(inset);
// 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
return it;
}
- Point o = I->second;
+ Point o = I->second.pos;
inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;
}
+ /*
/// moves position closest to (x, y) in given box
bool bruteFind(Cursor & cursor,
int x, int y, int xlow, int xhigh, int ylow, int yhigh)
for ( ; it != et; it.forwardPos(true)) {
// avoid invalid nesting when selecting
if (!cursor.selection() || positionable(it, cursor.anchor_)) {
- Point p = bv_funcs::getPos(bv, it, false);
+ Point p = bv.getPos(it, false);
int xo = p.x_;
int yo = p.y_;
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
return false;
}
+ */
/// moves position closest to (x, y) in given box
for ( ; it != et; it.forwardPos()) {
// avoid invalid nesting when selecting
- if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
+ if (bv.cursorStatus(it) == CUR_INSIDE
&& (!cur.selection() || positionable(it, cur.anchor_))) {
- Point p = bv_funcs::getPos(bv, it, false);
+ Point p = bv.getPos(it, false);
int xo = p.x_;
int yo = p.y_;
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
odocstringstream ods;
ods << '\n';
// only add blank line if we're not in an ERT or Listings inset
- if (par.ownerCode() != Inset::ERT_CODE
- && par.ownerCode() != Inset::LISTINGS_CODE)
+ if (par.ownerCode() != ERT_CODE
+ && par.ownerCode() != LISTINGS_CODE)
ods << '\n';
return ods.str();
}
void Cursor::getPos(int & x, int & y) const
{
- Point p = bv_funcs::getPos(bv(), *this, boundary());
+ Point p = bv().getPos(*this, boundary());
x = p.x_;
y = p.y_;
}
}
-void Cursor::setScreenPos(int x, int y)
+void Cursor::setScreenPos(int x, int /*y*/)
{
setTargetX(x);
- bruteFind(*this, x, y, 0, bv().workWidth(), 0, bv().workHeight());
+ //bruteFind(*this, x, y, 0, bv().workWidth(), 0, bv().workHeight());
}
// with and without selection are handled differently
if (!selection()) {
- int yo = bv_funcs::getPos(bv(), *this, boundary()).y_;
+ int yo = bv().getPos(*this, boundary()).y_;
Cursor old = *this;
// To next/previous row
if (up)
void Cursor::setCurrentFont()
{
- pos_type cpos = pos();
- Paragraph & par = paragraph();
- Text const & ctext = *text();
+ CursorSlice const & cs = innerTextSlice();
+ Paragraph const & par = cs.paragraph();
+ pos_type cpit = cs.pit();
+ pos_type cpos = cs.pos();
+ Text const & ctext = *cs.text();
TextMetrics const & tm = bv().textMetrics(&ctext);
// are we behind previous char in fact? -> go to that char
// abc| def -> font of c
// abc |[WERBEH], i.e. boundary==true -> font of c
// abc [WERBEH]| def, font of the space
- if (!tm.isRTLBoundary(pit(), cpos))
+ if (!tm.isRTLBoundary(cpit, cpos))
--cpos;
}
}
// get font
BufferParams const & bufparams = buffer().params();
current_font = par.getFontSettings(bufparams, cpos);
- real_current_font = tm.getDisplayFont(pit(), cpos);
+ real_current_font = tm.getDisplayFont(cpit, cpos);
// special case for paragraph end
- if (pos() == lastpos()
- && tm.isRTLBoundary(pit(), pos())
+ if (cs.pos() == lastpos()
+ && tm.isRTLBoundary(cpit, cs.pos())
&& !boundary()) {
Language const * lang = par.getParLanguage(bufparams);
current_font.setLanguage(lang);
}
}
+
+bool Cursor::textUndo()
+{
+ DocIterator dit = *this;
+ // Undo::textUndo() will modify dit.
+ if (!bv_->buffer().undo().textUndo(dit))
+ return false;
+ // Set cursor
+ setCursor(dit);
+ selection() = false;
+ resetAnchor();
+ fixIfBroken();
+ return true;
+}
+
+
+bool Cursor::textRedo()
+{
+ DocIterator dit = *this;
+ // Undo::textRedo() will modify dit.
+ if (!bv_->buffer().undo().textRedo(dit))
+ return false;
+ // Set cursor
+ setCursor(dit);
+ selection() = false;
+ resetAnchor();
+ fixIfBroken();
+ return true;
+}
+
+
+void Cursor::finishUndo()
+{
+ bv_->buffer().undo().finishUndo();
+}
+
+
+void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to)
+{
+ bv_->buffer().undo().recordUndo(*this, kind, from, to);
+}
+
+
+void Cursor::recordUndo(UndoKind kind, pit_type from)
+{
+ bv_->buffer().undo().recordUndo(*this, kind, from);
+}
+
+
+void Cursor::recordUndo(UndoKind kind)
+{
+ bv_->buffer().undo().recordUndo(*this, kind);
+}
+
+
+void Cursor::recordUndoInset(UndoKind kind)
+{
+ bv_->buffer().undo().recordUndoInset(*this, kind);
+}
+
+
+void Cursor::recordUndoFullDocument()
+{
+ bv_->buffer().undo().recordUndoFullDocument(*this);
+}
+
+
+void Cursor::recordUndoSelection()
+{
+ bv_->buffer().undo().recordUndo(*this, ATOMIC_UNDO,
+ selBegin().pit(), selEnd().pit());
+}
+
+
} // namespace lyx