#include "FuncRequest.h"
#include "Language.h"
#include "lfuns.h"
-#include "LyXFont.h"
+#include "Font.h"
#include "LyXFunc.h" // only for setMessage()
#include "LyXRC.h"
#include "Row.h"
-#include "LyXText.h"
+#include "Text.h"
#include "Paragraph.h"
#include "paragraph_funcs.h"
#include "ParIterator.h"
#include "mathed/MathData.h"
#include "mathed/InsetMath.h"
#include "mathed/InsetMathScript.h"
-#include "mathed/MathMacroTable.h"
+#include "mathed/MacroTable.h"
#include "support/limited_stack.h"
for (size_t i = 0;; ++i) {
int xo;
int yo;
- InsetBase const * inset = &it.inset();
- std::map<InsetBase const *, Point> const & data =
+ Inset const * inset = &it.inset();
+ std::map<Inset const *, Point> const & data =
c.bv().coordCache().getInsets().getData();
- std::map<InsetBase const *, Point>::const_iterator I = data.find(inset);
+ std::map<Inset const *, Point>::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
int x, int y, int xlow, int xhigh, int ylow, int yhigh)
{
BOOST_ASSERT(!cursor.empty());
- InsetBase & inset = cursor[0].inset();
+ Inset & inset = cursor[0].inset();
BufferView & bv = cursor.bv();
CoordCache::InnerParPosCache const & cache =
// << " xlow: " << xlow << " xhigh: " << xhigh
// << " ylow: " << ylow << " yhigh: " << yhigh
// << endl;
- InsetBase & inset = bv.buffer()->inset();
+ Inset & inset = bv.buffer()->inset();
DocIterator it = doc_iterator_begin(inset);
it.pit() = from;
DocIterator et = doc_iterator_end(inset);
return true;
}
+ docstring parbreak(Paragraph const & par)
+ {
+ 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)
+ ods << '\n';
+ return ods.str();
+ }
+
} // namespace anon
{}
-void Cursor::reset(InsetBase & inset)
+void Cursor::reset(Inset & inset)
{
clear();
push_back(CursorSlice(inset));
}
-void Cursor::push(InsetBase & p)
+void Cursor::push(Inset & p)
{
push_back(CursorSlice(p));
}
-void Cursor::pushLeft(InsetBase & p)
+void Cursor::pushLeft(Inset & p)
{
BOOST_ASSERT(!empty());
//lyxerr << "Entering inset " << t << " left" << endl;
BOOST_ASSERT(!empty());
for (int i = depth() - 1; i >= 0; --i) {
int res = operator[](i).inset().currentMode();
- if (res != InsetBase::UNDECIDED_MODE)
+ if (res != Inset::UNDECIDED_MODE)
return res;
}
- return InsetBase::TEXT_MODE;
+ return Inset::TEXT_MODE;
}
os << " ";
}
if (pos() != 0) {
- InsetBase const * inset = prevInset();
+ Inset const * inset = prevInset();
// prevInset() can return 0 in certain case.
if (inset)
prevInset()->infoize2(os);
//#define FILEDEBUG 1
-bool Cursor::isInside(InsetBase const * p)
+bool Cursor::isInside(Inset const * p)
{
for (size_t i = 0; i != depth(); ++i)
if (&operator[](i).inset() == p)
}
-void Cursor::leaveInset(InsetBase const & inset)
+void Cursor::leaveInset(Inset const & inset)
{
for (size_t i = 0; i != depth(); ++i) {
if (&operator[](i).inset() == &inset) {
}
-void Cursor::insert(InsetBase * inset)
+void Cursor::insert(Inset * inset)
{
if (inMathed())
insert(MathAtom(inset));
// First paragraph in selection
docstring result = pars[startpit].
- asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
+ asString(buffer, startpos, pars[startpit].size(), label)
+ + parbreak(pars[startpit]);
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
Paragraph const & par = pars[pit];
- result += par.asString(buffer, 0, par.size(), label) + "\n\n";
+ result += par.asString(buffer, 0, par.size(), label)
+ + parbreak(pars[pit]);
}
// Last paragraph in selection
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
- LyXText const & text = *sl.text();
- LyXFont font = text.getPar(sl.pit()).getFont(
+ Text const & text = *sl.text();
+ Font font = text.getPar(sl.pit()).getFont(
bv().buffer()->params(), sl.pos(), outerFont(sl.pit(), text.paragraphs()));
return font.language()->encoding();
}
}
-LyXFont Cursor::getFont() const
+Font Cursor::getFont() const
{
// HACK. far from being perfect...
int s = 0;
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
- LyXText const & text = *sl.text();
- LyXFont font = text.getPar(sl.pit()).getFont(
+ Text const & text = *sl.text();
+ Font font = text.getPar(sl.pit()).getFont(
bv().buffer()->params(),
sl.pos(),
outerFont(sl.pit(), text.paragraphs()));
void Cursor::fixIfBroken()
{
- // find out last good level
- Cursor copy = *this;
- size_t newdepth = depth();
- while (!copy.empty()) {
- if (copy.idx() > copy.lastidx()) {
- lyxerr << "wrong idx " << copy.idx()
- << ", max is " << copy.lastidx()
- << " at level " << copy.depth()
- << ". Trying to correct this." << endl;
- lyxerr << "old: " << *this << endl;
- newdepth = copy.depth() - 1;
- }
- else if (copy.pit() > copy.lastpit()) {
- lyxerr << "wrong pit " << copy.pit()
- << ", max is " << copy.lastpit()
- << " at level " << copy.depth()
- << ". Trying to correct this." << endl;
- lyxerr << "old: " << *this << endl;
- newdepth = copy.depth() - 1;
- }
- else if (copy.pos() > copy.lastpos()) {
- lyxerr << "wrong pos " << copy.pos()
- << ", max is " << copy.lastpos()
- << " at level " << copy.depth()
- << ". Trying to correct this." << endl;
- lyxerr << "old: " << *this << endl;
- newdepth = copy.depth() - 1;
- }
- copy.pop();
- }
- // shrink cursor to a size where everything is valid, possibly
- // leaving insets
- while (depth() > newdepth) {
- pop();
- lyxerr << "correcting cursor to level " << depth() << endl;
- lyxerr << "new: " << *this << endl;
- clearSelection();
+ if (DocIterator::fixIfBroken()) {
+ clearSelection();
+ resetAnchor();
}
}