int const width = inset.width(bv_, font);
int const inset_x = font.isVisibleRightToLeft()
- ? (cursor.x() - width) : cursor.x();
+ ? (cursor.ix() - width) : cursor.ix();
return Box(
inset_x + inset.scroll(),
inset_x + width,
- cursor.y() - inset.ascent(bv_, font),
- cursor.y() + inset.descent(bv_, font));
+ cursor.iy() - inset.ascent(bv_, font),
+ cursor.iy() + inset.descent(bv_, font));
}
int y = text->first_y;
Row * cursorrow = text->cursor.row();
- text->setCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
+ text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y);
finishUndo();
// This is to allow jumping over large insets
if ((cursorrow == text->cursor.row()))
text->cursorUp(bv_);
- if (text->inset_owner ||
- text->cursor.row()->height() < workarea_.height())
- screen_->draw(bv_->text, bv_,
+ if (text->inset_owner) {
+ int new_y = bv_->text->cursor.iy()
+ + bv_->theLockingInset()->insetInInsetY()
+ + y
+ + text->cursor.row()->height()
+ - workarea_.height() + 1;
+
+ screen_->draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
+ } else if (text->cursor.row()->height() < workarea_.height()) {
+ screen_->draw(text, bv_,
text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
- workarea_.height() + 1);
+ }
updateScrollbar();
}
return;
int y = text->first_y + workarea_.height();
-// if (text->inset_owner)
-// y += bv_->text->first;
+ if (text->inset_owner && !text->first_y) {
+ y -= (bv_->text->cursor.iy()
+ - bv_->text->first_y
+ + bv_->theLockingInset()->insetInInsetY());
+ }
text->getRowNearY(y);
Row * cursorrow = text->cursor.row();
if ((cursorrow == bv_->text->cursor.row()))
text->cursorDown(bv_);
- if (text->inset_owner ||
- text->cursor.row()->height() < workarea_.height())
- screen_->draw(bv_->text, bv_, text->cursor.y() -
+ if (text->inset_owner) {
+ screen_->draw(bv_->text, bv_,
+ bv_->text->cursor.iy()
+ + bv_->theLockingInset()->insetInInsetY()
+ + y - text->cursor.row()->baseline());
+ } else if (text->cursor.row()->height() < workarea_.height()) {
+ screen_->draw(text, bv_, text->cursor.y() -
text->cursor.row()->baseline());
+ }
updateScrollbar();
}
+2002-04-16 Juergen Vigna <jug@sad.it>
+
+ * text2.C (setCursor): set also the irow().
+ (setCursorFromCoordinates): fixed to set the (i) cursor values right!
+ (cursorUp):
+ (cursorDown): support for locking an inset if the x_fix value goes
+ inside it. That way I can transverse insets too with cursor up/down.
+
+ * lyxrow.h: added irow helper function same as other (i) functions.
+
+ * BufferView_pimpl.C (cursorPrevious):
+ (cursorNext): fixed for insets!
+
+2002-04-15 Juergen Vigna <jug@sad.it>
+
+ * BufferView_pimpl.C (insetDimensions): use ix/iy values for inset
+ position otherwise it is wrong in some cases.
+
+ * lyxfunc.C (dispatch): fix FINISHED UP/DOWN to handle x position
+ inside the inset before the call.
+
2002-04-16 Angus Leeming <a.leeming@ic.ac.uk>
* buffer.[Ch] (getBibkeyList): make it const.
+2002-04-16 Juergen Vigna <jug@sad.it>
+
+ * insettabular.C (insetButtonPress):
+ (insetUnlock): call a redraw on unlocking the cell inset.
+
+ * insettext.C (insetButtonPress): same as below.
+ (lockInset): new function to set initial values when inset should
+ be locked.
+ (insetButtonPress): use above function.
+ (insetUnlock): don't force a repaint only set the updateStatus. The
+ outside world should repaint if it thinks it should be done!
+
+ * insettabular.C (insetButtonPress): init values if not set as locked
+ as we are locked if someone presses on us and don't call the edit()
+ call of the InsetText to lock it do it as BufferView does it!
+
+ * inset.h (insetInInsetY): make func const and return an int.
+ * insettext.C:
+ * insettabular.C:
+ * insetcollapsable.C: adapt the above changed function.
+
+2002-04-15 Juergen Vigna <jug@sad.it>
+
+ * insettext.C (getCursorPos): return relative position as to be able
+ to give them directly to the edit() call.
+ (edit): we have to set also x_fix as it is not set inside the
+ setCursorFromCoordinates call!
+ (insetMotionNotify): ditto.
+
2002-04-16 Angus Leeming <a.leeming@ic.ac.uk>
* insetbib.C (getKeys): strip leading '\t's from the line too.
virtual UpdatableInset * getFirstLockingInsetOfType(Inset::Code c)
{ return (c == lyxCode()) ? this : 0; }
///
- virtual unsigned int insetInInsetY() { return 0; }
+ virtual int insetInInsetY() const { return 0; }
///
virtual bool updateInsetInInset(BufferView *, Inset *)
{ return false; }
if (!bv->lockInset(this))
return;
if (yp <= button_bottom_y) {
- inset.edit(bv);
+ inset.edit(bv, xp, 0, button);
} else {
LyXFont font(LyXFont::ALL_SANE);
int yy = ascent(bv, font) + yp -
}
-unsigned int InsetCollapsable::insetInInsetY()
+int InsetCollapsable::insetInInsetY() const
{
return inset.insetInInsetY() - (top_baseline - inset.y());
}
///
bool updateInsetInInset(BufferView *, Inset *);
///
- unsigned int insetInInsetY();
+ int insetInInsetY() const;
///
bool insetButtonRelease(BufferView *, int, int, int);
///
if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
the_locking_inset = 0;
+ updateLocal(bv, CELL, false);
}
hideInsetCursor(bv);
oldcell = -1;
}
-unsigned int InsetTabular::insetInInsetY()
+int InsetTabular::insetInInsetY() const
{
if (!the_locking_inset)
return 0;
int const orow = actrow;
hideInsetCursor(bv);
+ if (!locked) {
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+ }
setPos(bv, x, y);
if (actrow != orow)
updateLocal(bv, NONE, false);
return;
} else if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ the_locking_inset = 0;
+ updateLocal(bv, CELL, false);
}
- the_locking_inset = 0;
if (button == 2) {
localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
return;
}
if (inset_hit && bv->theLockingInset()) {
- // only activate the Inset so that no internal inset is hit
- // by this call. It should be only hit by the insetButtonPress call.
- if (activateCellInsetAbs(bv, 0, 0, 0))
- the_locking_inset->insetButtonPress(bv,
- x - inset_x,
- y - inset_y,
- button);
+ if (!bv->lockInset(static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)))) {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ return;
+ }
+ the_locking_inset->insetButtonPress(
+ bv, x - inset_x, y - inset_y, button);
return;
}
showInsetCursor(bv);
///
bool updateInsetInInset(BufferView *, Inset *);
///
- unsigned int insetInInsetY();
+ int insetInInsetY() const;
///
UpdatableInset * getLockingInset() const;
///
lt = getLyXText(bv);
clear = true;
}
- if (!checkAndActivateInset(bv, x, tmp_y, button))
+ if (!checkAndActivateInset(bv, x, tmp_y, button)) {
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent);
+ lt->cursor.x_fix(lt->cursor.x());
+ }
lt->clearSelection();
finishUndo();
// If the inset is empty set the language of the current font to the
if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
the_locking_inset = 0;
+ updateLocal(bv, CURSOR_PAR, false);
}
hideInsetCursor(bv);
no_selection = true;
locked = false;
int code;
+#if 0
if (drawFrame_ == LOCKED)
code = CURSOR|CLEAR_FRAME;
else
code = CURSOR;
+#else
+ if (drawFrame_ == LOCKED)
+ code = CLEAR_FRAME;
+#endif
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
}
if (clear)
lt = 0;
+#if 0
updateLocal(bv, code, false);
+#else
+ setUpdateStatus(bv, code);
+#endif
+}
+
+
+void InsetText::lockInset(BufferView * bv)
+{
+ locked = true;
+ the_locking_inset = 0;
+ inset_pos = inset_x = inset_y = 0;
+ inset_boundary = false;
+ inset_par = 0;
+ old_par = 0;
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ lt->setCursor(bv, par, 0);
+ lt->clearSelection();
+ finishUndo();
+ // If the inset is empty set the language of the current font to the
+ // language to the surronding text (if different).
+ if (par->size() == 0 && !par->next() &&
+ bv->getParentLanguage(this) != lt->current_font.language()) {
+ LyXFont font(LyXFont::ALL_IGNORE);
+ font.setLanguage(bv->getParentLanguage(this));
+ setFont(bv, font, false);
+ }
+ if (clear)
+ lt = 0;
+ int code = CURSOR;
+ if (drawFrame_ == LOCKED)
+ code = CURSOR|DRAW_FRAME;
+ setUpdateStatus(bv, code);
}
+
void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
{
the_locking_inset = inset;
mouse_x = x;
mouse_y = y;
+ if (!locked)
+ lockInset(bv);
+
int tmp_x = x - drawTextXOffset;
int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
hideInsetCursor(bv);
LyXCursor cur = lt->cursor;
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
+ lt->cursor.x_fix(lt->cursor.x());
if (cur == lt->cursor) {
if (clear)
lt = 0;
}
-void InsetText::getCursorPos(BufferView * bv,
- int & x, int & y) const
+void InsetText::getCursorPos(BufferView * bv, int & x, int & y) const
{
if (the_locking_inset) {
the_locking_inset->getCursorPos(bv, x, y);
return;
}
- x = cx(bv);
- y = cy(bv);
+ x = cx(bv) - top_x - TEXT_TO_INSET_OFFSET;
+ y = cy(bv) - TEXT_TO_INSET_OFFSET;
}
-unsigned int InsetText::insetInInsetY()
+int InsetText::insetInInsetY() const
{
if (!the_locking_inset)
return 0;
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
- bv->fitLockedInsetCursor(cx(bv), ciy(bv), asc, desc);
+ bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
if (show)
bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
setCursorVisible(true);
///
void getCursorPos(BufferView *, int & x, int & y) const;
///
- unsigned int insetInInsetY();
+ int insetInInsetY() const;
///
void toggleInsetCursor(BufferView *);
///
protected:
///
void updateLocal(BufferView *, int what, bool mark_dirty) const;
- ///
+ /// set parameters for an initial lock of this inset
+ void lockInset(BufferView *);
+ /// lock an inset inside this one
void lockInset(BufferView *, UpdatableInset *);
///
mutable int drawTextXOffset;
{
return row_;
}
+
+
+void LyXCursor::irow(Row * r)
+{
+ irow_ = r;
+}
+
+
+Row * LyXCursor::irow() const
+{
+ return irow_;
+}
void row(Row * r);
///
Row * row() const;
+ ///
+ void irow(Row * r);
+ ///
+ Row * irow() const;
private:
/// The paragraph the cursor is in.
Paragraph * par_;
int iy_;
///
Row * row_;
+ /// the row of the position before the inset when we put
+ /// the cursor on the end of the row before, otherwise equal to row.
+ Row * irow_;
};
///
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
(!keyseq.deleted())))
{
+ UpdatableInset * inset = owner->view()->theLockingInset();
+#if 1
+ int inset_x;
+ int dummy_y;
+ inset->getCursorPos(owner->view(), inset_x, dummy_y);
+#endif
if ((action == LFUN_UNKNOWN_ACTION)
&& argument.empty()) {
argument = keyseq.getiso();
} else if (action == LFUN_REDO) {
owner->view()->menuRedo();
goto exit_with_message;
- } else if (((result=owner->view()->theLockingInset()->
+ } else if (((result=inset->
// Hand-over to inset's own dispatch:
localDispatch(owner->view(), action, argument)) ==
UpdatableInset::DISPATCHED) ||
}
goto exit_with_message;
} else if (result == UpdatableInset::FINISHED_UP) {
- if (TEXT()->cursor.row()->previous()) {
+ if (TEXT()->cursor.irow()->previous()) {
+#if 1
+ TEXT()->setCursorFromCoordinates(
+ owner->view(), TEXT()->cursor.ix() + inset_x,
+ TEXT()->cursor.iy() -
+ TEXT()->cursor.irow()->baseline() - 1);
+ TEXT()->cursor.x_fix(TEXT()->cursor.x());
+#else
TEXT()->cursorUp(owner->view());
+#endif
moveCursorUpdate(true, false);
owner->showState();
} else {
}
goto exit_with_message;
} else if (result == UpdatableInset::FINISHED_DOWN) {
- if (TEXT()->cursor.row()->next())
+ if (TEXT()->cursor.irow()->next()) {
+#if 1
+ TEXT()->setCursorFromCoordinates(
+ owner->view(), TEXT()->cursor.ix() + inset_x,
+ TEXT()->cursor.iy() -
+ TEXT()->cursor.irow()->baseline() +
+ TEXT()->cursor.irow()->height() + 1);
+ TEXT()->cursor.x_fix(TEXT()->cursor.x());
+#else
TEXT()->cursorDown(owner->view());
- else
+#endif
+ } else {
TEXT()->cursorRight(owner->view());
+ }
moveCursorUpdate(true, false);
owner->showState();
goto exit_with_message;
int y = 0;
Row * row = getRow(par, pos, y);
Row * old_row = row;
+ cur.irow(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.par(row->par());
cur.pos(row->pos() + column);
cur.x(x);
- cur.ix(x);
cur.y(y + row->baseline());
+ cur.row(row);
Inset * ins;
- if (row->next() && cur.pos() &&
+ if (row->next() && row->next()->pos() == cur.pos() &&
+ cur.par() == row->next()->par() &&
cur.par()->getChar(cur.pos()) == Paragraph::META_INSET &&
(ins=cur.par()->getInset(cur.pos())) &&
(ins->needFullRow() || ins->display()))
{
+ // we enter here if we put the cursor on the end of the row before
+ // a inset which uses a full row and in that case we HAVE to calculate
+ // the right (i) values.
+ pos_type last = rowLastPrintable(row);
+ float x = getCursorX(bview, row->next(), cur.pos(), last, bound);
+ cur.ix(int(x));
cur.iy(y + row->height() + row->next()->baseline());
+ cur.irow(row->next());
} else {
cur.iy(cur.y());
+ cur.ix(cur.x());
+ cur.irow(row);
}
- cur.row(row);
cur.boundary(bound);
}
void LyXText::cursorUp(BufferView * bview) const
{
+#if 1
+ int x = cursor.x_fix();
+ int y = cursor.y() - cursor.row()->baseline() - 1;
+ setCursorFromCoordinates(bview, x, y);
+ int y1 = cursor.iy() - first_y;
+ int y2 = y1;
+ Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+ if (inset_hit && isHighlyEditableInset(inset_hit)) {
+ inset_hit->edit(bview, x, y - (y2 - y1), 0);
+ }
+#else
setCursorFromCoordinates(bview, cursor.x_fix(),
cursor.y() - cursor.row()->baseline() - 1);
+#endif
}
void LyXText::cursorDown(BufferView * bview) const
{
+#if 1
+ int x = cursor.x_fix();
+ int y = cursor.y() - cursor.row()->baseline() +
+ cursor.row()->height() + 1;
+ setCursorFromCoordinates(bview, x, y);
+ int y1 = cursor.iy() - first_y;
+ int y2 = y1;
+ Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+ if (inset_hit && isHighlyEditableInset(inset_hit)) {
+ inset_hit->edit(bview, x, y - (y2 - y1), 0);
+ }
+#else
setCursorFromCoordinates(bview, cursor.x_fix(),
cursor.y() - cursor.row()->baseline()
+ cursor.row()->height() + 1);
+#endif
}