shape = (txt->real_current_font.isVisibleRightToLeft())
? LyXScreen::REVERSED_L_SHAPE
: LyXScreen::L_SHAPE;
- y += cursor.y() + theLockingInset()->insetInInsetY();
+ y += cursor.iy() + theLockingInset()->insetInInsetY();
pimpl_->screen_->showManualCursor(text, x, y, asc, desc,
shape);
}
bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
{
if (theLockingInset() && available()) {
- y += text->cursor.y() + theLockingInset()->insetInInsetY();
+ y += text->cursor.iy() + theLockingInset()->insetInInsetY();
if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc)) {
updateScrollbar();
return true;
x -= b.x1;
// The origin of an inset is on the baseline
- y -= (text.cursor.y());
+ y -= text.cursor.iy();
return inset;
}
+2002-04-11 Juergen Vigna <jug@sad.it>
+
+ * BufferView2.C (showLockedInsetCursor): use iy
+ (fitLockedInsetCursor): ditto
+
+ * BufferView_pimpl.C (checkInset): use LyXCursor::iy for baseline of
+ locked insets as there we have the right value now.
+
+ * lyxcursor.C: added iy_ variable and iy functions to set to the
+ baseline of cursor-y of the locked inset.
+
+ * text2.C (setCursorFromCoordinates): set LyXCursor::iy.
+ (setCursor): fixed for insets which need a full row.
+
+ * text.C (rowLastPrintable): don't ignore the last space when before
+ an inset which needs a full row.
+ (numberOfSeparators): use rowLastPrintable and <= last to honor a space
+ as last character of a row when before a inset which needs a full row.
+
2002-04-06 Lars Gullik Bjønnes <larsbj@birdstep.com>
* version.C.in: update date
LyXCursor::LyXCursor()
: par_(0), pos_(0), boundary_(false),
- x_(0), x_fix_(0), y_(0), row_(0)
+ x_(0), x_fix_(0), y_(0), iy_(0), row_(0)
{}
}
+void LyXCursor::iy(int i)
+{
+ iy_ = i;
+}
+
+
+int LyXCursor::iy() const
+{
+ return iy_;
+}
+
+
void LyXCursor::row(Row * r)
{
row_ = r;
///
int y() const;
///
+ void iy(int i);
+ ///
+ int iy() const;
+ ///
void row(Row * r);
///
Row * row() const;
int x_fix_;
///
int y_;
+ /// the y position of the position before the inset when we put
+ /// the cursor on the end of the row before, otherwise equal to y.
+ int iy_;
///
Row * row_;
};
pos_type LyXText::rowLastPrintable(Row const * row) const
{
pos_type const last = rowLast(row);
+ bool ignore_the_space_on_the_last_position = true;
+ Inset * ins;
+ // we have to consider a space on the last position in this case!
+ if (row->next() && row->par() == row->next()->par() &&
+ row->next()->par()->getChar(last+1) == Paragraph::META_INSET &&
+ (ins=row->next()->par()->getInset(last+1)) &&
+ (ins->needFullRow() || ins->display()))
+ {
+ ignore_the_space_on_the_last_position = false;
+ }
if (last >= row->pos()
&& row->next()
&& row->next()->par() == row->par()
- && row->par()->isSeparator(last))
+ && row->par()->isSeparator(last)
+ && ignore_the_space_on_the_last_position)
return last - 1;
else
return last;
// on the very last column doesnt count
int LyXText::numberOfSeparators(Buffer const * buf, Row const * row) const
{
- pos_type const last = rowLast(row);
+ pos_type last = rowLastPrintable(row);
pos_type p = max(row->pos(), beginningOfMainBody(buf, row->par()));
+
int n = 0;
- for (; p < last; ++p) {
+ for (; p <= last; ++p) {
if (row->par()->isSeparator(p)) {
++n;
}
cur.pos(pos);
cur.boundary(boundary);
-#if 0
- if (pos && par->getChar(pos) == Paragraph::META_INSET &&
- par->getInset(pos)) {
- Inset * ins = par->getInset(pos);
- if (ins->needFullRow() || ins->display()) {
- --pos;
- boundary = true;
- }
- }
-#endif
-
// get the cursor y position in text
int y = 0;
Row * row = getRow(par, pos, y);
+ Row * old_row = row;
+ // if we are before the first char of this row and are still in the
+ // same paragraph and there is a previous row then put the cursor on
+ // the end of the previous row
+ cur.iy(y + row->baseline());
+ Inset * ins;
+ if (pos && par->getChar(pos) == Paragraph::META_INSET &&
+ (ins=par->getInset(pos)) && (ins->needFullRow() || ins->display()))
+ {
+ row = row->previous();
+ y -= row->height();
+ }
+
+ cur.row(row);
// y is now the beginning of the cursor row
y += row->baseline();
// y is now the cursor baseline
prepareToPrint(bview, row, x, fill_separator, fill_hfill,
fill_label_hfill);
pos_type cursor_vpos = 0;
- pos_type last = rowLastPrintable(row);
+ pos_type last = rowLastPrintable(old_row);
if (pos > last + 1) {
// This shouldn't happen.
cur.x(int(x));
cur.x_fix(cur.x());
- cur.row(row);
}
cur.pos(row->pos() + column);
cur.x(x);
cur.y(y + row->baseline());
+ cur.iy(cur.y());
cur.row(row);
cur.boundary(bound);
}