mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-02 08:10:39 +00:00
the optional argument patch from martin
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5079 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f1d753f3c2
commit
11953d3734
@ -252,6 +252,7 @@
|
||||
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
|
||||
|
@ -1,4 +1,15 @@
|
||||
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>
|
||||
|
||||
|
@ -92,10 +92,13 @@ Style Caption
|
||||
Align Center
|
||||
AlignPossible Center
|
||||
LabelType Sensitive
|
||||
LabelString Caption
|
||||
LabelString Caption
|
||||
OptionalArgs 1
|
||||
|
||||
# label font definition
|
||||
LabelFont
|
||||
Series Bold
|
||||
EndFont
|
||||
End
|
||||
|
||||
|
||||
|
@ -49,6 +49,7 @@ Style Chapter
|
||||
LabelType Counter_Chapter
|
||||
LabelString "Chapter "
|
||||
LabelStringAppendix "Appendix "
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
@ -73,6 +74,7 @@ Style Section
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType Counter_Section
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
@ -97,6 +99,7 @@ Style Subsection
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType Counter_Subsection
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
@ -121,6 +124,7 @@ Style Subsubsection
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType Counter_SubSubSection
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
@ -145,6 +149,7 @@ Style Paragraph
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType Counter_Paragraph
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
@ -170,6 +175,7 @@ Style Subparagraph
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType Counter_SubParagraph
|
||||
OptionalArgs 1
|
||||
|
||||
# standard font definition
|
||||
Font
|
||||
|
@ -22,6 +22,7 @@ Style Chapter*
|
||||
Margin Static
|
||||
LatexName chapter*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
# Section* style definition
|
||||
@ -30,6 +31,7 @@ Style Section*
|
||||
Margin Static
|
||||
LatexName section*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
# Subsection* style definition
|
||||
@ -38,6 +40,7 @@ Style Subsection*
|
||||
Margin Static
|
||||
LatexName subsection*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
# Subsubsection* style definition
|
||||
@ -46,6 +49,7 @@ Style Subsubsection*
|
||||
Margin Static
|
||||
LatexName subsubsection*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
# Paragraph* style definition
|
||||
@ -54,6 +58,7 @@ Style Paragraph*
|
||||
Margin Static
|
||||
LatexName paragraph*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
# Subparagraph* style definition
|
||||
@ -62,5 +67,6 @@ Style Subparagraph*
|
||||
Margin Static
|
||||
LatexName subparagraph*
|
||||
LabelType No_Label
|
||||
OptionalArgs 0
|
||||
End
|
||||
|
||||
|
@ -174,6 +174,7 @@ Menuset
|
||||
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"
|
||||
|
@ -8,6 +8,7 @@ src/converter.C
|
||||
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
|
||||
@ -133,6 +134,7 @@ src/insets/insetlist.C
|
||||
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
|
||||
|
@ -61,6 +61,7 @@
|
||||
#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"
|
||||
@ -1662,6 +1663,10 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
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)) {
|
||||
|
@ -1,3 +1,23 @@
|
||||
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
|
||||
|
@ -247,6 +247,8 @@ void LyXAction::init()
|
||||
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 },
|
||||
|
@ -73,6 +73,7 @@
|
||||
#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"
|
||||
@ -1115,6 +1116,8 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
|
||||
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") {
|
||||
|
@ -282,6 +282,7 @@ enum kb_action {
|
||||
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
|
||||
|
@ -63,6 +63,8 @@ libinsets_la_SOURCES = \
|
||||
insetminipage.h \
|
||||
insetnote.C \
|
||||
insetnote.h \
|
||||
insetoptarg.C \
|
||||
insetoptarg.h \
|
||||
insetparent.C \
|
||||
insetparent.h \
|
||||
insetquotes.C \
|
||||
|
@ -115,7 +115,9 @@ public:
|
||||
///
|
||||
FLOAT_LIST_CODE,
|
||||
///
|
||||
INDEX_PRINT_CODE
|
||||
INDEX_PRINT_CODE,
|
||||
///
|
||||
OPTARG_CODE
|
||||
};
|
||||
|
||||
///
|
||||
|
84
src/insets/insetoptarg.C
Normal file
84
src/insets/insetoptarg.C
Normal file
@ -0,0 +1,84 @@
|
||||
/* 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;
|
||||
}
|
||||
|
45
src/insets/insetoptarg.h
Normal file
45
src/insets/insetoptarg.h
Normal file
@ -0,0 +1,45 @@
|
||||
// -*- 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
|
@ -361,6 +361,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_OPTARG:
|
||||
disable = (TEXT(false)->cursor.par()->layout()->optionalargs == 0);
|
||||
break;
|
||||
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
if (mathcursor) {
|
||||
#if 0
|
||||
@ -527,6 +531,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
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;
|
||||
@ -577,9 +584,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
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);
|
||||
|
@ -59,6 +59,7 @@ enum LayoutTags {
|
||||
LT_ENDLABELTYPE,
|
||||
LT_LATEXNAME,
|
||||
LT_LATEXPARAM,
|
||||
LT_OPTARGS,
|
||||
LT_LATEXTYPE,
|
||||
LT_LEFTMARGIN,
|
||||
LT_NEED_PROTECT,
|
||||
@ -83,6 +84,7 @@ LyXLayout::LyXLayout ()
|
||||
margintype = MARGIN_STATIC;
|
||||
latextype = LATEX_PARAGRAPH;
|
||||
intitle = false;
|
||||
optionalargs = 0;
|
||||
needprotect = false;
|
||||
keepempty = false;
|
||||
font = LyXFont(LyXFont::ALL_INHERIT);
|
||||
@ -146,6 +148,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
||||
{ "newline", LT_NEWLINE },
|
||||
{ "nextnoindent", LT_NEXTNOINDENT },
|
||||
{ "obsoletedby", LT_OBSOLETEDBY },
|
||||
{ "optionalargs", LT_OPTARGS },
|
||||
{ "parindent", LT_PARINDENT },
|
||||
{ "parsep", LT_PARSEP },
|
||||
{ "parskip", LT_PARSKIP },
|
||||
@ -245,6 +248,10 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
|
||||
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;
|
||||
|
@ -188,6 +188,9 @@ public:
|
||||
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_;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "insets/insetoptarg.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -955,6 +956,23 @@ int Paragraph::getPositionOfInset(Inset const * inset) const
|
||||
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,
|
||||
@ -1053,8 +1071,16 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user