#include "support/textutils.h"
#include "support/convert.h"
+#include <boost/current_function.hpp>
+
#include <sstream>
using lyx::pit_type;
l_margin += font_metrics::signedWidth(tclass.leftmargin(), tclass.defaultfont());
if (par.getDepth() != 0) {
- // find the next level paragraph
- pit_type newpar = outerHook(pit, pars_);
+ // find the next level paragraph
+ pit_type newpar = outerHook(pit, pars_);
if (newpar != pit_type(pars_.size())) {
if (pars_[newpar].layout()->isEnvironment()) {
l_margin = leftMargin(newpar);
}
}
+ // This happens after sections in standard classes. The 1.3.x
+ // code compared depths too, but it does not seem necessary
+ // (JMarc)
+ if (par.layout() == tclass.defaultLayout()
+ && pit > 0 && pars_[pit - 1].layout()->nextnoindent)
+ parindent.erase();
+
LyXFont const labelfont = getLabelFont(par);
switch (layout->margintype) {
case MARGIN_DYNAMIC:
&& !isFirstInSequence(pit, pars_)))
&& align == LYX_ALIGN_BLOCK
&& !par.params().noindent()
+ // in some insets, paragraphs are never indented
+ && !(par.inInset() && par.inInset()->neverIndent())
// display style insets are always centered, omit indentation
&& !(!par.empty()
&& par.isInset(pos)
&& par.getInset(pos)->display())
- // in charstyles, tabulars and ert paragraphs are never indented!
- && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText())
- && par.ownerCode() != InsetBase::ERT_CODE
- && par.ownerCode() != InsetBase::CHARSTYLE_CODE)
&& (par.layout() != tclass.defaultLayout()
|| bv()->buffer()->params().paragraph_separation ==
BufferParams::PARSEP_INDENT))
if (bv_owner->text() == this) {
if (pit == 0 && row.pos() == 0)
maxasc += 20;
- if (pit + 1 == pars_.size() && row.endpos() == par.size())
+ if (pit + 1 == pit_type(pars_.size()) &&
+ row.endpos() == par.size())
maxdesc += 20;
}
current_font = rawtmpfont;
real_current_font = realtmpfont;
- //setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary());
- setCursor(cur, cur.pit(), cur.pos() + 1, false, true);
+ setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary());
charInserted();
}
InsetList::iterator iend = par.insetlist.end();
for (; ii != iend; ++ii) {
Dimension dim;
- int const w = maxwidth_ - leftMargin(pit) - rightMargin(par);
+ int const w = maxwidth_ - leftMargin(pit, ii->pos) - rightMargin(par);
MetricsInfo mi(bv(), getFont(par, ii->pos), w);
ii->inset->metrics(mi, dim);
}
z = row.endpos();
} while (z < par.size());
+ // Make sure that if a par ends in newline, there is one more row
+ // under it
+ // FIXME this is a dirty trick. Now the _same_ position in the
+ // paragraph occurs in _two_ different rows, and has two different
+ // display positions, leading to weird behaviour when moving up/down.
+ if (z > 0 && par.isNewline(z - 1)) {
+ Row row(z - 1);
+ row.endpos(z - 1);
+ setRowWidth(pit, row);
+ setHeightOfRow(pit, row);
+ par.rows().push_back(row);
+ dim.des += row.height();
+ }
+
dim.asc += par.rows()[0].ascent();
dim.des -= par.rows()[0].ascent();
lyxerr << "draw selection at " << x << endl;
- // is there a better way of getting these two iterators?
- DocIterator beg = cur;
- DocIterator end = cur;
-
- beg.top() = cur.selBegin();
- end.top() = cur.selEnd();
+ DocIterator beg = cur.selectionBegin();
+ DocIterator end = cur.selectionEnd();
// the selection doesn't touch the visible screen
if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW
<< "draw selection at " << x
<< endl;
- // is there a better way of getting these two iterators?
- DocIterator beg = cur;
- DocIterator end = cur;
-
- beg.top() = cur.selBegin();
- end.top() = cur.selEnd();
+ DocIterator beg = cur.selectionBegin();
+ DocIterator end = cur.selectionEnd();
// the selection doesn't touch the visible screen
if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW
// see correction above
if (boundary_correction)
- if (getFont(par, ppos).isRightToLeft())
+ if (getFont(par, ppos).isVisibleRightToLeft())
x -= singleWidth(par, ppos);
else
x += singleWidth(par, ppos);
+ // Make sure inside an inset we always count from the left
+ // edge (bidi!) -- MV
+ if (sl.pos() < par.size()) {
+ font = getFont(par, sl.pos());
+ if (!boundary && font.isVisibleRightToLeft()
+ && par.isInset(sl.pos()))
+ x -= par.getInset(sl.pos())->width();
+ }
return int(x);
}
// x,y are screen coordinates
// sets cursor only within this LyXText
-void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
+bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
{
pit_type pit = getPitNearY(y);
int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent();
<< " pos: " << pos
<< endl;
- setCursor(cur, pit, pos, true, bound);
+ return setCursor(cur, pit, pos, true, bound);
}