Fixes to various bug-reports.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2402 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-08-01 15:42:53 +00:00
parent 25433c309d
commit cc3955aa12
17 changed files with 264 additions and 112 deletions

View File

@ -265,7 +265,7 @@ void BufferView::copyEnvironment()
text->copyEnvironmentType(); text->copyEnvironmentType();
// clear the selection, even if mark_set // clear the selection, even if mark_set
toggleSelection(); toggleSelection();
text->clearSelection(this); text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
owner()->message(_("Paragraph environment type copied")); owner()->message(_("Paragraph environment type copied"));
} }
@ -288,7 +288,7 @@ void BufferView::copy()
text->copySelection(this); text->copySelection(this);
// clear the selection, even if mark_set // clear the selection, even if mark_set
toggleSelection(); toggleSelection();
text->clearSelection(this); text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
owner()->message(_("Copy")); owner()->message(_("Copy"));
} }
@ -316,7 +316,7 @@ void BufferView::paste()
hideCursor(); hideCursor();
// clear the selection // clear the selection
toggleSelection(); toggleSelection();
text->clearSelection(this); text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
// paste // paste
@ -325,7 +325,7 @@ void BufferView::paste()
// clear the selection // clear the selection
toggleSelection(); toggleSelection();
text->clearSelection(this); text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
} }
@ -361,7 +361,7 @@ void BufferView::endOfSpellCheck()
hideCursor(); hideCursor();
beforeChange(text); beforeChange(text);
text->selectSelectedWord(this); text->selectSelectedWord(this);
text->clearSelection(this); text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR); update(text, BufferView::SELECT|BufferView::FITCUR);
} }

View File

