mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-12 03:23:12 +00:00
Introduce inset parameters keepempty, freespacing, needprotect and rename verbatim->passthru
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21197 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fb5839e339
commit
1f07a7f929
@ -100,7 +100,9 @@ InsetLayout ERT
|
||||
Size Small
|
||||
EndFont
|
||||
MultiPar true
|
||||
Verbatim true
|
||||
PassThru true
|
||||
KeepEmpty true
|
||||
FreeSpacing true
|
||||
End
|
||||
|
||||
InsetLayout Branch
|
||||
@ -132,3 +134,4 @@ InsetLayout Box
|
||||
MultiPar true
|
||||
End
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ InsetLayout URL
|
||||
LatexName url
|
||||
Decoration minimalistic
|
||||
LabelString URL
|
||||
Verbatim true
|
||||
PassThru true
|
||||
Font
|
||||
Family Typewriter
|
||||
Color Blue
|
||||
|
@ -2363,10 +2363,7 @@ bool Paragraph::isFreeSpacing() const
|
||||
{
|
||||
if (layout()->free_spacing)
|
||||
return true;
|
||||
|
||||
// for now we just need this, later should we need this in some
|
||||
// other way we can always add a function to Inset too.
|
||||
return ownerCode() == ERT_CODE || ownerCode() == LISTINGS_CODE;
|
||||
return d->inset_owner_ && d->inset_owner_->isFreeSpacing();
|
||||
}
|
||||
|
||||
|
||||
@ -2374,7 +2371,7 @@ bool Paragraph::allowEmpty() const
|
||||
{
|
||||
if (layout()->keepempty)
|
||||
return true;
|
||||
return ownerCode() == ERT_CODE || ownerCode() == LISTINGS_CODE;
|
||||
return d->inset_owner_ && d->inset_owner_->allowEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -610,15 +610,18 @@ enum InsetLayoutTags {
|
||||
IL_FONT = 1,
|
||||
IL_BGCOLOR,
|
||||
IL_DECORATION,
|
||||
IL_FREESPACING,
|
||||
IL_LABELFONT,
|
||||
IL_LABELSTRING,
|
||||
IL_LATEXNAME,
|
||||
IL_LATEXPARAM,
|
||||
IL_LATEXTYPE,
|
||||
IL_LYXTYPE,
|
||||
IL_KEEPEMPTY,
|
||||
IL_MULTIPAR,
|
||||
IL_NEEDPROTECT,
|
||||
IL_PASSTHRU,
|
||||
IL_PREAMBLE,
|
||||
IL_VERBATIM,
|
||||
IL_END
|
||||
};
|
||||
|
||||
@ -630,6 +633,8 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
{ "decoration", IL_DECORATION },
|
||||
{ "end", IL_END },
|
||||
{ "font", IL_FONT },
|
||||
{ "freespacing", IL_FREESPACING },
|
||||
{ "keepempty", IL_KEEPEMPTY },
|
||||
{ "labelfont", IL_LABELFONT },
|
||||
{ "labelstring", IL_LABELSTRING },
|
||||
{ "latexname", IL_LATEXNAME },
|
||||
@ -637,8 +642,9 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
{ "latextype", IL_LATEXTYPE },
|
||||
{ "lyxtype", IL_LYXTYPE },
|
||||
{ "multipar", IL_MULTIPAR },
|
||||
{ "preamble", IL_PREAMBLE },
|
||||
{ "verbatim", IL_VERBATIM }
|
||||
{ "needprotect", IL_NEEDPROTECT },
|
||||
{ "passthru", IL_PASSTHRU },
|
||||
{ "preamble", IL_PREAMBLE }
|
||||
};
|
||||
|
||||
lexrc.pushTable(elementTags, IL_END);
|
||||
@ -654,7 +660,10 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
Color::color bgcolor(Color::background);
|
||||
string preamble;
|
||||
bool multipar(false);
|
||||
bool verbatim(false);
|
||||
bool passthru(false);
|
||||
bool needprotect(false);
|
||||
bool keepempty(false);
|
||||
bool freespacing(false);
|
||||
|
||||
bool getout = false;
|
||||
while (!getout && lexrc.isOK()) {
|
||||
@ -698,9 +707,21 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
lexrc.next();
|
||||
multipar = lexrc.getBool();
|
||||
break;
|
||||
case IL_VERBATIM:
|
||||
case IL_PASSTHRU:
|
||||
lexrc.next();
|
||||
verbatim = lexrc.getBool();
|
||||
passthru = lexrc.getBool();
|
||||
break;
|
||||
case IL_KEEPEMPTY:
|
||||
lexrc.next();
|
||||
keepempty = lexrc.getBool();
|
||||
break;
|
||||
case IL_FREESPACING:
|
||||
lexrc.next();
|
||||
freespacing = lexrc.getBool();
|
||||
break;
|
||||
case IL_NEEDPROTECT:
|
||||
lexrc.next();
|
||||
needprotect = lexrc.getBool();
|
||||
break;
|
||||
case IL_FONT:
|
||||
font.lyxRead(lexrc);
|
||||
@ -735,7 +756,10 @@ void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
|
||||
il.latexname = latexname;
|
||||
il.latexparam = latexparam;
|
||||
il.multipar = multipar;
|
||||
il.verbatim = verbatim;
|
||||
il.passthru = passthru;
|
||||
il.needprotect = needprotect;
|
||||
il.freespacing = freespacing;
|
||||
il.keepempty = keepempty;
|
||||
il.font = font;
|
||||
il.labelfont = labelfont;
|
||||
il.bgcolor = bgcolor;
|
||||
|
@ -46,7 +46,10 @@ public:
|
||||
Color::color bgcolor;
|
||||
std::string preamble;
|
||||
bool multipar;
|
||||
bool verbatim;
|
||||
bool passthru;
|
||||
bool needprotect;
|
||||
bool freespacing;
|
||||
bool keepempty;
|
||||
};
|
||||
|
||||
|
||||
|
@ -157,6 +157,11 @@ public:
|
||||
virtual void cursorPos(BufferView const & bv,
|
||||
CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
||||
|
||||
///
|
||||
virtual bool isFreeSpacing() const { return false; }
|
||||
///
|
||||
virtual bool allowEmpty() const { return false; }
|
||||
|
||||
/// is this an inset that can be moved into?
|
||||
/// FIXME: merge with editable()
|
||||
virtual bool isActive() const { return nargs() > 0; }
|
||||
|
@ -648,7 +648,7 @@ bool InsetCollapsable::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_TABULAR_INSERT:
|
||||
case LFUN_TOC_INSERT:
|
||||
case LFUN_WRAP_INSERT:
|
||||
if (layout_.verbatim) {
|
||||
if (layout_.passthru) {
|
||||
flag.enabled(false);
|
||||
return true;
|
||||
} else
|
||||
@ -732,7 +732,7 @@ int InsetCollapsable::latex(Buffer const & buf, odocstream & os,
|
||||
}
|
||||
}
|
||||
OutputParams rp = runparams;
|
||||
if (layout_.verbatim)
|
||||
if (layout_.passthru)
|
||||
rp.verbatim = true;
|
||||
int i = InsetText::latex(buf, os, rp);
|
||||
if (!layout_.latexname.empty()) {
|
||||
|
@ -139,6 +139,11 @@ public:
|
||||
///
|
||||
virtual InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
|
||||
|
||||
/// Allow multiple blanks
|
||||
virtual bool isFreeSpacing() const { return layout_.freespacing; }
|
||||
/// Don't eliminate empty paragraphs
|
||||
virtual bool allowEmpty() const { return layout_.keepempty; }
|
||||
|
||||
protected:
|
||||
///
|
||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user