>>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
Martin> Then you want this patch. Has the inside-inset crash fixed and Martin> outlining buttons disabled for non-ToC. Abdel claims that Martin> there should still be a crash in this (related to "illegal" Martin> counters like 1.0.5). Thanks. A few comments (some of them may be more relevant to the 1.5 version). Index: LyXAction.C =================================================================== --- LyXAction.C (revision 13690) +++ LyXAction.C (working copy) @@ -240,6 +240,7 @@ 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 }, Do you really intend this OUTLINE function to be useful for readonly documents?? + case LFUN_OUTLINE: { + lyx::toc::OutlineOp const op = + static_cast<lyx::toc::OutlineOp>(convert<int>(cmd.argument)); + lyx::toc::outline(op, buffer_, cursor_.pit()); So this is a weird lfun that takes arguments 0, 1, 2, 3? What might be better would be to have 4 different functions, that could be mapped to kbd actions. Then I could see mergin this with LFUN_DEPTH_PLUS/MIN, which are the same thing for environments. Note that lists would also benefit from a way to move items (and everything nested under them) up or down. + cursor_.text()->setCursor(cursor_, cursor_.pit(), 0); + buffer_->markDirty(); + updateCounters(*buffer_); + update(); + } This does not look good in a case where the function did not trigger. Of course in this case the button is disabled, but it is still a bit ugly. Also, why do you need to reset the cursor? outline() could return a bool telling whether something happened. Or LFUN_OUTLINE could have proper getStatus support (which return code would be used to enable/disable buttons). On a separate topic, I feel some ugliness here when the cursor is not at top-level. cursor_.pit() is not going to have the same meaning for setCursor and outline... Index: lfuns.h =================================================================== --- lfuns.h (revision 13690) +++ lfuns.h (working copy) @@ -357,6 +357,7 @@ enum kb_action { LFUN_BIBDB_ADD, LFUN_BIBDB_DEL, LFUN_INSERT_CITATION, + LFUN_OUTLINE, // Vermeer 20060323 LFUN_LASTACTION // end of the table }; Spacing problem? +void outline(OutlineOp mode, Buffer * buf, pit_type & pit) +{ + ParagraphList & pars = buf->text().paragraphs(); Why not pass a cursor directly? What is the information available from the TOC itself? + case Up: { ... + case Down: { ... I guess this is where problems can occur :) + case In: + for (; lit != lend; ++lit) { + if ((*lit)->toclevel == thistoclevel + 1) { + s->layout((*lit)); + break; + } + } + break; It could be possible/nice too to increase toclevel of all the nested headings below (i.e. if a sections becomes subsection, have its subsections become subsubsections). Should not be too difficult if we ignore nested text insets. All in all, I like this patch. I am not sure yet whether it should go in 1.4.2, but it could go in later. JMarc