diff --git a/src/cursor.C b/src/cursor.C index f0fb6577c9..d77f7c25c9 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -507,7 +507,7 @@ std::ostream & operator<<(std::ostream & os, LCursor const & cur) bool LCursor::isInside(InsetBase const * p) { - for (size_t i = 0; i < depth(); ++i) + for (size_t i = 0; i != depth(); ++i) if (&operator[](i).inset() == p) return true; return false; @@ -1187,4 +1187,3 @@ void LCursor::fixIfBroken() lyxerr << "correcting cursor to level " << depth() << endl; } } - diff --git a/src/cursor.h b/src/cursor.h index d4ac28fe71..5cd4b39ad5 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -53,7 +53,7 @@ public: bool popLeft(); /// pop one slice off the cursor stack and go right bool popRight(); - /// make sure cursor is outside given inset + /// make sure we are outside of given inset void leaveInset(InsetBase const & inset); /// sets cursor part void setCursor(DocIterator const & it); diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 6b87c07997..48c4e4df99 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -203,20 +203,6 @@ void LyXView::dispatch(FuncRequest const & cmd) } -LyXFunc & LyXView::getLyXFunc() -{ - BOOST_ASSERT(lyxfunc_.get()); - return *lyxfunc_.get(); -} - - -LyXFunc const & LyXView::getLyXFunc() const -{ - BOOST_ASSERT(lyxfunc_.get()); - return *lyxfunc_.get(); -} - - Buffer const * const LyXView::updateInset(InsetBase const * inset) const { Buffer const * buffer_ptr = 0; diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 5caff004b7..c43dc71186 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -80,9 +80,9 @@ public: Buffer * buffer() const; /// return the LyX function handler for this view - LyXFunc & getLyXFunc(); + LyXFunc & getLyXFunc() { return *lyxfunc_.get(); } /// - LyXFunc const & getLyXFunc() const; + LyXFunc const & getLyXFunc() const { return *lyxfunc_.get(); } /// return the toolbar for this view Toolbars & getToolbars() { return *toolbars_.get(); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a1c624ae97..49d2ce026c 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,8 +1,3 @@ - -2005-05-07 André Pönitz - - * insetert.C (doDispatch): move cursor out of collapsed insets - 2005-05-06 José Matos * insetcommandparams.C (scanCommand): fix out of range string access. diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index 70fa28a7ed..d32362907e 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -147,32 +147,24 @@ void InsetBranch::doDispatch(LCursor & cur, FuncRequest & cmd) cur.dispatched(); if (cmd.argument == "open") - setStatus(Open); - else if (cmd.argument == "close") { - setStatus(Collapsed); - cur.leaveInset(*this); - } else if (cmd.argument == "toggle") { - if (isOpen()) { - setStatus(Collapsed); - cur.leaveInset(*this); - } else { - setStatus(Open); - } - - // The branch inset uses "assign". - } else if (cmd.argument == "assign" || cmd.argument.empty()) { + setStatus(cur, Open); + else if (cmd.argument == "close") + setStatus(cur, Collapsed); + else if (cmd.argument == "toggle") + setStatus(cur, isOpen() ? Collapsed : Open); + else if (cmd.argument == "assign" || cmd.argument.empty()) { + // The branch inset uses "assign". BranchList const & branchlist = cur.buffer().params().branchlist(); if (isBranchSelected(branchlist)) { if (status() != Open) - setStatus(Open); + setStatus(cur, Open); else cur.undispatched(); } else { - if (status() != Collapsed) { - setStatus(Collapsed); - cur.leaveInset(*this); - } else + if (status() != Collapsed) + setStatus(cur, Collapsed); + else cur.undispatched(); } } @@ -198,7 +190,8 @@ bool InsetBranch::getStatus(LCursor & cur, FuncRequest const & cmd, if (cmd.argument == "open" || cmd.argument == "close" || cmd.argument == "toggle") flag.enabled(true); - else if (cmd.argument == "assign" || cmd.argument.empty()) { + else if (cmd.argument == "assign" + || cmd.argument.empty()) { BranchList const & branchlist = cur.buffer().params().branchlist(); if (isBranchSelected(branchlist)) diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index e98f78bc9a..62025c7249 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -45,7 +45,7 @@ using std::ostringstream; void InsetCharStyle::init() { setInsetName("CharStyle"); - setStatus(Inlined); + setInlined(); setDrawFrame(false); has_label_ = true; } @@ -126,7 +126,7 @@ void InsetCharStyle::write(Buffer const & buf, ostream & os) const void InsetCharStyle::read(Buffer const & buf, LyXLex & lex) { InsetCollapsable::read(buf, lex); - setStatus(Inlined); + setInlined(); } @@ -209,7 +209,7 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const void InsetCharStyle::doDispatch(LCursor & cur, FuncRequest & cmd) { - setStatus(Inlined); + setInlined(); switch (cmd.action) { case LFUN_MOUSE_PRESS: if (cmd.button() == mouse_button::button3) diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 41e7654147..e825670b80 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -206,8 +206,7 @@ void InsetCollapsable::getCursorPos if (openinlined_) x += dimensionCollapsed().wid; else - y += dimensionCollapsed().height() - ascent() - + TEXT_TO_INSET_OFFSET + textdim_.asc; + y += dimensionCollapsed().height() - ascent() + TEXT_TO_INSET_OFFSET + textdim_.asc; } x += TEXT_TO_INSET_OFFSET; @@ -316,8 +315,7 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd) case Open: { if (hitButton(cmd)) { lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl; - setStatus(Collapsed); - cur.leaveInset(*this); + setStatus(cur, Collapsed); cur.bv().cursor() = cur; } else { lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl; @@ -335,18 +333,12 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd) case LFUN_INSET_TOGGLE: if (cmd.argument == "open") - setStatus(Open); - else if (cmd.argument == "close") { - setStatus(Collapsed); - cur.leaveInset(*this); - } else if (cmd.argument == "toggle" || cmd.argument.empty()) { - if (isOpen()) { - setStatus(Collapsed); - cur.leaveInset(*this); - } else { - setStatus(Open); - } - } else // if assign or anything else + setStatus(cur, Open); + else if (cmd.argument == "close") + setStatus(cur, Collapsed); + else if (cmd.argument == "toggle" || cmd.argument.empty()) + setStatus(cur, isOpen() ? Collapsed : Open); + else // if assign or anything else cur.undispatched(); cur.dispatched(); break; @@ -388,29 +380,18 @@ int InsetCollapsable::scroll(bool recursive) const } -void InsetCollapsable::open() -{ - if (status_ == Collapsed) // ...but not inlined - setStatus(Open); -} - - -void InsetCollapsable::close() -{ - setStatus(Collapsed); -} - - void InsetCollapsable::setLabel(string const & l) { label = l; } -void InsetCollapsable::setStatus(CollapseStatus status) +void InsetCollapsable::setStatus(LCursor & cur, CollapseStatus status) { status_ = status; setButtonLabel(); + if (status_ == Collapsed) + cur.leaveInset(*this); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 9b9e84ed13..1f747325d9 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -83,17 +83,13 @@ public: /// CollapseStatus status() const { return status_; } /// - void open(); - /// - void close(); - /// bool allowSpellCheck() const { return true; } /// bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const; protected: /// - void setStatus(CollapseStatus st); + void setStatus(LCursor & cur, CollapseStatus st); /// virtual void doDispatch(LCursor & cur, FuncRequest & cmd); /// @@ -106,6 +102,8 @@ protected: void edit(LCursor & cur, bool left); /// InsetBase * editXY(LCursor & cur, int x, int y) const; + /// + void setInlined() { status_ = Inlined; } protected: /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 412205160b..3d4b17887a 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -207,9 +207,7 @@ void InsetERT::doDispatch(LCursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetCollapsable::CollapseStatus st; InsetERTMailer::string2params(cmd.argument, st); - setStatus(st); - if (status() == Collapsed) - cur.leaveInset(*this); + setStatus(cur, st); break; } case LFUN_PASTE: diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 4abde3aecf..57bd08c788 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1518,7 +1518,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } } - BOOST_ASSERT(view()); if (view()->available()) { // Redraw screen unless explicitly told otherwise. // This also initializes the position cache for all insets