>>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:
Juergen> http://bugzilla.lyx.org/show_bug.cgi?id=2756 I'm not sure Juergen> what LFUN_INSET_TOGGLE in mathed is actually supposed to do, Juergen> but the attached patch (against 1.4) fixes the reported Juergen> assert. It checks whether the cursor has left mathed before Juergen> trying to get the cell inset. In mathed LFUN_INSET_TOGGLE locks an inset, meaning that the cursor does not enter in it anymore. This can make navigation easier. Note however that it is not foolproof since clicking in the inset gets you there. However, the code in math_nestinset tried to do the work of LFUN_NEXT_INSET_TOGGLE, which also looks at the inset at cursor position. The following patch (against 1.4.x) moves LFUN_NEXT_INSET_TOGGLE to BufferView::Pimpl (since it is not a text-only lfun), simplifies it to the point where it is understandable, and also simplifies LFUN_INSET_TOGGLE in nest insets. Please test. JMarc
Index: src/BufferView_pimpl.C =================================================================== --- src/BufferView_pimpl.C (revision 14576) +++ src/BufferView_pimpl.C (working copy) @@ -1054,6 +1054,7 @@ FuncStatus BufferView::Pimpl::getStatus( case LFUN_BIBDB_ADD: case LFUN_BIBDB_DEL: case LFUN_WORDS_COUNT: + case LFUN_NEXT_INSET_TOGGLE: flag.enabled(true); break; @@ -1351,6 +1352,20 @@ bool BufferView::Pimpl::dispatch(FuncReq buffer_->params().compressed = !buffer_->params().compressed; break; + case LFUN_NEXT_INSET_TOGGLE: { + // if there is an inset at cursor, see whether it + // wants to toggle. + InsetBase * inset = cur.nextInset(); + if (inset) + cur.pushLeft(*inset); + + cur.dispatch(FuncRequest(LFUN_INSET_TOGGLE, cmd.origin)); + if (cur.result().dispatched()) + cur.clearSelection(); + + break; + } + default: return false; } Index: src/ChangeLog =================================================================== --- src/ChangeLog (revision 14584) +++ src/ChangeLog (working copy) @@ -1,5 +1,13 @@ 2006-08-09 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + * BufferView_pimpl.C (dispatch/LFUN_NEXT_INSET_TOGGLE): moved from + LyXText and simplified a lot. + + * text3.C (dispatch/LFUN_NEXT_INSET_TOGGLE): moved to + BufferView::Pimpl, since this should work in mathed too. + +2006-08-09 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + * CutAndPaste.C (copySelection): remove annoying debug message. Index: src/mathed/ChangeLog =================================================================== --- src/mathed/ChangeLog (revision 14584) +++ src/mathed/ChangeLog (working copy) @@ -1,5 +1,10 @@ 2006-08-09 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + * math_nestinset.C (doDispatch/LFUN_INSET_TOGGLE): do not try to + do the work which belongs to LFUN_NEXT_INSET_TOGGLE (bug 2756). + +2006-08-09 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + * math_nestinset.C (script): * math_scriptinset.C (removeScript): remove annoying debug messages. Index: src/mathed/math_nestinset.C =================================================================== --- src/mathed/math_nestinset.C (revision 14584) +++ src/mathed/math_nestinset.C (working copy) @@ -649,15 +649,8 @@ void MathNestInset::doDispatch(LCursor & case LFUN_INSET_TOGGLE: recordUndo(cur); - //lockToggle(); - if (cur.pos() != cur.lastpos()) { - // toggle previous inset ... - cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock()); - } else if (cur.popLeft() && cur.pos() != cur.lastpos()) { - // ... or enclosing inset if we are in the last inset position - cur.nextAtom().nucleus()->lock(!cur.nextAtom()->lock()); - ++cur.pos(); - } + lock(!lock()); + cur.popRight(); break; case LFUN_SELFINSERT: Index: src/text3.C =================================================================== --- src/text3.C (revision 14576) +++ src/text3.C (working copy) @@ -674,28 +674,6 @@ void LyXText::dispatch(LCursor & cur, Fu cur.inset().showInsetDialog(bv); break; - case LFUN_NEXT_INSET_TOGGLE: { - InsetBase * inset = cur.nextInset(); - // this is the real function we want to invoke - cmd = FuncRequest(LFUN_INSET_TOGGLE); - cur.undispatched(); - // if there is an inset at cursor, see whether it - // wants to toggle. - if (inset) { - LCursor tmpcur = cur; - tmpcur.pushLeft(*inset); - inset->dispatch(tmpcur, cmd); - if (tmpcur.result().dispatched()) { - cur.clearSelection(); - cur.dispatched(); - } - } - // if it did not work, try the underlying inset. - if (!cur.result().dispatched()) - cur.inset().dispatch(cur, cmd); - break; - } - case LFUN_SPACE_INSERT: if (cur.paragraph().layout()->free_spacing) insertChar(cur, ' '); @@ -1719,7 +1697,6 @@ bool LyXText::getStatus(LCursor & cur, F case LFUN_BREAKPARAGRAPH_SKIP: case LFUN_PARAGRAPH_SPACING: case LFUN_INSET_INSERT: - case LFUN_NEXT_INSET_TOGGLE: case LFUN_UPCASE_WORD: case LFUN_LOWCASE_WORD: case LFUN_CAPITALIZE_WORD: