#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"
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
// 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();
+ if (DocIterator::fixIfBroken()) {
+ clearSelection();
+ resetAnchor();
}
- // 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();
- }
-}
-
-
-bool Cursor::isRTL() const
-{
- return top().paragraph().isRightToLeftPar(bv().buffer()->params());
}