From: Jürgen Vigna Date: Wed, 1 Aug 2001 15:42:53 +0000 (+0000) Subject: Fixes to various bug-reports. X-Git-Tag: 1.6.10~20943 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=cc3955aa12f0616a951883e022b2a3c4da452eb0;p=lyx.git Fixes to various bug-reports. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2402 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView2.C b/src/BufferView2.C index 6509b06845..acef2517b3 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -265,7 +265,7 @@ void BufferView::copyEnvironment() text->copyEnvironmentType(); // clear the selection, even if mark_set toggleSelection(); - text->clearSelection(this); + text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); owner()->message(_("Paragraph environment type copied")); } @@ -288,7 +288,7 @@ void BufferView::copy() text->copySelection(this); // clear the selection, even if mark_set toggleSelection(); - text->clearSelection(this); + text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); owner()->message(_("Copy")); } @@ -316,7 +316,7 @@ void BufferView::paste() hideCursor(); // clear the selection toggleSelection(); - text->clearSelection(this); + text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); // paste @@ -325,7 +325,7 @@ void BufferView::paste() // clear the selection toggleSelection(); - text->clearSelection(this); + text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); } @@ -361,7 +361,7 @@ void BufferView::endOfSpellCheck() hideCursor(); beforeChange(text); text->selectSelectedWord(this); - text->clearSelection(this); + text->clearSelection(); update(text, BufferView::SELECT|BufferView::FITCUR); } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 634363041c..584f1a0c73 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -559,7 +559,11 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) bv_->text->setSelection(bv_); screen_->toggleToggle(bv_->text, bv_); fitCursor(bv_->text); +#if 0 screen_->showCursor(bv_->text, bv_); +#else + showCursor(); +#endif } @@ -615,7 +619,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // Clear the selection screen_->toggleSelection(bv_->text, bv_); - bv_->text->clearSelection(bv_); + bv_->text->clearSelection(); bv_->text->fullRebreak(bv_); screen_->update(bv_->text, bv_); updateScrollbar(); @@ -1126,7 +1130,7 @@ bool BufferView::Pimpl::available() const void BufferView::Pimpl::beforeChange(LyXText * text) { 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)) { if (bv_->text->updateInset(bv_, - bv_->theLockingInset())) { + bv_->theLockingInset())) { update(); if (mark_dirty){ buffer_->markDirty(); diff --git a/src/ChangeLog b/src/ChangeLog index 686096bdf5..b2264bacbf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2001-08-01 Juergen Vigna + + * 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 * lyxfunc.C: small change due to changed mathed interface diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 370cd03079..f94142d655 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,21 @@ +2001-08-01 Juergen Vigna + + * 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 * insetcite.C (latex): Paranoia check. Make sure that there is no @@ -5,6 +23,9 @@ 2001-07-31 Juergen Vigna + * 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 to the only user InsetERT. diff --git a/src/insets/inset.C b/src/insets/inset.C index e9ac220de5..67bf153603 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -135,6 +135,9 @@ void Inset::id(int id_arg) id_ = id_arg; } +void Inset::setFont(BufferView *, LyXFont const &, bool, bool ) +{} + // some stuff for inset locking 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 { LyXFont font; diff --git a/src/insets/inset.h b/src/insets/inset.h index 70e5a31888..b359e85bdb 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -284,6 +284,9 @@ public: /// check if the font of the char we want inserting is correct /// and modify it if it is not. 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: /// mutable int top_x; @@ -409,9 +412,6 @@ public: virtual void draw(BufferView *, LyXFont 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 UpdatableInset * getLockingInset() const { @@ -446,7 +446,7 @@ public: /// virtual bool showInsetDialog(BufferView *) const { return false; } /// - virtual void nodraw(bool b) { + virtual void nodraw(bool b) const { block_drawing_ = b; } /// @@ -490,6 +490,6 @@ private: /// mutable bool cursor_visible_; /// - bool block_drawing_; + mutable bool block_drawing_; }; #endif diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 03f214c2c1..20801418a6 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -37,11 +37,11 @@ using std::max; InsetCollapsable::InsetCollapsable(bool collapsed) : UpdatableInset(), collapsed_(collapsed), button_length(0), button_top_y(0), button_bottom_y(0), - need_update(FULL), label("Label"), + need_update(NONE), label("Label"), #if 0 autocollapse(false), #endif - oldWidth(0) + oldWidth(0), in_update(false) { inset.setOwner(this); inset.setAutoBreakRows(true); @@ -55,11 +55,11 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id) : UpdatableInset(in, same_id), collapsed_(in.collapsed_), framecolor(in.framecolor), labelfont(in.labelfont), 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 autocollapse(in.autocollapse), #endif - oldWidth(0) + oldWidth(0), in_update(false) { inset.init(&(in.inset), same_id); inset.setOwner(this); @@ -177,6 +177,12 @@ void InsetCollapsable::draw_collapsed(Painter & pain, void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, int baseline, float & x, bool cleared) const { + if (need_update != NONE) { + const_cast(&inset)->update(bv, f, true); + bv->text->status(bv, LyXText::CHANGED_IN_DRAW); + need_update = NONE; + return; + } if (nodraw()) return; @@ -219,7 +225,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x, cleared); - need_update = NONE; } @@ -382,9 +387,16 @@ int InsetCollapsable::getMaxWidth(BufferView * bv, void InsetCollapsable::update(BufferView * bv, LyXFont const & font, - bool reinit) + bool reinit) { + if (in_update) + return; + in_update = true; inset.update(bv, font, reinit); + if (reinit && owner()) { + owner()->update(bv, font, true); + } + in_update = false; } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 6a52d8af41..f2401c96fe 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -237,6 +237,8 @@ private: #endif /// mutable int oldWidth; + /// + bool in_update; }; #endif diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index f0bd9aa719..394649240e 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -263,7 +263,10 @@ InsetMinipage::Position InsetMinipage::pos() const 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) { - 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) { - width_ = ll; + if (ll != width_) { + width_ = ll; + need_update = FULL; + } } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b15d80e5e4..dc52ffc95b 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -138,6 +138,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) actrow = actcell = 0; clearSelection(); need_update = INIT; + in_update = false; } @@ -152,6 +153,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf, actrow = actcell = 0; sel_cell_start = sel_cell_end = 0; 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) { + if (in_update) + return; + in_update = true; if (reinit) { need_update = INIT; calculate_dimensions_of_cells(bv, font, true); if (owner()) owner()->update(bv, font, true); + in_update = false; return; } if (the_locking_inset) @@ -485,6 +491,7 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit) default: break; } + in_update = false; } @@ -793,9 +800,8 @@ void InsetTabular::insetKeyPress(XKeyEvent * xke) UpdatableInset::RESULT -InsetTabular::localDispatch(BufferView * bv, - kb_action action, - string const & arg) +InsetTabular::localDispatch(BufferView * bv, kb_action action, + string const & arg) { // We need to save the value of the_locking_inset as the call to // the_locking_inset->LocalDispatch might unlock it. @@ -814,34 +820,33 @@ InsetTabular::localDispatch(BufferView * bv, bool hs = hasSelection(); result = DISPATCHED; - // this one have priority over the locked InsetText! - switch (action) { - case LFUN_SHIFT_TAB: - case LFUN_TAB: - { - if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) != this) + // this one have priority over the locked InsetText, if we're not already + // inside another tabular then that one get's priority! + if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) { + switch (action) { + case LFUN_SHIFT_TAB: + 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; - 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) { @@ -860,7 +865,6 @@ InsetTabular::localDispatch(BufferView * bv, updateLocal(bv, CELL, false); the_locking_inset->toggleInsetCursor(bv); return result; - } else if (result == FINISHED) { } } @@ -1095,11 +1099,11 @@ InsetTabular::localDispatch(BufferView * bv, // we need to update if this was requested before updateLocal(bv, NONE, false); return UNDISPATCHED; + } else if (hs) { + clearSelection(); } nodraw(false); -// the_locking_inset->ToggleInsetCursor(bv); updateLocal(bv, CELL, false); -// the_locking_inset->ToggleInsetCursor(bv); return result; } break; @@ -1247,8 +1251,20 @@ void InsetTabular::hideInsetCursor(BufferView * bv) bv->hideLockedInsetCursor(); 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; } - + nodraw(true); // otherwise we have to lock the next inset and ask for it's selecttion UpdatableInset * inset = static_cast(tabular->GetCellInset(actcell)); inset->edit(bv, 0, 0, 0); string const str(selectNextWordInt(bv, value)); + nodraw(false); if (!str.empty()) resetPos(bv); return str; @@ -2524,7 +2541,7 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection) 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->searchForward(bv, str, cs, mw)) @@ -2535,16 +2552,18 @@ bool InsetTabular::searchForward(BufferView * bv, string const & str, } ++actcell; } - nodraw(true); // otherwise we have to lock the next inset and search there UpdatableInset * inset = static_cast(tabular->GetCellInset(actcell)); inset->edit(bv); +#if 0 bool const res = searchForward(bv, str, cs, mw); updateLocal(bv, NONE, false); - nodraw(false); bv->updateInset(const_cast(this), false); return res; +#else + return searchForward(bv, str, cs, mw); +#endif } @@ -2560,13 +2579,15 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str, } --actcell; } - nodraw(true); // otherwise we have to lock the next inset and search there UpdatableInset * inset = static_cast(tabular->GetCellInset(actcell)); inset->edit(bv, false); +#if 0 bool const res = searchBackward(bv, str, cs, mw); - nodraw(false); bv->updateInset(const_cast(this), false); return res; +#else + return searchBackward(bv, str, cs, mw); +#endif } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 3a69d952bb..2d7a61b4f6 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -189,7 +189,7 @@ public: /// std::vector const getLabelList() const; /// - void nodraw(bool b) { + void nodraw(bool b) const { UpdatableInset::nodraw(b); } bool nodraw() const; @@ -243,6 +243,8 @@ private: /// void hideInsetCursor(BufferView *); /// + void fitInsetCursor(BufferView *) const; + /// void setPos(BufferView *, int x, int y) const; /// UpdatableInset::RESULT moveRight(BufferView *, bool lock = true); @@ -333,5 +335,7 @@ private: mutable bool locked; /// mutable UpdateCodes need_update; + /// + bool in_update; }; #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6b020d1d15..3d21be3178 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -117,6 +117,7 @@ InsetText::InsetText() { par = new Paragraph; init(); + in_update = false; } @@ -125,6 +126,7 @@ InsetText::InsetText(InsetText const & ins, bool same_id) { par = 0; init(&ins, same_id); + in_update = false; autoBreakRows = ins.autoBreakRows; } @@ -415,7 +417,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, } else if (!locked) { if (need_update & CURSOR) { bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); - lt->clearSelection(bv); + lt->clearSelection(); lt->selection.cursor = lt->cursor; } 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)); else if (need_update & CURSOR) { bv->screen()->toggleSelection(lt, bv, true, y_offset,int(x)); - lt->clearSelection(bv); + lt->clearSelection(); lt->selection.cursor = lt->cursor; } 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) { + if (in_update) + return; + in_update = true; if (reinit) { need_update |= INIT; resizeLyXText(bv); if (owner()) owner()->update(bv, font, true); + in_update = false; return; } if (the_locking_inset) { @@ -502,6 +508,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) need_update |= FULL; if (clear) lt = 0; + in_update = false; return; } 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; if (clear) lt = 0; + in_update = false; } @@ -530,8 +538,11 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const need_update |= CURSOR_PAR; // this to not draw a selection when we redraw all of it! - if ((need_update & (INIT|FULL)) && (need_update & CURSOR)) - lt->clearSelection(bv); + if (need_update & CURSOR) { + if (lt->selection.set()) + need_update = FULL; + lt->clearSelection(); + } if (clear) 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)) lt->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent); - lt->clearSelection(bv); + lt->clearSelection(); finishUndo(); showInsetCursor(bv); updateLocal(bv, CURSOR, false); @@ -636,7 +647,7 @@ void InsetText::edit(BufferView * bv, bool front) p = p->next(); lt->setCursor(bv, p, p->size()-1); } - lt->clearSelection(bv); + lt->clearSelection(); finishUndo(); showInsetCursor(bv); updateLocal(bv, CURSOR, false); @@ -674,7 +685,7 @@ void InsetText::insetUnlock(BufferView * bv) clear = true; } if (lt->selection.set()) { - lt->clearSelection(bv); + lt->clearSelection(); code = FULL; } else if (owner()) { 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, y + insetAscent); + getLyXText(bv)->clearSelection(); + updateLocal(bv, FULL, false); getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor; - updateLocal(bv, CURSOR, false); bv->owner()->setLayout(cpar(bv)->getLayout()); old_par = cpar(bv); // Insert primary selection with middle mouse @@ -975,7 +987,7 @@ InsetText::localDispatch(BufferView * bv, lt->cutSelection(bv, false); } } - lt->clearSelection(bv); + lt->clearSelection(); for (string::size_type i = 0; i < arg.length(); ++i) { if (greek_kb_flag) { if (!math_insert_greek(bv, arg[i])) { @@ -1484,9 +1496,11 @@ bool InsetText::insertInset(BufferView * bv, Inset * inset) clear = true; } lt->insertInset(bv, inset); +#if 0 if ((cpar(bv)->getChar(cpos(bv)) != Paragraph::META_INSET) || (cpar(bv)->getInset(cpos(bv)) != inset)) lt->cursorLeft(bv); +#endif bv->fitCursor(lt); updateLocal(bv, CURSOR_PAR|CURSOR, true); showInsetCursor(bv); @@ -1570,7 +1584,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall, lt->setFont(bv, font, toggleall); #endif if (selectall) - lt->clearSelection(bv); + lt->clearSelection(); bv->fitCursor(lt); if (selectall || lt->selection.set()) updateLocal(bv, FULL, true); @@ -1784,7 +1798,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv, lyx::Assert(it->second.text.get()); cached_text = it->second.text; if (recursive && the_locking_inset) { - return the_locking_inset->getLyXText(bv); + return the_locking_inset->getLyXText(bv, true); } return cached_text.get(); } else if (it->second.remove) { @@ -1948,7 +1962,7 @@ void InsetText::selectAll(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 const & cs, bool const & mw) { - if (the_locking_inset) + if (the_locking_inset) { if (the_locking_inset->searchForward(bv, str, cs, mw)) 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)) { return true; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 501247ee0a..9c67d1e86f 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -394,5 +394,7 @@ private: mutable int frame_y; mutable int frame_w; mutable int frame_h; + /// + bool in_update; /* as update is not reentrant! */ }; #endif diff --git a/src/lyxfind.C b/src/lyxfind.C index 4f82ef9e1f..4b9a48cdaf 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -64,7 +64,7 @@ int LyXReplace(BufferView * bv, // start at top if replaceall bool fw = forward; if (replaceall) { - text->clearSelection(bv); + text->clearSelection(); if (text->inset_owner) { bv->unlockInset(bv->theLockingInset()); text = bv->text; @@ -84,7 +84,7 @@ int LyXReplace(BufferView * bv, } } - bool found; + bool found = false; int replace_count = 0; do { bv->hideCursor(); @@ -128,6 +128,26 @@ bool LyXFind(BufferView * bv, bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd); if (found) 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 { result = forward ? SearchForward(bv, text, searchstr, casesens, matchwrd) : @@ -139,7 +159,7 @@ bool LyXFind(BufferView * bv, // the actual text pointer could have changed! bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR); bv->toggleSelection(); - bv->getLyXText()->clearSelection(bv); + bv->getLyXText()->clearSelection(); bv->getLyXText()->setSelectionOverString(bv, searchstr); bv->toggleSelection(false); 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 // and recall us with the outside LyXText! bv->unlockInset((UpdatableInset *)text->inset_owner); - text = bv->getLyXText(); - par = text->cursor.par(); - pos = text->cursor.pos(); - if (pos < par->size() - 1) - ++pos; - else { - pos = 0; - par = par->next(); - } - if (!par) + if (!bv->theLockingInset()) { + text = bv->getLyXText(); + par = text->cursor.par(); + pos = text->cursor.pos(); + if (pos < par->size() - 1) + ++pos; + else { + pos = 0; + par = par->next(); + } + if (!par) + return SR_NOT_FOUND; + text->setCursor(bv, par, pos); + return SearchForward(bv, text, str, cs, mw); + } else { return SR_NOT_FOUND; - text->setCursor(bv, par, pos); - return SearchForward(bv, text, str, cs, mw); + } } else 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 // and recall us with the outside LyXText! bv->unlockInset((UpdatableInset *)text->inset_owner); - return SearchBackward(bv, bv->getLyXText(), str, cs, mw); - } else { - return SR_NOT_FOUND; + if (!bv->theLockingInset()) { + return SearchBackward(bv, bv->getLyXText(), str, cs, mw); + } } + return SR_NOT_FOUND; } diff --git a/src/lyxtext.h b/src/lyxtext.h index 532e0b7023..384efd0f2a 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -273,7 +273,7 @@ public: /// need the selection cursor: void setSelection(BufferView *); /// - void clearSelection(BufferView *) const; + void clearSelection() const; /// string const selectionAsString(Buffer const *) const; diff --git a/src/text.C b/src/text.C index ee3b5e26e6..f087cb3816 100644 --- a/src/text.C +++ b/src/text.C @@ -1707,7 +1707,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout) // Just a macro to make some thing easier. void LyXText::redoParagraph(BufferView * bview) const { - clearSelection(bview); + clearSelection(); redoParagraphs(bview, cursor, cursor.par()->next()); setCursorIntern(bview, cursor.par(), cursor.pos()); } diff --git a/src/text2.C b/src/text2.C index 9c001ca637..749d8a9bbe 100644 --- a/src/text2.C +++ b/src/text2.C @@ -199,7 +199,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par, if (par->getChar(pos) == Paragraph::META_INSET) { Inset * inset = par->getInset(pos); if (inset) { - if (inset->editable()==Inset::HIGHLY_EDITABLE) { + if (inset->editable()==Inset::IS_EDITABLE) { UpdatableInset * uinset = static_cast(inset); uinset->setFont(bv, fnt, toggleall, true); @@ -523,7 +523,7 @@ void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos(), false); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); } @@ -604,7 +604,7 @@ void LyXText::incDepth(BufferView * bview) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos()); } @@ -661,7 +661,7 @@ void LyXText::decDepth(BufferView * bview) selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); updateCounters(bview, cursor.row()); - clearSelection(bview); + clearSelection(); setSelection(bview); 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()); selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); - clearSelection(bview); + clearSelection(); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true, 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.mark(false); @@ -1048,7 +1048,7 @@ void LyXText::toggleFree(BufferView * bview, // Implicit selections are cleared afterwards //and cursor is set to the original position. if (implicitSelection) { - clearSelection(bview); + clearSelection(); cursor = resetCursor; setCursor(bview, cursor.par(), cursor.pos()); selection.cursor = cursor; @@ -1083,7 +1083,7 @@ LyXText::getStringToIndex(BufferView * bview) // Implicit selections are cleared afterwards //and cursor is set to the original position. if (implicitSelection) { - clearSelection(bview); + clearSelection(); cursor = resetCursor; setCursor(bview, cursor.par(), cursor.pos()); selection.cursor = cursor; @@ -1176,7 +1176,7 @@ void LyXText::setParagraph(BufferView * bview, redoParagraphs(bview, selection.start, endpar); - clearSelection(bview); + clearSelection(); setCursor(bview, selection.start.par(), selection.start.pos()); selection.cursor = cursor; setCursor(bview, selection.end.par(), selection.end.pos()); @@ -1705,7 +1705,7 @@ void LyXText::cutSelection(BufferView * bview, bool doclear) cursor = selection.start; // need a valid cursor. (Lgb) - clearSelection(bview); + clearSelection(); setCursor(bview, cursor.par(), cursor.pos()); selection.cursor = cursor; @@ -1764,7 +1764,7 @@ void LyXText::pasteSelection(BufferView * bview) redoParagraphs(bview, cursor, endpar); setCursor(bview, cursor.par(), cursor.pos()); - clearSelection(bview); + clearSelection(); selection.cursor = cursor; setCursor(bview, actpar, pos); @@ -1834,7 +1834,7 @@ void LyXText::insertStringAsLines(BufferView * bview, string const & str) setCursorParUndo(bview); // only to be sure, should not be neccessary - clearSelection(bview); + clearSelection(); bview->buffer()->insertStringAsLines(par, pos, current_font, str); @@ -2536,6 +2536,11 @@ void LyXText::status(BufferView * bview, LyXText::text_status st) const status_ = st; if (inset_owner && st != UNCHANGED) { 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