// check needed to survive LyX startup
if (bv_->getLyXText()) {
- bv_->getLyXText()->redoCursor();
-
// update all 'visible' paragraphs
ParagraphList::iterator beg;
ParagraphList::iterator end;
top_y(), top_y() + workarea().workHeight(),
beg, end);
bv_->text->redoParagraphs(beg, end);
-
+ bv_->getLyXText()->redoCursor();
updateScrollbar();
}
screen().redraw(*bv_);
cmd2.x -= inset->x();
cmd2.y -= inset->y();
res = inset->dispatch(cmd2);
- if (res.update())
+ if (res.update()) {
bv_->update();
+ bv_->cursor().updatePos();
+ }
res.update(false);
switch (res.val()) {
case FINISHED:
theTempCursor.pop();
bv_->cursor() = theTempCursor;
bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
+ bv_->cursor().updatePos();
bv_->fitCursor();
return true;
default:
lyxerr << "dispatching " << cmd1
<< " to surrounding LyXText "
<< bv_->cursor().innerText() << endl;
- cursor_ = theTempCursor;
+ bv_->cursor() = theTempCursor;
theTempCursor.dispatch(cmd1);
+ bv_->update();
+ bv_->cursor().updatePos();
//return DispatchResult(true, true);
}
-
- bv_->update();
// see workAreaKeyPress
cursor_timeout.restart();
screen().showCursor(*bv_);
+2003-11-11 Alfredo Braunstein <abraunst@lyx.org>
+
+ * cursor.[Ch] (updatePos): new function for updating the y
+ position of the tip inset
+ * bufferview_funcs.C (put_selection_at):
+ * BufferView_pimpl.C (workAreaDispatch): rationalise update calls
2003-11-11 André Pönitz <poenitz@gmx.net>
#include "buffer.h"
#include "bufferparams.h"
#include "BufferView.h"
+#include "cursor.h"
#include "gettext.h"
#include "language.h"
#include "LColor.h"
}
+/*
+if the fitCursor call refers to some point in never-explored-land, then we
+don't have y information in insets there, then we cannot even do an update
+to get it (because we need the y infomation for setting top_y first). So
+this is solved in put_selection_at with:
+
+- setting top_y to the y of the outerPar (that has good info)
+- calling update
+- calling cursor().updatePos()
+- then call fitCursor()
+
+Ab.
+*/
+
void put_selection_at(BufferView * bv, PosIterator const & cur,
int length, bool backwards)
{
LyXText * text = par.text(bv);
par.lockPath(bv);
-
+ //hack for the chicken and egg problem
+ if (par.inset())
+ bv->top_y(par.outerPar()->y);
+ bv->update();
text->setCursor(cur.pit(), cur.pos());
+ bv->cursor().updatePos();
if (length) {
text->setSelectionRange(length);
if (backwards)
text->cursor = text->selection.start;
}
-
+
bv->fitCursor();
bv->update();
}
{
lyxerr << "LCursor::push() inset: " << inset << endl;
data_.push_back(CursorItem(inset));
- cached_y_ = bv_->top_y() + inset->y();
+ cached_y_ = bv_->top_y() + innerInset()->y();
}
}
+void LCursor::updatePos()
+{
+ if (!data_.empty())
+ cached_y_ = bv_->top_y() + innerInset()->y();
+}
+
+
void LCursor::getPos(int & x, int & y) const
{
if (data_.empty()) {
LyXText * innerText() const;
/// returns x,y position
void getPos(int & x, int & y) const;
+ /// cache the absolute coordinate from the top inset
+ void updatePos();
///
friend std::ostream & operator<<(std::ostream &, LCursor const &);
public:
DispatchResult(bool dis)
: dispatched_(dis), update_(false), val_(NONE) {}
DispatchResult(bool dis, bool update)
- : dispatched_(dis), update_(true), val_(NONE) {}
+ : dispatched_(dis), update_(update), val_(NONE) {}
DispatchResult(bool dis, dispatch_result_t val)
- : dispatched_(dis), update_(false), val_(val) {}
+ : dispatched_(dis), update_(true), val_(val) {}
dispatch_result_t val() const { return val_; }
void val(dispatch_result_t drt) {
val_ = drt;
+2003-11-11 Alfredo Braunstein <abraunst@lyx.org>
+
+ * insettext.C: remove all update calls
+ * insetcollapsable.C: remove all update calls
+
2003-11-11 Alfredo Braunstein <abraunst@libero.it>
* insettext.C (updateLocal, insertInset, setFont): remove
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
collapsed_ = false;
edit(bv, true);
- bv->buffer()->markDirty();
- bv->update();
return DispatchResult(true, true);
}
if (!collapsed_) {
collapsed_ = true;
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
- bv->update();
return DispatchResult(false, FINISHED_RIGHT);
}
collapsed_ = false;
- bv->update();
- bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
} else if (!collapsed_ && cmd.y > button_dim.y2) {
lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
collapsed_ = false;
// set this only here as it should be recollapsed only if
// it was already collapsed!
- bv->update();
- bv->buffer()->markDirty();
inset.edit(bv, x, y);
} else {
if (y <= button_dim.y2)
return;
collapsed_ = false;
- bv->update();
}
return;
collapsed_ = true;
- bv->update();
}
text_.selection.cursor = text_.cursor;
// bv->fitCursor();
- bv->update();
bv->owner()->view_state_changed();
bv->owner()->updateMenubar();
bv->owner()->updateToolbar();
for (--beg; beg != begpar && beg->y > ystart; --beg)
;
- for (end = beg ; end != endpar && end->y < yend; ++end)
+ for (end = beg ; end != endpar && end->y <= yend; ++end)
;
}