On Wed, 2006-04-26 at 13:56 +0300, Martin Vermeer wrote: > On Wed, 2006-04-26 at 11:07 +0200, Jean-Marc Lasgouttes wrote: > > >>>>> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes: > > > > Abdelrazak> 1) unnumbered sections will be transformed into a numbered > > Abdelrazak> section if you use IN and OUT. > > > > This is probably a consequence of a change we did to layout files > > recently. Now unnumbered sections in many layout files do have a toc > > level. It is both good (we can relate them to numbered sections) and > > bad (some code is not ready for that). You can recognize the numbered > > version because its label type is LABEL_COUNTER. I guess you should > > transform numbered to numbered and unnumbered to unnumbered. > > Precisely what I'm doing now. Need to test still. > > - Martin
This is the result. Now promoting/demoting preserves label type. Furthermore, Undo works (but fails to refresh the ToC window; I have no idea for that), and in order for numberless headers to refresh the ToC window when promoted/demoted, I had to change the == operator for ToC items: it didn't consider depth difference, which matters in the absence of a numerical label. Attached. This will go in soon unless somebody spots a problem. - Martin PS will somebody please get rid of the ^M in TocBackend.h!
Index: LyXAction.C =================================================================== --- LyXAction.C (revision 13713) +++ LyXAction.C (working copy) @@ -240,7 +240,10 @@ void LyXAction::init() { LFUN_DOWN_PARAGRAPH, "paragraph-down", ReadOnly | NoUpdate}, { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select", ReadOnly }, { LFUN_GOTO_PARAGRAPH, "paragraph-goto", ReadOnly }, - { LFUN_OUTLINE, "outline", ReadOnly }, + { LFUN_OUTLINE_UP, "outline", Noop }, + { LFUN_OUTLINE_DOWN, "outline", Noop }, + { LFUN_OUTLINE_IN, "outline", Noop }, + { LFUN_OUTLINE_OUT, "outline", Noop }, { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", Noop }, { LFUN_UP_PARAGRAPH, "paragraph-up", ReadOnly | NoUpdate}, { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select", ReadOnly }, Index: BufferView_pimpl.C =================================================================== --- BufferView_pimpl.C (revision 13713) +++ BufferView_pimpl.C (working copy) @@ -1074,7 +1074,11 @@ FuncStatus BufferView::Pimpl::getStatus( case LFUN_INSERT_LABEL: case LFUN_BOOKMARK_SAVE: case LFUN_GOTO_PARAGRAPH: - case LFUN_OUTLINE: + // FIXME handle non-trivially + case LFUN_OUTLINE_UP: + case LFUN_OUTLINE_DOWN: + case LFUN_OUTLINE_IN: + case LFUN_OUTLINE_OUT: case LFUN_GOTOERROR: case LFUN_GOTONOTE: case LFUN_REFERENCE_GOTO: @@ -1230,15 +1234,24 @@ bool BufferView::Pimpl::dispatch(FuncReq break; } - case LFUN_OUTLINE: { - lyx::toc::OutlineOp const op = - static_cast<lyx::toc::OutlineOp>(convert<int>(cmd.argument)); - lyx::toc::outline(op, buffer_, cursor_.pit()); + case LFUN_OUTLINE_UP: + lyx::toc::outline(lyx::toc::UP, cursor_); cursor_.text()->setCursor(cursor_, cursor_.pit(), 0); - buffer_->markDirty(); updateLabels(*buffer_); - update(); - } + break; + case LFUN_OUTLINE_DOWN: + lyx::toc::outline(lyx::toc::DOWN, cursor_); + cursor_.text()->setCursor(cursor_, cursor_.pit(), 0); + updateLabels(*buffer_); + break; + case LFUN_OUTLINE_IN: + lyx::toc::outline(lyx::toc::IN, cursor_); + updateLabels(*buffer_); + break; + case LFUN_OUTLINE_OUT: + lyx::toc::outline(lyx::toc::OUT, cursor_); + updateLabels(*buffer_); + break; case LFUN_GOTOERROR: bv_funcs::gotoInset(bv_, InsetBase::ERROR_CODE, false); Index: frontends/controllers/ControlToc.C =================================================================== --- frontends/controllers/ControlToc.C (revision 13713) +++ frontends/controllers/ControlToc.C (working copy) @@ -47,9 +47,20 @@ bool ControlToc::canOutline(string const void ControlToc::outline(toc::OutlineOp op) { - std::ostringstream o; - o << op << std::flush; - kernel().dispatch(FuncRequest(LFUN_OUTLINE, o.str())); + switch (op) { + case toc::UP: + kernel().dispatch(FuncRequest(LFUN_OUTLINE_UP)); + break; + case toc::DOWN: + kernel().dispatch(FuncRequest(LFUN_OUTLINE_DOWN)); + break; + case toc::IN: + kernel().dispatch(FuncRequest(LFUN_OUTLINE_IN)); + break; + case toc::OUT: + kernel().dispatch(FuncRequest(LFUN_OUTLINE_OUT)); + break; + } } Index: lfuns.h =================================================================== --- lfuns.h (revision 13713) +++ lfuns.h (working copy) @@ -357,7 +357,11 @@ enum kb_action { LFUN_BIBDB_ADD, LFUN_BIBDB_DEL, LFUN_INSERT_CITATION, - LFUN_OUTLINE, // Vermeer 20060323 + LFUN_OUTLINE_UP, // Vermeer 20060323 + // 275 + LFUN_OUTLINE_DOWN, + LFUN_OUTLINE_IN, + LFUN_OUTLINE_OUT, LFUN_LASTACTION // end of the table }; Index: toc.C =================================================================== --- toc.C (revision 13715) +++ toc.C (working copy) @@ -22,6 +22,7 @@ #include "paragraph.h" #include "cursor.h" #include "debug.h" +#include "undo.h" #include "frontends/LyXView.h" @@ -123,8 +124,11 @@ string const getGuiName(string const & t } -void outline(OutlineOp mode, Buffer * buf, pit_type & pit) +void outline(OutlineOp mode, LCursor & cur) { + recordUndo(cur); + Buffer * buf = & cur.buffer(); + pit_type & pit = cur.pit(); ParagraphList & pars = buf->text().paragraphs(); ParagraphList::iterator bgn = pars.begin(); ParagraphList::iterator s = boost::next(bgn, pit); @@ -204,7 +208,8 @@ void outline(OutlineOp mode, Buffer * bu } case IN: for (; lit != lend; ++lit) { - if ((*lit)->toclevel == thistoclevel + 1) { + if ((*lit)->toclevel == thistoclevel + 1 && + s->layout()->labeltype == (*lit)->labeltype) { s->layout((*lit)); break; } @@ -212,7 +217,8 @@ void outline(OutlineOp mode, Buffer * bu break; case OUT: for (; lit != lend; ++lit) { - if ((*lit)->toclevel == thistoclevel - 1) { + if ((*lit)->toclevel == thistoclevel - 1 && + s->layout()->labeltype == (*lit)->labeltype) { s->layout((*lit)); break; } Index: toc.h =================================================================== --- toc.h (revision 13715) +++ toc.h (working copy) @@ -63,7 +63,7 @@ enum OutlineOp { }; -void outline(OutlineOp, Buffer *, pit_type &); +void outline(OutlineOp, LCursor &); } // namespace toc Index: TocBackend.h =================================================================== --- TocBackend.h (revision 13715) +++ TocBackend.h (working copy) @@ -124,8 +124,7 @@ private: inline bool operator==(TocBackend::Item const & a, TocBackend::Item const & b) { - return a.id() == b.id() && a.str() == b.str(); - // No need to compare depth. + return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth(); }
signature.asc
Description: This is a digitally signed message part