X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.cpp;h=6089756f9bbae041d28cc8322a1b4ff34712a579;hb=d1e3d75da226311cb290fc4be3686d6deef7b967;hp=566a5e94dfd6e3cab89ecae2001ed63f0b50fed3;hpb=58b87df638a3a0475d606a736c2d3e7080d4f449;p=lyx.git diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 566a5e94df..6089756f9b 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -729,7 +729,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, pos_type bottom_pos, // insets. size_t const n = dit.depth(); for (size_t i = 0; i < n; ++i) - if (dit[i].inset().editable() != Inset::HIGHLY_EDITABLE) { + if (!dit[i].inset().editable()) { dit.resize(i); break; } @@ -895,10 +895,8 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter) } -FuncStatus BufferView::getStatus(FuncRequest const & cmd) +bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag) { - FuncStatus flag; - Cursor & cur = d->cursor_; switch (cmd.action) { @@ -916,6 +914,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) // FIXME: Actually, these LFUNS should be moved to Text flag.setEnabled(cur.inTexted()); break; + case LFUN_FONT_STATE: case LFUN_LABEL_INSERT: case LFUN_INFO_INSERT: @@ -1018,60 +1017,19 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd) flag.setEnabled(cur.inset().allowParagraphCustomization(cur.idx())); break; - case LFUN_INSET_SETTINGS: { - InsetCode code = cur.inset().lyxCode(); - if (cmd.getArg(0) == insetName(code)) { - flag.setEnabled(true); - break; - } - bool enable = false; - InsetCode next_code = cur.nextInset() - ? cur.nextInset()->lyxCode() : NO_CODE; - //FIXME: remove these special cases: - switch (next_code) { - case TABULAR_CODE: - case ERT_CODE: - case FLOAT_CODE: - case WRAP_CODE: - case NOTE_CODE: - case BRANCH_CODE: - case PHANTOM_CODE: - case BOX_CODE: - case LISTINGS_CODE: - enable = (cmd.argument().empty() || - cmd.getArg(0) == insetName(next_code)); - break; - default: - break; - } - flag.setEnabled(enable); - break; - } - case LFUN_DIALOG_SHOW_NEW_INSET: + if (cur.inset().lyxCode() == CAPTION_CODE) + return cur.inset().getStatus(cur, cmd, flag); flag.setEnabled(cur.inset().lyxCode() != ERT_CODE && cur.inset().lyxCode() != LISTINGS_CODE); - if (cur.inset().lyxCode() == CAPTION_CODE) { - FuncStatus flag; - if (cur.inset().getStatus(cur, cmd, flag)) - return flag; - } - break; - - case LFUN_BRANCH_ACTIVATE: - case LFUN_BRANCH_DEACTIVATE: { - BranchList const & branchList = buffer_.params().branchlist(); - docstring const branchName = cmd.argument(); - flag.setEnabled(!branchName.empty() - && branchList.find(branchName)); break; - } default: flag.setEnabled(false); + return false; } - return flag; + return true; } @@ -1120,7 +1078,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) docstring label = cmd.argument(); if (label.empty()) { InsetRef * inset = - getInsetByCode(d->cursor_, REF_CODE); + getInsetByCode(cur, REF_CODE); if (inset) { label = inset->getParam("reference"); // persistent=false: use temp_bookmark @@ -1244,23 +1202,23 @@ bool BufferView::dispatch(FuncRequest const & cmd) case LFUN_ALL_CHANGES_ACCEPT: // select complete document - d->cursor_.reset(buffer_.inset()); - d->cursor_.selHandle(true); - buffer_.text().cursorBottom(d->cursor_); + cur.reset(buffer_.inset()); + cur.selHandle(true); + buffer_.text().cursorBottom(cur); // accept everything in a single step to support atomic undo - buffer_.text().acceptOrRejectChanges(d->cursor_, Text::ACCEPT); + buffer_.text().acceptOrRejectChanges(cur, Text::ACCEPT); // FIXME: Move this LFUN to Buffer so that we don't have to do this: processUpdateFlags(Update::Force | Update::FitCursor); break; case LFUN_ALL_CHANGES_REJECT: // select complete document - d->cursor_.reset(buffer_.inset()); - d->cursor_.selHandle(true); - buffer_.text().cursorBottom(d->cursor_); + cur.reset(buffer_.inset()); + cur.selHandle(true); + buffer_.text().cursorBottom(cur); // reject everything in a single step to support atomic undo // Note: reject does not work recursively; the user may have to repeat the operation - buffer_.text().acceptOrRejectChanges(d->cursor_, Text::REJECT); + buffer_.text().acceptOrRejectChanges(cur, Text::REJECT); // FIXME: Move this LFUN to Buffer so that we don't have to do this: processUpdateFlags(Update::Force | Update::FitCursor); break; @@ -1303,19 +1261,17 @@ bool BufferView::dispatch(FuncRequest const & cmd) case LFUN_MARK_OFF: cur.clearSelection(); - cur.resetAnchor(); cur.message(from_utf8(N_("Mark off"))); break; case LFUN_MARK_ON: cur.clearSelection(); cur.setMark(true); - cur.resetAnchor(); cur.message(from_utf8(N_("Mark on"))); break; case LFUN_MARK_TOGGLE: - cur.clearSelection(); + cur.setSelection(false); if (cur.mark()) { cur.setMark(false); cur.message(from_utf8(N_("Mark removed"))); @@ -1335,7 +1291,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; case LFUN_BIBTEX_DATABASE_ADD: { - Cursor tmpcur = d->cursor_; + Cursor tmpcur = cur; findInset(tmpcur, BIBTEX_CODE, false); InsetBibtex * inset = getInsetByCode(tmpcur, BIBTEX_CODE); @@ -1347,7 +1303,7 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_BIBTEX_DATABASE_DEL: { - Cursor tmpcur = d->cursor_; + Cursor tmpcur = cur; findInset(tmpcur, BIBTEX_CODE, false); InsetBibtex * inset = getInsetByCode(tmpcur, BIBTEX_CODE); @@ -1506,14 +1462,6 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; } - case LFUN_BRANCH_ACTIVATE: - case LFUN_BRANCH_DEACTIVATE: - if (cmd.argument().empty()) - return false; - buffer_.dispatch(cmd); - processUpdateFlags(Update::Force); - break; - // This could be rewriten using some command like forall // once the insets refactoring is done. case LFUN_NOTES_MUTATE: {