From f289399bf5960e5d6d6ea19f756330b60fb226ea Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Mon, 20 Aug 2007 19:02:38 +0000 Subject: [PATCH] Inset configurability, LaTeX work git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19665 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCharStyle.cpp | 19 +------------------ src/insets/InsetCharStyle.h | 3 --- src/insets/InsetCollapsable.cpp | 33 +++++++++++++++++++++++++++++++++ src/insets/InsetCollapsable.h | 3 +++ src/insets/InsetNote.cpp | 13 +------------ 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/insets/InsetCharStyle.cpp b/src/insets/InsetCharStyle.cpp index 0fef555fc7..3e38f8796e 100644 --- a/src/insets/InsetCharStyle.cpp +++ b/src/insets/InsetCharStyle.cpp @@ -204,23 +204,6 @@ bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd, } -int InsetCharStyle::latex(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const -{ - if (!undefined()) { - // FIXME UNICODE - os << '\\' << from_utf8(layout_.latexname); - if (!layout_.latexparam.empty()) - os << from_utf8(layout_.latexparam); - os << '{'; - } - int i = InsetText::latex(buf, os, runparams); - if (!undefined()) - os << "}"; - return i; -} - - int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os, OutputParams const & runparams) const { @@ -262,7 +245,7 @@ void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const void InsetCharStyle::validate(LaTeXFeatures & features) const { // Force inclusion of preamble snippet in layout file - features.require(params_.name); + features.require(layout_.latexname); InsetText::validate(features); } diff --git a/src/insets/InsetCharStyle.h b/src/insets/InsetCharStyle.h index cf1b450f9a..dc264ae494 100644 --- a/src/insets/InsetCharStyle.h +++ b/src/insets/InsetCharStyle.h @@ -68,9 +68,6 @@ public: /// virtual Decoration decoration() const { return Conglomerate; } - /// - int latex(Buffer const &, odocstream &, - OutputParams const &) const; /// int plaintext(Buffer const &, odocstream &, OutputParams const &) const; diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index fe1631a50e..314ec4bada 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -618,4 +618,37 @@ docstring InsetCollapsable::floatName(string const & type, BufferParams const & } + +int InsetCollapsable::latex(Buffer const & buf, odocstream & os, + OutputParams const & runparams) const +{ + // This implements the standard way of handling the LaTeX output of + // a collapsable inset, either a command or an environment. Standard + // collapsable insets should not redefine this, non-standard ones may + // call this. + if (!layout_.latexname.empty()) { + if (layout_.latextype == "command") { + // FIXME UNICODE + os << '\\' << from_utf8(layout_.latexname); + if (!layout_.latexparam.empty()) + os << from_utf8(layout_.latexparam); + os << '{'; + } else if (layout_.latextype == "environment") { + os << "%\n\\begin{" << from_utf8(layout_.latexname) << "}\n"; + if (!layout_.latexparam.empty()) + os << from_utf8(layout_.latexparam); + } + } + int i = InsetText::latex(buf, os, runparams); + if (!layout_.latexname.empty()) + if (layout_.latextype == "command") { + os << "}"; + } else if (layout_.latextype == "environment") { + os << "\n\\end{" << from_utf8(layout_.latexname) << "}\n"; + i += 4; + } + return i; +} + + } // namespace lyx diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index e9540c7414..901c480d87 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -130,6 +130,9 @@ public: void setStatus(Cursor & cur, CollapseStatus st); /// bool setMouseHover(bool mouse_hover); + /// + int latex(Buffer const &, odocstream &, + OutputParams const &) const; protected: /// diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index ac98846b06..9285ea95f6 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -232,14 +232,6 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_DIALOG_UPDATE: InsetNoteMailer(*this).updateDialog(&cur.bv()); break; - - case LFUN_MOUSE_RELEASE: - if (cmd.button() == mouse_button::button3 && hitButton(cmd)) - InsetNoteMailer(*this).showDialog(&cur.bv()); - else - InsetCollapsable::doDispatch(cur, cmd); - break; - default: InsetCollapsable::doDispatch(cur, cmd); break; @@ -285,10 +277,7 @@ int InsetNote::latex(Buffer const & buf, odocstream & os, } odocstringstream ss; - //ss << "%\n\\begin{" << from_ascii(type) << "}\n"; - ss << "%\n\\begin{" << from_ascii(layout_.latexname) << "}\n"; - InsetText::latex(buf, ss, runparams); - ss << "\n\\end{" << from_ascii(layout_.latexname) << "}\n"; + InsetCollapsable::latex(buf, ss, runparams); // the space after the comment in 'a[comment] b' will be eaten by the // comment environment since the space before b is ignored with the // following latex output: -- 2.39.2