On Wed, Oct 24, 2007 at 12:38:54PM +0200, Jean-Marc Lasgouttes wrote: > Martin Vermeer <[EMAIL PROTECTED]> writes: > > > Ah. But doesn't verbatim imply free spacing? And what about allowEmpty()? > > > > I see what's happening with the Verbatim layout and with the > > FreeSpacing parameter, but what is the logic behind it (if any)? > > Should we have a separate FreeSpacing parm for insets also? Doable. > > There are some things in Layout objects that would be useful in > InsetLayout, namely: > > /// > bool free_spacing; > /// > bool pass_thru; > /** true when the fragile commands in the paragraph need to be > \protect'ed. */ > bool needprotect; > /// true when empty paragraphs should be kept. > bool keepempty; > > It would make sense to have the same concepts in both kind of layouts. > I think your verbatim is what is called pass_thru in Layout. I do not > care about particular names, but uniformity is good (meaning that if > you prefer you can rename PassThru to Verbatim for normal paragraphs). > > JMarc
Done, see attached. - Martin
Index: src/TextClass.cpp =================================================================== --- src/TextClass.cpp (revision 21179) +++ src/TextClass.cpp (working copy) @@ -610,15 +610,18 @@ 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 @@ { "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 @@ { "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 @@ 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,10 +707,22 @@ 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); font.realize(defaultfont()); @@ -735,7 +756,10 @@ 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; Index: src/insets/Inset.h =================================================================== --- src/insets/Inset.h (revision 21179) +++ src/insets/Inset.h (working copy) @@ -157,6 +157,11 @@ 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; } Index: src/insets/InsetCollapsable.cpp =================================================================== --- src/insets/InsetCollapsable.cpp (revision 21179) +++ src/insets/InsetCollapsable.cpp (working copy) @@ -648,7 +648,7 @@ 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 @@ } } OutputParams rp = runparams; - if (layout_.verbatim) + if (layout_.passthru) rp.verbatim = true; int i = InsetText::latex(buf, os, rp); if (!layout_.latexname.empty()) { Index: src/insets/InsetCollapsable.h =================================================================== --- src/insets/InsetCollapsable.h (revision 21179) +++ src/insets/InsetCollapsable.h (working copy) @@ -139,6 +139,11 @@ /// 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); Index: src/TextClass.h =================================================================== --- src/TextClass.h (revision 21179) +++ src/TextClass.h (working copy) @@ -46,7 +46,10 @@ Color::color bgcolor; std::string preamble; bool multipar; - bool verbatim; + bool passthru; + bool needprotect; + bool freespacing; + bool keepempty; }; Index: src/Paragraph.cpp =================================================================== --- src/Paragraph.cpp (revision 21179) +++ src/Paragraph.cpp (working copy) @@ -2415,10 +2415,7 @@ { 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(); } @@ -2426,7 +2423,7 @@ { if (layout()->keepempty) return true; - return ownerCode() == ERT_CODE || ownerCode() == LISTINGS_CODE; + return d->inset_owner_ && d->inset_owner_->allowEmpty(); } Index: lib/layouts/stdinsets.inc =================================================================== --- lib/layouts/stdinsets.inc (revision 21184) +++ lib/layouts/stdinsets.inc (working copy) @@ -100,7 +101,9 @@ Size Small EndFont MultiPar true - Verbatim true + PassThru true + KeepEmpty true + FreeSpacing true End InsetLayout Branch @@ -132,3 +135,4 @@ MultiPar true End + Index: lib/layouts/url.module =================================================================== --- lib/layouts/url.module (revision 21184) +++ lib/layouts/url.module (working copy) @@ -8,7 +8,7 @@ LatexName url Decoration minimalistic LabelString URL - Verbatim true + PassThru true Font Family Typewriter Color Blue