cursor.par(), cursor.pos());
int width = bv_->theLockingInset()->width(bv_, font);
int inset_x = font.isVisibleRightToLeft()
- ? cursor.x() - width : cursor.x();
+ ? cursor.ix() - width : cursor.ix();
int start_x = inset_x + bv_->theLockingInset()->scroll();
bv_->theLockingInset()->
insetMotionNotify(bv_,
x - start_x,
- y - cursor.y() + bv_->text->first_y,
+ y - cursor.iy() + bv_->text->first_y,
state);
return;
}
2002-04-12 Juergen Vigna <jug@sad.it>
+ * BufferView_pimpl.C (workAreaMotionNotify): use new ix() cursor pos.
+
+ * text2.C (getCursorX): new helper function
+ (setCursor): compute also ix_
+ (setCursorFromCoordinates): set also ix.
+
+ * lyxcursor.h: added ix_ and helper functions.
+
+ * BufferView_pimpl.C (workAreaMotionNotify): forgot to use iy().
+
+ * buffer.C (insertStringAsLines): dont break paragraph if the this
+ paragraph is inside an inset which does not permit it!
+
* text.C (breakParagraph): honor keepempty flag and break the paragraph
also with no chars on this paragraph.
+ (paintRowText): only paint stuff if it's inside the workarea!
* paragraph.C (breakParagraph): honor keepempty flag and break the
paragraph always below not above.
par->checkInsertChar(font);
// insert the string, don't insert doublespace
bool space_inserted = true;
+ bool autobreakrows = !par->inInset() ||
+ static_cast<InsetText *>(par->inInset())->getAutoBreakRows();
for(string::const_iterator cit = str.begin();
cit != str.end(); ++cit) {
if (*cit == '\n') {
- if (par->size() || layout.keepempty) {
+ if (autobreakrows && (par->size() || layout.keepempty)) {
par->breakParagraph(params, pos,
layout.isEnvironment());
par = par->next();
+2002-04-12 Juergen Vigna <jug@sad.it>
+
+ * insettext.h: added cix() helper function and use it where appropriate
+
2002-04-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetgraphics.C (prepareFile): fix bug when graphics is a
2002-04-12 Juergen Vigna <jug@sad.it>
* insettext.C (insertInset): remove unneeded code!
+ (updateLocal): fitCursor() fixes.
+ (collapseParagraphs): fix a possible problem when having a selection
+ and collapsing the paragraphs.
2002-04-08 Herbert Voss <voss@perce.de>
if (the_locking_inset && (cpar(bv) == inset_par)
&& (cpos(bv) == inset_pos)) {
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
if (!cleared && (need_update == CURSOR)
}
if (!autoBreakRows && par->next())
- collapseParagraphs(bv->buffer()->params);
+ collapseParagraphs(bv);
if (the_locking_inset) {
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
the_locking_inset->update(bv, font, reinit);
}
void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
{
if (!autoBreakRows && par->next())
- collapseParagraphs(bv->buffer()->params);
+ collapseParagraphs(bv);
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
lt->selection.cursor = lt->cursor;
if (clear)
lt = 0;
+#if 0
+ // IMO this is not anymore needed as we do this in fitInsetCursor!
+ // and we always get "true" as returnvalue of this function in the
+ // case of a locking inset (Jug 20020412)
if (locked && (need_update & CURSOR) && bv->fitCursor())
need_update |= FULL;
+#else
+ bv->fitCursor();
+#endif
if (flag)
bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
{
the_locking_inset = inset;
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
inset_pos = cpos(bv);
inset_par = cpar(bv);
} else if (the_locking_inset && (the_locking_inset == inset)) {
if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
} else {
lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
{
if (!autoBreakRows && par->next())
- collapseParagraphs(bv->buffer()->params);
+ collapseParagraphs(bv);
if (inset == this)
return true;
bool clear = false;
if (the_locking_inset &&
cpar(bv) == inset_par && cpos(bv) == inset_pos)
{
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
}
else if (inset) {
// otherwise unlock the_locking_inset and lock the new inset
the_locking_inset->insetUnlock(bv);
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
the_locking_inset = 0;
inset->insetButtonPress(bv, x - inset_x,
ret = inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button);
} else {
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
ret = inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button);
x = insetWidth;
if (y < 0)
y = insetDescent;
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
inset->edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
}
+int InsetText::cix(BufferView * bv) const
+{
+ // we do nothing dangerous so we use a local cache
+ LyXText * llt = getLyXText(bv);
+ int x = llt->cursor.ix() + top_x + TEXT_TO_INSET_OFFSET;
+ if (the_locking_inset) {
+ LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
+ llt->cursor.pos());
+ if (font.isVisibleRightToLeft())
+ x -= the_locking_inset->width(bv, font);
+ }
+ return x;
+}
+
+
int InsetText::cy(BufferView * bv) const
{
LyXFont font;
t->init(bv, true);
restoreLyXTextState(bv, t);
if (the_locking_inset) {
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
t->init(bv, true);
restoreLyXTextState(bv, t);
if (the_locking_inset) {
- inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
if (bv->screen()) {
}
-void InsetText::collapseParagraphs(BufferParams const & bparams) const
+void InsetText::collapseParagraphs(BufferView * bv) const
{
+ BufferParams const & bparams = bv->buffer()->params;
+ LyXText * llt = getLyXText(bv);
+
while(par->next()) {
if (par->size() && par->next()->size() &&
!par->isSeparator(par->size()-1))
{
par->insertChar(par->size(), ' ');
}
+ if (llt->selection.set()) {
+ if (llt->selection.start.par() == par->next()) {
+ llt->selection.start.par(par);
+ llt->selection.start.pos(
+ llt->selection.start.pos() + par->size());
+ }
+ if (llt->selection.end.par() == par->next()) {
+ llt->selection.end.par(par);
+ llt->selection.end.pos(
+ llt->selection.end.pos() + par->size());
+ }
+ }
par->pasteParagraph(bparams);
}
reinitLyXText();
///
int cx(BufferView *) const;
///
+ int cix(BufferView *) const;
+ ///
int cy(BufferView *) const;
///
int ciy(BufferView *) const;
///
void reinitLyXText() const;
///
- void collapseParagraphs(BufferParams const & bparams) const;
+ void collapseParagraphs(BufferView *) const;
/* Private structures and variables */
///
LyXCursor::LyXCursor()
: par_(0), pos_(0), boundary_(false),
- x_(0), x_fix_(0), y_(0), iy_(0), row_(0)
+ x_(0), ix_(0), x_fix_(0), y_(0), iy_(0), row_(0)
{}
}
+void LyXCursor::ix(int n)
+{
+ ix_ = n;
+}
+
+int LyXCursor::ix() const
+{
+ return ix_;
+}
+
+
void LyXCursor::x_fix(int i)
{
x_fix_ = i;
///
int x() const;
///
+ void ix(int i);
+ ///
+ int ix() const;
+ ///
void x_fix(int i);
///
int x_fix() const;
bool boundary_;
///
int x_;
+ /// the x position of the position before the inset when we put
+ /// the cursor on the end of the row before, otherwise equal to x.
+ int ix_;
///
int x_fix_;
///
bool setfont = true,
bool boundary = false) const;
///
+ float getCursorX(BufferView *, Row *, lyx::pos_type pos,
+ lyx::pos_type last, bool boundary) const;
+ ///
void setCurrentFont(BufferView *) const;
///
pos_type vpos = p.row->pos();
while (vpos <= last) {
+ if (p.x > p.bv->workWidth())
+ break;
pos_type pos = vis2log(vpos);
+ if (p.x + singleWidth(p.bv, par, pos) < 0) {
+ p.x += singleWidth(p.bv, par, pos);
+ ++vpos;
+ continue;
+ }
if (main_body > 0 && pos == main_body - 1) {
int const lwidth = lyxfont::width(layout.labelsep,
getLabelFont(buffer, par));
// y is now the cursor baseline
cur.y(y);
- // now get the cursors x position
- float x;
- float fill_separator;
- float fill_hfill;
- float fill_label_hfill;
- prepareToPrint(bview, row, x, fill_separator, fill_hfill,
- fill_label_hfill);
- pos_type cursor_vpos = 0;
pos_type last = rowLastPrintable(old_row);
if (pos > last + 1) {
cur.pos(pos);
}
+ // now get the cursors x position
+ float x = getCursorX(bview, row, pos, last, boundary);
+ cur.x(int(x));
+ cur.x_fix(cur.x());
+ if (old_row != row) {
+ x = getCursorX(bview, old_row, pos, last, boundary);
+ cur.ix(int(x));
+ } else
+ cur.ix(cur.x());
+}
+
+
+float LyXText::getCursorX(BufferView * bview, Row * row,
+ pos_type pos, pos_type last, bool boundary) const
+{
+ pos_type cursor_vpos = 0;
+ float x;
+ float fill_separator;
+ float fill_hfill;
+ float fill_label_hfill;
+ // This call HAS to be here because of the BidiTables!!!
+ prepareToPrint(bview, row, x, fill_separator, fill_hfill,
+ fill_label_hfill);
+
if (last < row->pos())
cursor_vpos = row->pos();
else if (pos > last && !boundary)
main_body = 0;
for (pos_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
+ pos_type pos = vis2log(vpos);
if (main_body > 0 && pos == main_body - 1) {
x += fill_label_hfill +
lyxfont::width(textclasslist[
} else
x += singleWidth(bview, row->par(), pos);
}
-
- cur.x(int(x));
- cur.x_fix(cur.x());
+ return x;
}
cur.par(row->par());
cur.pos(row->pos() + column);
cur.x(x);
+ cur.ix(x);
cur.y(y + row->baseline());
Inset * ins;
if (row->next() && cur.pos() &&