From 0e8b1dc29a4d5acd01a0e6f4c12b1ccc5fb2c8da Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 21:56:22 +0000 Subject: [PATCH] define InsetText::insetAllowed properly and rely on it for inset insertion in Text::dispatchsvndiff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30593 a592a061-630c-0410-9148-cb99ea01b6c8 --- configure.ac | 2 +- src/Text3.cpp | 69 ++++++++++++----------------------------- src/insets/InsetERT.cpp | 6 ---- src/insets/InsetERT.h | 2 -- src/insets/InsetText.h | 2 +- 5 files changed, 22 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index f81818aa40..f233132e12 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ fi AM_MAINTAINER_MODE save_PACKAGE=$PACKAGE -AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5]) +AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.5 silent-rules]) PACKAGE=$save_PACKAGE ### Set the execute permissions of the various scripts correctly diff --git a/src/Text3.cpp b/src/Text3.cpp index 5a8b23afa1..3318ff0bda 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2380,6 +2380,9 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_LABEL_INSERT: code = LABEL_CODE; break; + case LFUN_LINE_INSERT: + code = LINE_CODE; + break; case LFUN_INFO_INSERT: code = INFO_CODE; break; @@ -2433,6 +2436,19 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, code = SPACE_CODE; break; + case LFUN_MATH_INSERT: + case LFUN_MATH_AMS_MATRIX: + case LFUN_MATH_MATRIX: + case LFUN_MATH_DELIM: + case LFUN_MATH_BIGDELIM: + case LFUN_MATH_DISPLAY: + case LFUN_MATH_MODE: + case LFUN_MATH_MACRO: + case LFUN_MATH_SUBSCRIPT: + case LFUN_MATH_SUPERSCRIPT: + code = MATH_CODE; + break; + case LFUN_INSET_MODIFY: // We need to disable this, because we may get called for a // tabular cell via @@ -2592,18 +2608,10 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_NEWPAGE_INSERT: // not allowed in description items + code = NEWPAGE_CODE; enable = !inDescriptionItem(cur); break; - case LFUN_MATH_INSERT: - case LFUN_MATH_AMS_MATRIX: - case LFUN_MATH_MATRIX: - case LFUN_MATH_DELIM: - case LFUN_MATH_BIGDELIM: - // not allowed in ERT, for example. - enable = cur.inset().insetAllowed(MATH_CODE); - break; - case LFUN_DATE_INSERT: { string const format = cmd.argument().empty() ? lyxrc.date_insert_format : to_utf8(cmd.argument()); @@ -2664,12 +2672,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_SERVER_GET_LAYOUT: case LFUN_LAYOUT: case LFUN_SELF_INSERT: - case LFUN_LINE_INSERT: - case LFUN_MATH_DISPLAY: - case LFUN_MATH_MODE: - case LFUN_MATH_MACRO: - case LFUN_MATH_SUBSCRIPT: - case LFUN_MATH_SUPERSCRIPT: case LFUN_FONT_DEFAULT: case LFUN_FONT_UNDERLINE: case LFUN_FONT_STRIKEOUT: @@ -2718,7 +2720,9 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, } if (code != NO_CODE - && (cur.empty() || !cur.inset().insetAllowed(code))) + && (cur.empty() + || !cur.inset().insetAllowed(code) + || cur.paragraph().layout().pass_thru)) enable = false; switch (cmd.action) { @@ -2739,17 +2743,9 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_ACCENT_UNDERBAR: case LFUN_ACCENT_UNDERDOT: case LFUN_APPENDIX: - case LFUN_BOX_INSERT: - case LFUN_BRANCH_INSERT: - case LFUN_CAPTION_INSERT: case LFUN_DEPTH_DECREMENT: case LFUN_DEPTH_INCREMENT: - case LFUN_ERT_INSERT: case LFUN_FILE_INSERT: - case LFUN_FLEX_INSERT: - case LFUN_FLOAT_INSERT: - case LFUN_FLOAT_LIST_INSERT: - case LFUN_FLOAT_WIDE_INSERT: case LFUN_FONT_BOLD: case LFUN_FONT_BOLDSYMBOL: case LFUN_FONT_TYPEWRITER: @@ -2766,42 +2762,17 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd, case LFUN_FONT_STRIKEOUT: case LFUN_FONT_UULINE: case LFUN_FONT_UWAVE: - case LFUN_FOOTNOTE_INSERT: - case LFUN_HYPERLINK_INSERT: - case LFUN_INDEX_INSERT: - case LFUN_INDEX_PRINT: - case LFUN_INSET_INSERT: case LFUN_LABEL_GOTO: - case LFUN_LABEL_INSERT: case LFUN_LAYOUT_TABULAR: - case LFUN_LINE_INSERT: - case LFUN_MARGINALNOTE_INSERT: - case LFUN_MATH_DISPLAY: - case LFUN_MATH_INSERT: - case LFUN_MATH_AMS_MATRIX: - case LFUN_MATH_MATRIX: - case LFUN_MATH_MODE: case LFUN_MENU_OPEN: - case LFUN_NEWLINE_INSERT: - case LFUN_NEWPAGE_INSERT: case LFUN_NOACTION: - case LFUN_NOMENCL_INSERT: - case LFUN_NOMENCL_PRINT: - case LFUN_NOTE_INSERT: case LFUN_NOTE_NEXT: - case LFUN_OPTIONAL_INSERT: - case LFUN_PHANTOM_INSERT: case LFUN_REFERENCE_NEXT: case LFUN_SERVER_GOTO_FILE_ROW: case LFUN_SERVER_NOTIFY: case LFUN_SERVER_SET_XY: - case LFUN_SPACE_INSERT: - case LFUN_SPECIALCHAR_INSERT: - case LFUN_TABULAR_INSERT: case LFUN_TEXTSTYLE_APPLY: case LFUN_TEXTSTYLE_UPDATE: - case LFUN_TOC_INSERT: - case LFUN_WRAP_INSERT: if (cur.inset().getLayout().isPassThru()) enable = false; break; diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 4c396a1b9d..c05a6a5e87 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -128,12 +128,6 @@ docstring const InsetERT::buttonLabel(BufferView const & bv) const } -bool InsetERT::insetAllowed(InsetCode /* code */) const -{ - return false; -} - - bool InsetERT::showInsetDialog(BufferView * bv) const { bv->showDialog("ert", params2string(status(*bv)), diff --git a/src/insets/InsetERT.h b/src/insets/InsetERT.h index f6df3da8b9..e1add048b6 100644 --- a/src/insets/InsetERT.h +++ b/src/insets/InsetERT.h @@ -47,8 +47,6 @@ private: /// void write(std::ostream & os) const; /// - bool insetAllowed(InsetCode code) const; - /// int plaintext(odocstream &, OutputParams const &) const; /// int docbook(odocstream &, OutputParams const &) const; diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 399d48db50..063817d2fe 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -137,7 +137,7 @@ public: /// ParagraphList const & paragraphs() const; /// - bool insetAllowed(InsetCode) const { return true; } + bool insetAllowed(InsetCode) const { return !getLayout().isPassThru(); } /// Allow spellchecking, except for insets with latex_language bool allowSpellCheck() const { return !getLayout().isPassThru(); } /// -- 2.39.5