]> git.lyx.org Git - lyx.git/commitdiff
Introduce inset parameters keepempty, freespacing, needprotect and rename verbatim...
authorMartin Vermeer <martin.vermeer@hut.fi>
Thu, 25 Oct 2007 09:19:26 +0000 (09:19 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Thu, 25 Oct 2007 09:19:26 +0000 (09:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21197 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/stdinsets.inc
lib/layouts/url.module
src/Paragraph.cpp
src/TextClass.cpp
src/TextClass.h
src/insets/Inset.h
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h

index fc25ebcb9fa1a626221ddd63ecc786277994622c..41293be1fa5291c67f93fac0d14c41f2250f8a36 100644 (file)
@@ -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
 
+
index c8d9576e91fce0e3dc80c748f2dc879c9b193b68..37068bfe7365275447bb3dfd306b41204cef4daf 100644 (file)
@@ -8,7 +8,7 @@ InsetLayout URL
   LatexName url
   Decoration minimalistic
   LabelString URL
-  Verbatim true
+  PassThru true
   Font
     Family Typewriter
     Color Blue
index 56a19927b8e08cb74c31fee282e7a1d95e147e19..779c60f989cf04496506199b46fa2fa264a12bad 100644 (file)
@@ -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();
 }
 
 
index 5397227b08652f5b19c5d61428801656c92c38a8..e2e63d569713f66c303fdc356aeb1922ff9d27f7 100644 (file)
@@ -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;           
index e3a4a66fb37d57400a68b4f997e5ee0e16d91279..d8aa0f17ef4802dd980e77ea5312ffd779c5b0b3 100644 (file)
@@ -46,7 +46,10 @@ public:
        Color::color bgcolor;
        std::string preamble;
        bool multipar;
-       bool verbatim;
+       bool passthru;
+       bool needprotect;
+       bool freespacing;
+       bool keepempty;
 };
 
 
index 7e6995e6faab0e7d162bfb88d6e22214ea5df740..e8e0f9ef0e4504026c80960f42c16f9288b2bef2 100644 (file)
@@ -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; }
index e6a4f741b4b2565a38e6b78f76709da9ca7cf4a2..17a0fbe8c69585d3f427dd565b7d52e9fdb5c1ed 100644 (file)
@@ -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()) {
index 75fc3d8e624aaac9969ed1f2a8910fe41cb5d0d0..2aaa609e2b6693584fee9198f88496bc4e296836 100644 (file)
@@ -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);