@ -559,7 +559,11 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
bv_->text->setSelection(bv_); bv_->text->setSelection(bv_);
screen_->toggleToggle(bv_->text, bv_); screen_->toggleToggle(bv_->text, bv_);
fitCursor(bv_->text); fitCursor(bv_->text);
#if 0
screen_->showCursor(bv_->text, bv_); screen_->showCursor(bv_->text, bv_);
#else
showCursor();
#endif
} }
@ -615,7 +619,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
// Clear the selection // Clear the selection
screen_->toggleSelection(bv_->text, bv_); screen_->toggleSelection(bv_->text, bv_);
bv_->text->clearSelection(bv_); bv_->text->clearSelection();
bv_->text->fullRebreak(bv_); bv_->text->fullRebreak(bv_);
screen_->update(bv_->text, bv_); screen_->update(bv_->text, bv_);
updateScrollbar(); updateScrollbar();
@ -1126,7 +1130,7 @@ bool BufferView::Pimpl::available() const
void BufferView::Pimpl::beforeChange(LyXText * text) void BufferView::Pimpl::beforeChange(LyXText * text)
{ {
toggleSelection(); toggleSelection();
text->clearSelection(bv_); text->clearSelection();
} }
@ -3373,7 +3377,7 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
} }
} else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) { } else if (bv_->theLockingInset()->updateInsetInInset(bv_, inset)) {
if (bv_->text->updateInset(bv_, if (bv_->text->updateInset(bv_,
bv_->theLockingInset())) { bv_->theLockingInset())) {
update(); update();
if (mark_dirty){ if (mark_dirty){
buffer_->markDirty(); buffer_->markDirty();

View File

@ -1,3 +1,15 @@
2001-08-01 Juergen Vigna <jug@sad.it>
* lyxfind.C (LyXFind): fixed
(SearchForward): ditto
(SearchBackward): ditto
* BufferView_pimpl.C (workAreaMotionNotify): hopefully fixed the
spurius drawing of the cursor in the main area.
* text2.C (status): small fix which could lead to a segfault!
(clearSelection): remove unneeded BufferView param.
2001-08-01 André Pönitz <poenitz@gmx.net> 2001-08-01 André Pönitz <poenitz@gmx.net>
* lyxfunc.C: small change due to changed mathed interface * lyxfunc.C: small change due to changed mathed interface

View File

@ -1,3 +1,21 @@
2001-08-01 Juergen Vigna <jug@sad.it>
* insetcollapsable.C (update): added an in_update bool so we avoid
reentering.
* insettabular.C (update): added an in_update bool so we avoid
reentering.
* insettext.C (insetButtonPress): hopefully fixed setselection/clear
selection problem.
(update): added an in_update bool so we avoid reentering.
* insettabular.C (localDispatch): clear col/row selection when doing
something else inside an inset.
* insettext.C (getLyXText): fixed bug when requesting a recursive
insettext!
2001-08-01 Angus Leeming <a.leeming@ic.ac.uk> 2001-08-01 Angus Leeming <a.leeming@ic.ac.uk>
* insetcite.C (latex): Paranoia check. Make sure that there is no * insetcite.C (latex): Paranoia check. Make sure that there is no
@ -5,6 +23,9 @@
2001-07-31 Juergen Vigna <jug@sad.it> 2001-07-31 Juergen Vigna <jug@sad.it>
* inset.h (nodraw): make the set function also const so that this
can be called from inside other const functions.
* insetcollapsable.h: removed inline variable and moved it over * insetcollapsable.h: removed inline variable and moved it over
to the only user InsetERT. to the only user InsetERT.

View File

@ -135,6 +135,9 @@ void Inset::id(int id_arg)
id_ = id_arg; id_ = id_arg;
} }
void Inset::setFont(BufferView *, LyXFont const &, bool, bool )
{}
// some stuff for inset locking // some stuff for inset locking
UpdatableInset::UpdatableInset() UpdatableInset::UpdatableInset()
@ -222,10 +225,6 @@ void UpdatableInset::draw(BufferView *, LyXFont const &,
} }
void UpdatableInset::setFont(BufferView *, LyXFont const &, bool, bool )
{}
void UpdatableInset::scroll(BufferView * bv, float s) const void UpdatableInset::scroll(BufferView * bv, float s) const
{ {
LyXFont font; LyXFont font;

View File

@ -284,6 +284,9 @@ public:
/// check if the font of the char we want inserting is correct /// check if the font of the char we want inserting is correct
/// and modify it if it is not. /// and modify it if it is not.
virtual bool checkInsertChar(LyXFont &); virtual bool checkInsertChar(LyXFont &);
/// we need this here because collapsed insets are only EDITABLE
virtual void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
protected: protected:
/// ///
mutable int top_x; mutable int top_x;
@ -409,9 +412,6 @@ public:
virtual void draw(BufferView *, LyXFont const &, virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x, bool cleared) const; int baseline, float & x, bool cleared) const;
/// ///
virtual void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
///
virtual bool insertInset(BufferView *, Inset *) { return false; } virtual bool insertInset(BufferView *, Inset *) { return false; }
/// ///
virtual UpdatableInset * getLockingInset() const { virtual UpdatableInset * getLockingInset() const {
@ -446,7 +446,7 @@ public:
/// ///
virtual bool showInsetDialog(BufferView *) const { return false; } virtual bool showInsetDialog(BufferView *) const { return false; }
/// ///
virtual void nodraw(bool b) { virtual void nodraw(bool b) const {
block_drawing_ = b; block_drawing_ = b;
} }
/// ///
@ -490,6 +490,6 @@ private:
/// ///
mutable bool cursor_visible_; mutable bool cursor_visible_;
/// ///
bool block_drawing_; mutable bool block_drawing_;
}; };
#endif #endif

View File

@ -37,11 +37,11 @@ using std::max;
InsetCollapsable::InsetCollapsable(bool collapsed) InsetCollapsable::InsetCollapsable(bool collapsed)
: UpdatableInset(), collapsed_(collapsed), : UpdatableInset(), collapsed_(collapsed),
button_length(0), button_top_y(0), button_bottom_y(0), button_length(0), button_top_y(0), button_bottom_y(0),
need_update(FULL), label("Label"), need_update(NONE), label("Label"),
#if 0 #if 0
autocollapse(false), autocollapse(false),
#endif #endif
oldWidth(0) oldWidth(0), in_update(false)
{ {
inset.setOwner(this); inset.setOwner(this);
inset.setAutoBreakRows(true); inset.setAutoBreakRows(true);
@ -55,11 +55,11 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
: UpdatableInset(in, same_id), collapsed_(in.collapsed_), : UpdatableInset(in, same_id), collapsed_(in.collapsed_),
framecolor(in.framecolor), labelfont(in.labelfont), framecolor(in.framecolor), labelfont(in.labelfont),
button_length(0), button_top_y(0), button_bottom_y(0), button_length(0), button_top_y(0), button_bottom_y(0),
need_update(FULL), label(in.label), need_update(NONE), label(in.label),
#if 0 #if 0
autocollapse(in.autocollapse), autocollapse(in.autocollapse),
#endif #endif
oldWidth(0) oldWidth(0), in_update(false)
{ {
inset.init(&(in.inset), same_id); inset.init(&(in.inset), same_id);
inset.setOwner(this); inset.setOwner(this);
@ -177,6 +177,12 @@ void InsetCollapsable::draw_collapsed(Painter & pain,
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const int baseline, float & x, bool cleared) const
{ {
if (need_update != NONE) {
const_cast<InsetText *>(&inset)->update(bv, f, true);
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
need_update = NONE;
return;
}
if (nodraw()) if (nodraw())
return; return;
@ -219,7 +225,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
inset.draw(bv, f, inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f), bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared); x, cleared);
need_update = NONE;
} }
@ -382,9 +387,16 @@ int InsetCollapsable::getMaxWidth(BufferView * bv,
void InsetCollapsable::update(BufferView * bv, LyXFont const & font, void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
bool reinit) bool reinit)
{ {
if (in_update)
return;
in_update = true;
inset.update(bv, font, reinit); inset.update(bv, font, reinit);
if (reinit && owner()) {
owner()->update(bv, font, true);
}
in_update = false;
} }

View File

@ -237,6 +237,8 @@ private:
#endif #endif
/// ///
mutable int oldWidth; mutable int oldWidth;
///
bool in_update;
}; };
#endif #endif

View File

@ -263,7 +263,10 @@ InsetMinipage::Position InsetMinipage::pos() const
void InsetMinipage::pos(InsetMinipage::Position p) void InsetMinipage::pos(InsetMinipage::Position p)
{ {
pos_ = p; if (pos_ != p) {
pos_ = p;
need_update = FULL;
}
} }
@ -287,7 +290,10 @@ string const & InsetMinipage::height() const
void InsetMinipage::height(string const & ll) void InsetMinipage::height(string const & ll)
{ {
height_ = ll; if (height_ != ll) {
height_ = ll;
need_update = FULL;
}
} }
@ -299,7 +305,10 @@ string const & InsetMinipage::width() const
void InsetMinipage::width(string const & ll) void InsetMinipage::width(string const & ll)
{ {
width_ = ll; if (ll != width_) {
width_ = ll;
need_update = FULL;
}
} }

View File

@ -138,6 +138,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
actrow = actcell = 0; actrow = actcell = 0;
clearSelection(); clearSelection();
need_update = INIT; need_update = INIT;
in_update = false;
} }
@ -152,6 +153,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
actrow = actcell = 0; actrow = actcell = 0;
sel_cell_start = sel_cell_end = 0; sel_cell_start = sel_cell_end = 0;
need_update = INIT; need_update = INIT;
in_update = false;
} }
@ -457,11 +459,15 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit) void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
{ {
if (in_update)
return;
in_update = true;
if (reinit) { if (reinit) {
need_update = INIT; need_update = INIT;
calculate_dimensions_of_cells(bv, font, true); calculate_dimensions_of_cells(bv, font, true);
if (owner()) if (owner())
owner()->update(bv, font, true); owner()->update(bv, font, true);
in_update = false;
return; return;
} }
if (the_locking_inset) if (the_locking_inset)
@ -485,6 +491,7 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
default: default:
break; break;
} }
in_update = false;
} }
@ -793,9 +800,8 @@ void InsetTabular::insetKeyPress(XKeyEvent * xke)
UpdatableInset::RESULT UpdatableInset::RESULT
InsetTabular::localDispatch(BufferView * bv, InsetTabular::localDispatch(BufferView * bv, kb_action action,
kb_action action, string const & arg)
string const & arg)
{ {
// We need to save the value of the_locking_inset as the call to // We need to save the value of the_locking_inset as the call to
// the_locking_inset->LocalDispatch might unlock it. // the_locking_inset->LocalDispatch might unlock it.
@ -814,34 +820,33 @@ InsetTabular::localDispatch(BufferView * bv,
bool hs = hasSelection(); bool hs = hasSelection();
result = DISPATCHED; result = DISPATCHED;
// this one have priority over the locked InsetText! // this one have priority over the locked InsetText, if we're not already
switch (action) { // inside another tabular then that one get's priority!
case LFUN_SHIFT_TAB: if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
case LFUN_TAB: switch (action) {
{ case LFUN_SHIFT_TAB:
if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) != this) case LFUN_TAB:
hideInsetCursor(bv);
if (the_locking_inset) {
unlockInsetInInset(bv, the_locking_inset);
the_locking_inset = 0;
}
if (action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0);
else
movePrevCell(bv, old_locking_inset != 0);
sel_cell_start = sel_cell_end = actcell;
if (hs)
updateLocal(bv, SELECTION, false);
if (!the_locking_inset) {
showInsetCursor(bv);
return DISPATCHED_NOUPDATE;
}
return result;
// this to avoid compiler warnings.
default:
break; break;
hideInsetCursor(bv);
if (the_locking_inset) {
unlockInsetInInset(bv, the_locking_inset);
the_locking_inset = 0;
} }
if (action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0);
else
movePrevCell(bv, old_locking_inset != 0);
sel_cell_start = sel_cell_end = actcell;
if (hs)
updateLocal(bv, SELECTION, false);
if (!the_locking_inset) {
showInsetCursor(bv);
return DISPATCHED_NOUPDATE;
}
return result;
}
// this to avoid compiler warnings.
default:
break;
} }
if (the_locking_inset) { if (the_locking_inset) {
@ -860,7 +865,6 @@ InsetTabular::localDispatch(BufferView * bv,
updateLocal(bv, CELL, false); updateLocal(bv, CELL, false);
the_locking_inset->toggleInsetCursor(bv); the_locking_inset->toggleInsetCursor(bv);
return result; return result;
} else if (result == FINISHED) {
} }
} }
@ -1095,11 +1099,11 @@ InsetTabular::localDispatch(BufferView * bv,
// we need to update if this was requested before // we need to update if this was requested before
updateLocal(bv, NONE, false); updateLocal(bv, NONE, false);
return UNDISPATCHED; return UNDISPATCHED;
} else if (hs) {
clearSelection();
} }
nodraw(false); nodraw(false);
// the_locking_inset->ToggleInsetCursor(bv);
updateLocal(bv, CELL, false); updateLocal(bv, CELL, false);
// the_locking_inset->ToggleInsetCursor(bv);
return result; return result;
} }
break; break;
@ -1247,8 +1251,20 @@ void InsetTabular::hideInsetCursor(BufferView * bv)
bv->hideLockedInsetCursor(); bv->hideLockedInsetCursor();
setCursorVisible(false); setCursorVisible(false);
} }
// if (cursor_visible) }
// ToggleInsetCursor(bv);
void InsetTabular::fitInsetCursor(BufferView * bv) const
{
if (the_locking_inset) {
the_locking_inset->fitInsetCursor(bv);
return;
}
LyXFont font;
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
} }
@ -2471,12 +2487,13 @@ string const InsetTabular::selectNextWord(BufferView * bv, float & value) const
} }
++actcell; ++actcell;
} }
nodraw(true);
// otherwise we have to lock the next inset and ask for it's selecttion // otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)); static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
inset->edit(bv, 0, 0, 0); inset->edit(bv, 0, 0, 0);
string const str(selectNextWordInt(bv, value)); string const str(selectNextWordInt(bv, value));
nodraw(false);
if (!str.empty()) if (!str.empty())
resetPos(bv); resetPos(bv);
return str; return str;
@ -2524,7 +2541,7 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
bool InsetTabular::searchForward(BufferView * bv, string const & str, bool InsetTabular::searchForward(BufferView * bv, string const & str,
bool const & cs, bool const & mw) bool const & cs, bool const & mw)
{ {
if (the_locking_inset) { if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw)) if (the_locking_inset->searchForward(bv, str, cs, mw))
@ -2535,16 +2552,18 @@ bool InsetTabular::searchForward(BufferView * bv, string const & str,
} }
++actcell; ++actcell;
} }
nodraw(true);
// otherwise we have to lock the next inset and search there // otherwise we have to lock the next inset and search there
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)); static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
inset->edit(bv); inset->edit(bv);
#if 0
bool const res = searchForward(bv, str, cs, mw); bool const res = searchForward(bv, str, cs, mw);
updateLocal(bv, NONE, false); updateLocal(bv, NONE, false);
nodraw(false);
bv->updateInset(const_cast<InsetTabular *>(this), false); bv->updateInset(const_cast<InsetTabular *>(this), false);
return res; return res;
#else
return searchForward(bv, str, cs, mw);
#endif
} }
@ -2560,13 +2579,15 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str,
} }
--actcell; --actcell;
} }
nodraw(true);
// otherwise we have to lock the next inset and search there // otherwise we have to lock the next inset and search there
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)); static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
inset->edit(bv, false); inset->edit(bv, false);
#if 0
bool const res = searchBackward(bv, str, cs, mw); bool const res = searchBackward(bv, str, cs, mw);
nodraw(false);
bv->updateInset(const_cast<InsetTabular *>(this), false); bv->updateInset(const_cast<InsetTabular *>(this), false);
return res; return res;
#else
return searchBackward(bv, str, cs, mw);
#endif
} }

