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();