Gnome frontend
@bMartin Vermeer
@iE-mail: martin.vermeer@hut.fi
+ support for optional argument in sections/captions
svjour/svjog, egs and llncs document classes
Lot of bug hunting (and fixing!)
@bJuergen Vigna
+2002-08-23 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+ * ui/default.ui: add menu entry for optional-insert
+
+ * CREDITS: update Martin's entry
+
+2002-08-20 Martin Vermeer <martin.vermeer@hut.fi>
+
+ * layouts/stdlayouts.inc:
+ * layouts/stdsections.inc:
+ * layouts/stdstarsections.inc: aded OptionalArgs tags to the
+ relevant layouts
2002-08-21 André Pönitz <poenitz@gmx.net>
Align Center
AlignPossible Center
LabelType Sensitive
- LabelString Caption
+ LabelString Caption
+ OptionalArgs 1
# label font definition
LabelFont
Series Bold
EndFont
End
+
+
LabelType Counter_Chapter
LabelString "Chapter "
LabelStringAppendix "Appendix "
+ OptionalArgs 1
# standard font definition
Font
Align Block
AlignPossible Block, Left
LabelType Counter_Section
+ OptionalArgs 1
# standard font definition
Font
Align Block
AlignPossible Block, Left
LabelType Counter_Subsection
+ OptionalArgs 1
# standard font definition
Font
Align Block
AlignPossible Block, Left
LabelType Counter_SubSubSection
+ OptionalArgs 1
# standard font definition
Font
Align Block
AlignPossible Block, Left
LabelType Counter_Paragraph
+ OptionalArgs 1
# standard font definition
Font
Align Block
AlignPossible Block, Left
LabelType Counter_SubParagraph
+ OptionalArgs 1
# standard font definition
Font
Margin Static
LatexName chapter*
LabelType No_Label
+ OptionalArgs 0
End
# Section* style definition
Margin Static
LatexName section*
LabelType No_Label
+ OptionalArgs 0
End
# Subsection* style definition
Margin Static
LatexName subsection*
LabelType No_Label
+ OptionalArgs 0
End
# Subsubsection* style definition
Margin Static
LatexName subsubsection*
LabelType No_Label
+ OptionalArgs 0
End
# Paragraph* style definition
Margin Static
LatexName paragraph*
LabelType No_Label
+ OptionalArgs 0
End
# Subparagraph* style definition
Margin Static
LatexName subparagraph*
LabelType No_Label
+ OptionalArgs 0
End
Item "Label...|L" "label-insert"
Item "Footnote|F" "footnote-insert"
Item "Marginal Note|M" "marginalnote-insert"
+ Item "Short title" "optional-insert"
Item "Index Entry|I" "index-insert"
Item "URL...|U" "url-insert"
Item "Note|N" "note-insert"
src/CutAndPaste.C
src/debug.C
src/exporter.C
+src/ext_l10n.h
src/FloatList.C
src/frontends/controllers/biblio.C
src/frontends/controllers/ButtonController.h
src/insets/insetmarginal.C
src/insets/insetminipage.C
src/insets/insetnote.C
+src/insets/insetoptarg.C
src/insets/insetparent.C
src/insets/insetref.C
src/insets/insettabular.C
#include "insets/insetminipage.h"
#include "insets/insetfloat.h"
#include "insets/insettabular.h"
+#include "insets/insetoptarg.h"
#if 0
#include "insets/insettheorem.h"
#include "insets/insetlist.h"
insertAndEditInset(new InsetNote(buffer_->params));
break;
+ case LFUN_INSET_OPTARG:
+ insertAndEditInset(new InsetOptArg(buffer_->params));
+ break;
+
case LFUN_INSET_FLOAT:
// check if the float type exist
if (floatList.typeExist(ev.argument)) {
+2002-08-22 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * lyxfunc.C (getStatus): handle LFUN_INSET_OPTARG
+
+2002-08-20 Martin Vermeer <martin.vermeer@hut.fi>
+
+ * BufferView_pimpl.C:
+ * LyXAction.C:
+ * buffer.C:
+ * commandtags.h:
+ * lyxfunc.C:
+ * paragraph.[Ch]:
+ * text2.C:
+ * insets/insetoptarg.[Ch]: Added "optional argument" collapsible
+ inset and code to make it work with the paragraph code. The inset
+ can be anywhere in the paragraph, but will only do the expected
+ thing in LaTeX if the layout file contains the parameter line
+ OptionalArgs 1
+ (or more generally, a nonzero value) for that layout.
+
2002-08-22 Lars Gullik Bjønnes <larsbj@gullik.net>
* paragraph.h: remove the declaration of undefined counters class
ReadOnly },
{ LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"),
Noop },
+ { LFUN_INSET_OPTARG, "optional-insert", N_("Insert Optional Argument"),
+ Noop },
{ LFUN_LANGUAGE, "language", N_("Change language"), Noop },
{ LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"),
ReadOnly },
#include "insets/insetgraphics.h"
#include "insets/insetfoot.h"
#include "insets/insetmarginal.h"
+#include "insets/insetoptarg.h"
#include "insets/insetminipage.h"
#include "insets/insetfloat.h"
#include "insets/insettabular.h"
inset = new InsetFoot(params);
} else if (tmptok == "Marginal") {
inset = new InsetMarginal(params);
+ } else if (tmptok == "OptArg") {
+ inset = new InsetOptArg(params);
} else if (tmptok == "Minipage") {
inset = new InsetMinipage(params);
} else if (tmptok == "Float") {
LFUN_FORKS_SHOW, // Angus 16 Feb 2002
LFUN_FORKS_KILL, // Angus 16 Feb 2002
LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002
+ LFUN_INSET_OPTARG, // Martin 12 Aug 2002
LFUN_MOUSE_PRESS, // André 9 Aug 2002
LFUN_MOUSE_MOTION, // André 9 Aug 2002
LFUN_MOUSE_RELEASE, // André 9 Aug 2002
insetminipage.h \
insetnote.C \
insetnote.h \
+ insetoptarg.C \
+ insetoptarg.h \
insetparent.C \
insetparent.h \
insetquotes.C \
///
FLOAT_LIST_CODE,
///
- INDEX_PRINT_CODE
+ INDEX_PRINT_CODE,
+ ///
+ OPTARG_CODE
};
///
--- /dev/null
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "debug.h"
+
+#include "insetoptarg.h"
+#include "support/LOstream.h"
+#include "frontends/Alert.h"
+#include "support/lstrings.h" //frontStrip, strip
+#include "lyxtext.h"
+#include "buffer.h"
+#include "gettext.h"
+#include "BufferView.h"
+#include "support/lstrings.h"
+
+using std::ostream;
+using std::vector;
+using std::pair;
+
+/* OptArg. Used to insert a short version of sectioning header etc.
+ * automatically, or other optional LaTeX arguments */
+
+
+InsetOptArg::InsetOptArg(BufferParams const & ins)
+ : InsetCollapsable(ins, true)
+{
+ LyXFont font(LyXFont::ALL_SANE);
+ font.setColor(LColor::collapsable);
+ setLabelFont(font);
+ setLabel(_("opt"));
+}
+
+InsetOptArg::InsetOptArg(InsetOptArg const & in, bool same_id)
+ : InsetCollapsable(in, same_id)
+{
+ LyXFont font(LyXFont::ALL_SANE);
+ font.setColor(LColor::collapsable);
+ setLabelFont(font);
+ setLabel(_("opt"));
+}
+
+Inset * InsetOptArg::clone(Buffer const &, bool same_id) const
+{
+ return new InsetOptArg(*this, same_id);
+}
+
+string const InsetOptArg::editMessage() const
+{
+ return _("Opened Optional Argument Inset");
+}
+
+void InsetOptArg::write(Buffer const * buf, ostream & os) const
+{
+ os << "OptArg" << "\n";
+ InsetCollapsable::write(buf, os);
+}
+
+int InsetOptArg::latex(Buffer const *, ostream &, bool, bool) const
+{
+ return 0;
+}
+
+int InsetOptArg::latexOptional(Buffer const * buf, ostream & os,
+ bool, bool fp) const
+{
+ os << '[';
+ int const i = inset.latex(buf, os, false, fp);
+ os << ']';
+ return i + 2;
+}
+
--- /dev/null
+// -*- C++ -*-
+/* This file is part of*
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2001 The LyX Team
+ *
+ * ====================================================== */
+
+#ifndef INSETOPTARG_H
+#define INSETOPTARG_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insettext.h"
+#include "insetcollapsable.h"
+
+class InsetOptArg : public InsetCollapsable {
+public:
+ InsetOptArg(BufferParams const &);
+ ///
+ InsetOptArg(InsetOptArg const &, bool same_id = false);
+
+ Inset * clone(Buffer const &, bool same_id = false) const;
+ ///
+ EDITABLE editable() const { return IS_EDITABLE; }
+ ///
+ Inset::Code lyxCode() const { return Inset::OPTARG_CODE; }
+ ///
+ string const editMessage() const;
+ /// Standard LaTeX output -- short-circuited
+ int latex(Buffer const *, std::ostream &,
+ bool fragile, bool fp) const;
+ /// Outputting the optional parameter of a LaTeX command
+ int latexOptional(Buffer const *, std::ostream &,
+ bool fragile, bool fp) const;
+ ///
+ void write(Buffer const * buf, ostream & os) const;
+};
+
+#endif
break;
}
+ case LFUN_INSET_OPTARG:
+ disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
+ break;
+
case LFUN_TABULAR_FEATURE:
if (mathcursor) {
#if 0
case LFUN_INSERT_LABEL:
code = Inset::LABEL_CODE;
break;
+ case LFUN_INSET_OPTARG:
+ code = Inset::OPTARG_CODE;
+ break;
case LFUN_REF_INSERT:
code = Inset::REF_CODE;
break;
default:
break;
}
- if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
+ if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code))
disable = true;
- }
if (disable)
flag.disabled(true);
LT_ENDLABELTYPE,
LT_LATEXNAME,
LT_LATEXPARAM,
+ LT_OPTARGS,
LT_LATEXTYPE,
LT_LEFTMARGIN,
LT_NEED_PROTECT,
margintype = MARGIN_STATIC;
latextype = LATEX_PARAGRAPH;
intitle = false;
+ optionalargs = 0;
needprotect = false;
keepempty = false;
font = LyXFont(LyXFont::ALL_INHERIT);
{ "newline", LT_NEWLINE },
{ "nextnoindent", LT_NEXTNOINDENT },
{ "obsoletedby", LT_OBSOLETEDBY },
+ { "optionalargs", LT_OPTARGS },
{ "parindent", LT_PARINDENT },
{ "parsep", LT_PARSEP },
{ "parskip", LT_PARSKIP },
intitle = lexrc.next() && lexrc.getInteger();
break;
+ case LT_OPTARGS:
+ optionalargs = lexrc.next() && lexrc.getInteger();
+ break;
+
case LT_NEED_PROTECT:
needprotect = lexrc.next() && lexrc.getInteger();
break;
LYX_LATEX_TYPES latextype;
/// Does this object belong in the title part of the document?
bool intitle;
+ /// Does this layout allow for an optional parameter?
+ int optionalargs;
+
private:
/// Name of the layout/paragraph environment
string name_;
#include "insets/insetinclude.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
+#include "insets/insetoptarg.h"
#include "support/filetools.h"
#include "support/lstrings.h"
return -1;
}
+namespace {
+
+InsetOptArg * optArgInset(Paragraph const & par)
+{
+ // Find the entry.
+ InsetList::iterator it = par.insetlist.begin();
+ InsetList::iterator end = par.insetlist.end();
+ for (; it != end; ++it) {
+ Inset * ins = it.getInset();
+ if (ins->lyxCode() == Inset::OPTARG_CODE) {
+ return static_cast<InsetOptArg *>(ins);
+ }
+ }
+ return 0;
+}
+
+} // end namespace
Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
BufferParams const & bparams,
switch (style->latextype) {
case LATEX_COMMAND:
os << '\\'
- << style->latexname()
- << style->latexparam();
+ << style->latexname();
+
+ // Separate handling of optional argument inset.
+ if (style->optionalargs == 1) {
+ InsetOptArg * it = optArgInset(*this);
+ if (it != 0)
+ it->latexOptional(buf, os, false, false);
+ }
+ else
+ os << style->latexparam();
break;
case LATEX_ITEM_ENVIRONMENT:
if (bibkey) {