View File

@ -189,7 +189,7 @@ public:
/// ///
std::vector<string> const getLabelList() const; std::vector<string> const getLabelList() const;
/// ///
void nodraw(bool b) { void nodraw(bool b) const {
UpdatableInset::nodraw(b); UpdatableInset::nodraw(b);
} }
bool nodraw() const; bool nodraw() const;
@ -243,6 +243,8 @@ private:
/// ///
void hideInsetCursor(BufferView *); void hideInsetCursor(BufferView *);
/// ///
void fitInsetCursor(BufferView *) const;
///
void setPos(BufferView *, int x, int y) const; void setPos(BufferView *, int x, int y) const;
/// ///
UpdatableInset::RESULT moveRight(BufferView *, bool lock = true); UpdatableInset::RESULT moveRight(BufferView *, bool lock = true);
@ -333,5 +335,7 @@ private:
mutable bool locked; mutable bool locked;
/// ///
mutable UpdateCodes need_update; mutable UpdateCodes need_update;
///
bool in_update;
}; };
#endif #endif

View File

@ -117,6 +117,7 @@ InsetText::InsetText()
{ {
par = new Paragraph; par = new Paragraph;
init(); init();
in_update = false;
} }
@ -125,6 +126,7 @@ InsetText::InsetText(InsetText const & ins, bool same_id)
{ {
par = 0; par = 0;
init(&ins, same_id); init(&ins, same_id);
in_update = false;
autoBreakRows = ins.autoBreakRows; autoBreakRows = ins.autoBreakRows;
} }
@ -415,7 +417,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
} else if (!locked) { } else if (!locked) {
if (need_update & CURSOR) { if (need_update & CURSOR) {
bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection(bv); lt->clearSelection();
lt->selection.cursor = lt->cursor; lt->selection.cursor = lt->cursor;
} }
bv->screen()->update(lt, bv, y_offset, int(x)); bv->screen()->update(lt, bv, y_offset, int(x));
@ -425,7 +427,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
bv->screen()->toggleToggle(lt, bv, y_offset, int(x)); bv->screen()->toggleToggle(lt, bv, y_offset, int(x));
else if (need_update & CURSOR) { else if (need_update & CURSOR) {
bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection(bv); lt->clearSelection();
lt->selection.cursor = lt->cursor; lt->selection.cursor = lt->cursor;
} }
bv->screen()->update(lt, bv, y_offset, int(x)); bv->screen()->update(lt, bv, y_offset, int(x));
@ -477,11 +479,15 @@ void InsetText::clearFrame(Painter & pain, bool cleared) const
void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
{ {
if (in_update)
return;
in_update = true;
if (reinit) { if (reinit) {
need_update |= INIT; need_update |= INIT;
resizeLyXText(bv); resizeLyXText(bv);
if (owner()) if (owner())
owner()->update(bv, font, true); owner()->update(bv, font, true);
in_update = false;
return; return;
} }
if (the_locking_inset) { if (the_locking_inset) {
@ -502,6 +508,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
need_update |= FULL; need_update |= FULL;
if (clear) if (clear)
lt = 0; lt = 0;
in_update = false;
return; return;
} }
if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) && if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) &&
@ -513,6 +520,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
need_update |= FULL; need_update |= FULL;
if (clear) if (clear)
lt = 0; lt = 0;
in_update = false;
} }
@ -530,8 +538,11 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const
need_update |= CURSOR_PAR; need_update |= CURSOR_PAR;
// this to not draw a selection when we redraw all of it! // this to not draw a selection when we redraw all of it!
if ((need_update & (INIT|FULL)) && (need_update & CURSOR)) if (need_update & CURSOR) {
lt->clearSelection(bv); if (lt->selection.set())
need_update = FULL;
lt->clearSelection();
}
if (clear) if (clear)
lt = 0; lt = 0;
} }
@ -591,7 +602,7 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
if (!checkAndActivateInset(bv, x, tmp_y, button)) if (!checkAndActivateInset(bv, x, tmp_y, button))
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
y + insetAscent); y + insetAscent);
lt->clearSelection(bv); lt->clearSelection();
finishUndo(); finishUndo();
showInsetCursor(bv); showInsetCursor(bv);
updateLocal(bv, CURSOR, false); updateLocal(bv, CURSOR, false);
@ -636,7 +647,7 @@ void InsetText::edit(BufferView * bv, bool front)
p = p->next(); p = p->next();
lt->setCursor(bv, p, p->size()-1); lt->setCursor(bv, p, p->size()-1);
} }
lt->clearSelection(bv); lt->clearSelection();
finishUndo(); finishUndo();
showInsetCursor(bv); showInsetCursor(bv);
updateLocal(bv, CURSOR, false); updateLocal(bv, CURSOR, false);
@ -674,7 +685,7 @@ void InsetText::insetUnlock(BufferView * bv)
clear = true; clear = true;
} }
if (lt->selection.set()) { if (lt->selection.set()) {
lt->clearSelection(bv); lt->clearSelection();
code = FULL; code = FULL;
} else if (owner()) { } else if (owner()) {
bv->owner()->setLayout(owner()->getLyXText(bv) bv->owner()->setLayout(owner()->getLyXText(bv)
@ -819,8 +830,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
} }
getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset, getLyXText(bv)->setCursorFromCoordinates(bv, x-drawTextXOffset,
y + insetAscent); y + insetAscent);
getLyXText(bv)->clearSelection();
updateLocal(bv, FULL, false);
getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor; getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
updateLocal(bv, CURSOR, false);
bv->owner()->setLayout(cpar(bv)->getLayout()); bv->owner()->setLayout(cpar(bv)->getLayout());
old_par = cpar(bv); old_par = cpar(bv);
// Insert primary selection with middle mouse // Insert primary selection with middle mouse
@ -975,7 +987,7 @@ InsetText::localDispatch(BufferView * bv,
lt->cutSelection(bv, false); lt->cutSelection(bv, false);
} }
} }
lt->clearSelection(bv); lt->clearSelection();
for (string::size_type i = 0; i < arg.length(); ++i) { for (string::size_type i = 0; i < arg.length(); ++i) {
if (greek_kb_flag) { if (greek_kb_flag) {
if (!math_insert_greek(bv, arg[i])) { if (!math_insert_greek(bv, arg[i])) {
@ -1484,9 +1496,11 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset)
clear = true; clear = true;
} }
lt->insertInset(bv, inset); lt->insertInset(bv, inset);
#if 0
if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) || if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) ||
(cpar(bv)->getInset(cpos(bv)) != inset)) (cpar(bv)->getInset(cpos(bv)) != inset))
lt->cursorLeft(bv); lt->cursorLeft(bv);
#endif
bv->fitCursor(lt); bv->fitCursor(lt);
updateLocal(bv, CURSOR_PAR|CURSOR, true); updateLocal(bv, CURSOR_PAR|CURSOR, true);
showInsetCursor(bv); showInsetCursor(bv);
@ -1570,7 +1584,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
lt->setFont(bv, font, toggleall); lt->setFont(bv, font, toggleall);
#endif #endif
if (selectall) if (selectall)
lt->clearSelection(bv); lt->clearSelection();
bv->fitCursor(lt); bv->fitCursor(lt);
if (selectall || lt->selection.set()) if (selectall || lt->selection.set())
updateLocal(bv, FULL, true); updateLocal(bv, FULL, true);
@ -1784,7 +1798,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv,
lyx::Assert(it->second.text.get()); lyx::Assert(it->second.text.get());
cached_text = it->second.text; cached_text = it->second.text;
if (recursive && the_locking_inset) { if (recursive && the_locking_inset) {
return the_locking_inset->getLyXText(bv); return the_locking_inset->getLyXText(bv, true);
} }
return cached_text.get(); return cached_text.get();
} else if (it->second.remove) { } else if (it->second.remove) {
@ -1948,7 +1962,7 @@ void InsetText::selectAll(BufferView * bv)
void InsetText::clearSelection(BufferView * bv) void InsetText::clearSelection(BufferView * bv)
{ {
getLyXText(bv)->clearSelection(bv); getLyXText(bv)->clearSelection();
} }
@ -2127,9 +2141,31 @@ void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
bool InsetText::searchForward(BufferView * bv, string const & str, bool InsetText::searchForward(BufferView * bv, string const & str,
bool const & cs, bool const & mw) bool const & cs, bool const & mw)
{ {
if (the_locking_inset) if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw)) if (the_locking_inset->searchForward(bv, str, cs, mw))
return true; return true;
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
clear = true;
}
Paragraph * lpar = lt->cursor.par();
Paragraph::size_type pos = lt->cursor.pos();
if (pos < lpar->size() - 1)
++pos;
else {
pos = 0;
lpar = lpar->next();
}
if (!lpar) {
if (clear)
lt = 0;
return false;
}
lt->setCursor(bv, lpar, pos);
if (clear)
lt = 0;
}
if (LyXFind(bv, str, true, true, cs , mw)) { if (LyXFind(bv, str, true, true, cs , mw)) {
return true; return true;
} }

View File

@ -394,5 +394,7 @@ private:
mutable int frame_y; mutable int frame_y;
mutable int frame_w; mutable int frame_w;
mutable int frame_h; mutable int frame_h;
///
bool in_update; /* as update is not reentrant! */
}; };
#endif #endif

View File

@ -64,7 +64,7 @@ int LyXReplace(BufferView * bv,
// start at top if replaceall // start at top if replaceall
bool fw = forward; bool fw = forward;
if (replaceall) { if (replaceall) {
text->clearSelection(bv); text->clearSelection();
if (text->inset_owner) { if (text->inset_owner) {
bv->unlockInset(bv->theLockingInset()); bv->unlockInset(bv->theLockingInset());
text = bv->text; text = bv->text;
@ -84,7 +84,7 @@ int LyXReplace(BufferView * bv,
} }
} }
bool found; bool found = false;
int replace_count = 0; int replace_count = 0;
do { do {
bv->hideCursor(); bv->hideCursor();
@ -128,6 +128,26 @@ bool LyXFind(BufferView * bv,
bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd); bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd);
if (found) if (found)
result = SR_FOUND_NOUPDATE; result = SR_FOUND_NOUPDATE;
else {
text = bv->getLyXText();
Paragraph * par = text->cursor.par();
Paragraph::size_type pos = text->cursor.pos();
if (forward) {
if (pos < par->size() - 1)
++pos;
else {
pos = 0;
par = par->next();
}
if (par)
text->setCursor(bv, par, pos);
}
if (par) {
result = forward ?
SearchForward(bv, text, searchstr, casesens, matchwrd) :
SearchBackward(bv, text, searchstr, casesens, matchwrd);
}
}
} else { } else {
result = forward ? result = forward ?
SearchForward(bv, text, searchstr, casesens, matchwrd) : SearchForward(bv, text, searchstr, casesens, matchwrd) :
@ -139,7 +159,7 @@ bool LyXFind(BufferView * bv,
// the actual text pointer could have changed! // the actual text pointer could have changed!
bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR); bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
bv->toggleSelection(); bv->toggleSelection();
bv->getLyXText()->clearSelection(bv); bv->getLyXText()->clearSelection();
bv->getLyXText()->setSelectionOverString(bv, searchstr); bv->getLyXText()->setSelectionOverString(bv, searchstr);
bv->toggleSelection(false); bv->toggleSelection(false);
bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR); bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
@ -220,19 +240,23 @@ SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
// test if we're inside an inset if yes unlock the inset // test if we're inside an inset if yes unlock the inset
// and recall us with the outside LyXText! // and recall us with the outside LyXText!
bv->unlockInset((UpdatableInset *)text->inset_owner); bv->unlockInset((UpdatableInset *)text->inset_owner);
text = bv->getLyXText(); if (!bv->theLockingInset()) {
par = text->cursor.par(); text = bv->getLyXText();
pos = text->cursor.pos(); par = text->cursor.par();
if (pos < par->size() - 1) pos = text->cursor.pos();
++pos; if (pos < par->size() - 1)
else { ++pos;
pos = 0; else {
par = par->next(); pos = 0;
} par = par->next();
if (!par) }
if (!par)
return SR_NOT_FOUND;
text->setCursor(bv, par, pos);
return SearchForward(bv, text, str, cs, mw);
} else {
return SR_NOT_FOUND; return SR_NOT_FOUND;
text->setCursor(bv, par, pos); }
return SearchForward(bv, text, str, cs, mw);
} else } else
return SR_NOT_FOUND; return SR_NOT_FOUND;
} }
@ -280,9 +304,10 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
// test if we're inside an inset if yes unlock the inset // test if we're inside an inset if yes unlock the inset
// and recall us with the outside LyXText! // and recall us with the outside LyXText!
bv->unlockInset((UpdatableInset *)text->inset_owner); bv->unlockInset((UpdatableInset *)text->inset_owner);
return SearchBackward(bv, bv->getLyXText(), str, cs, mw); if (!bv->theLockingInset()) {
} else { return SearchBackward(bv, bv->getLyXText(), str, cs, mw);
return SR_NOT_FOUND; }
} }
return SR_NOT_FOUND;
} }

View File

@ -273,7 +273,7 @@ public:
/// need the selection cursor: /// need the selection cursor:
void setSelection(BufferView *); void setSelection(BufferView *);
/// ///
void clearSelection(BufferView *) const; void clearSelection() const;
/// ///
string const selectionAsString(Buffer const *) const; string const selectionAsString(Buffer const *) const;

View File

@ -1707,7 +1707,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
// Just a macro to make some thing easier. // Just a macro to make some thing easier.
void LyXText::redoParagraph(BufferView * bview) const void LyXText::redoParagraph(BufferView * bview) const
{ {
clearSelection(bview); clearSelection();
redoParagraphs(bview, cursor, cursor.par()->next()); redoParagraphs(bview, cursor, cursor.par()->next());
setCursorIntern(bview, cursor.par(), cursor.pos()); setCursorIntern(bview, cursor.par(), cursor.pos());
} }

View File

@ -199,7 +199,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
if (par->getChar(pos) == Paragraph::META_INSET) { if (par->getChar(pos) == Paragraph::META_INSET) {
Inset * inset = par->getInset(pos); Inset * inset = par->getInset(pos);
if (inset) { if (inset) {
if (inset->editable()==Inset::HIGHLY_EDITABLE) { if (inset->editable()==Inset::IS_EDITABLE) {
UpdatableInset * uinset = UpdatableInset * uinset =
static_cast<UpdatableInset *>(inset); static_cast<UpdatableInset *>(inset);
uinset->setFont(bv, fnt, toggleall, true); uinset->setFont(bv, fnt, toggleall, true);
@ -523,7 +523,7 @@ void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout)
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos(), false); setCursor(bview, selection.end.par(), selection.end.pos(), false);
updateCounters(bview, cursor.row()); updateCounters(bview, cursor.row());
clearSelection(bview); clearSelection();
setSelection(bview); setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true);
} }
@ -604,7 +604,7 @@ void LyXText::incDepth(BufferView * bview)
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos()); setCursor(bview, selection.end.par(), selection.end.pos());
updateCounters(bview, cursor.row()); updateCounters(bview, cursor.row());
clearSelection(bview); clearSelection();
setSelection(bview); setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos()); setCursor(bview, tmpcursor.par(), tmpcursor.pos());
} }
@ -661,7 +661,7 @@ void LyXText::decDepth(BufferView * bview)
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos()); setCursor(bview, selection.end.par(), selection.end.pos());
updateCounters(bview, cursor.row()); updateCounters(bview, cursor.row());
clearSelection(bview); clearSelection();
setSelection(bview); setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos()); setCursor(bview, tmpcursor.par(), tmpcursor.pos());
} }
@ -723,7 +723,7 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
setCursor(bview, selection.start.par(), selection.start.pos()); setCursor(bview, selection.start.par(), selection.start.pos());
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos()); setCursor(bview, selection.end.par(), selection.end.pos());
clearSelection(bview); clearSelection();
setSelection(bview); setSelection(bview);
setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
tmpcursor.boundary()); tmpcursor.boundary());
@ -976,7 +976,7 @@ string const LyXText::selectionAsString(Buffer const * buffer) const
} }
void LyXText::clearSelection(BufferView * /*bview*/) const void LyXText::clearSelection() const
{ {
selection.set(false); selection.set(false);
selection.mark(false); selection.mark(false);
@ -1048,7 +1048,7 @@ void LyXText::toggleFree(BufferView * bview,
// Implicit selections are cleared afterwards // Implicit selections are cleared afterwards
//and cursor is set to the original position. //and cursor is set to the original position.
if (implicitSelection) { if (implicitSelection) {
clearSelection(bview); clearSelection();
cursor = resetCursor; cursor = resetCursor;
setCursor(bview, cursor.par(), cursor.pos()); setCursor(bview, cursor.par(), cursor.pos());
selection.cursor = cursor; selection.cursor = cursor;
@ -1083,7 +1083,7 @@ LyXText::getStringToIndex(BufferView * bview)
// Implicit selections are cleared afterwards // Implicit selections are cleared afterwards
//and cursor is set to the original position. //and cursor is set to the original position.
if (implicitSelection) { if (implicitSelection) {
clearSelection(bview); clearSelection();
cursor = resetCursor; cursor = resetCursor;
setCursor(bview, cursor.par(), cursor.pos()); setCursor(bview, cursor.par(), cursor.pos());
selection.cursor = cursor; selection.cursor = cursor;
@ -1176,7 +1176,7 @@ void LyXText::setParagraph(BufferView * bview,
redoParagraphs(bview, selection.start, endpar); redoParagraphs(bview, selection.start, endpar);
clearSelection(bview); clearSelection();
setCursor(bview, selection.start.par(), selection.start.pos()); setCursor(bview, selection.start.par(), selection.start.pos());
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, selection.end.par(), selection.end.pos()); setCursor(bview, selection.end.par(), selection.end.pos());
@ -1705,7 +1705,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear)
cursor = selection.start; cursor = selection.start;
// need a valid cursor. (Lgb) // need a valid cursor. (Lgb)
clearSelection(bview); clearSelection();
setCursor(bview, cursor.par(), cursor.pos()); setCursor(bview, cursor.par(), cursor.pos());
selection.cursor = cursor; selection.cursor = cursor;
@ -1764,7 +1764,7 @@ void LyXText::pasteSelection(BufferView * bview)
redoParagraphs(bview, cursor, endpar); redoParagraphs(bview, cursor, endpar);
setCursor(bview, cursor.par(), cursor.pos()); setCursor(bview, cursor.par(), cursor.pos());
clearSelection(bview); clearSelection();
selection.cursor = cursor; selection.cursor = cursor;
setCursor(bview, actpar, pos); setCursor(bview, actpar, pos);
@ -1834,7 +1834,7 @@ void LyXText::insertStringAsLines(BufferView * bview, string const & str)
setCursorParUndo(bview); setCursorParUndo(bview);
// only to be sure, should not be neccessary // only to be sure, should not be neccessary
clearSelection(bview); clearSelection();
bview->buffer()->insertStringAsLines(par, pos, current_font, str); bview->buffer()->insertStringAsLines(par, pos, current_font, str);
@ -2536,6 +2536,11 @@ void LyXText::status(BufferView * bview, LyXText::text_status st) const
status_ = st; status_ = st;
if (inset_owner && st != UNCHANGED) { if (inset_owner && st != UNCHANGED) {
bview->text->status(bview, NEED_VERY_LITTLE_REFRESH); bview->text->status(bview, NEED_VERY_LITTLE_REFRESH);
if (!bview->text->refresh_row) {
bview->text->refresh_row = bview->text->cursor.row();
bview->text->refresh_y = bview->text->cursor.y() -
bview->text->cursor.row()->baseline();
}
} }
} }
#endif #endif