]> git.lyx.org Git - lyx.git/commitdiff
minimal ERT spacing patch (first patch sent to list plus a couple of fixes)
authorJohn Levon <levon@movementarian.org>
Sat, 7 Jun 2003 17:45:43 +0000 (17:45 +0000)
committerJohn Levon <levon@movementarian.org>
Sat, 7 Jun 2003 17:45:43 +0000 (17:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7134 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/insets/ChangeLog
src/insets/insetert.C
src/insets/insetgraphics.C
src/paragraph.C
src/paragraph.h
src/paragraph_funcs.C
src/paragraph_pimpl.C
src/text.C
src/text2.C

index 14da15ca4f2a4427b8f78c7ab0df75c322faae03..27ac7e4f7d23f9f0ea1f410c4de3089e8bf7b478 100644 (file)
@@ -1,3 +1,14 @@
+2003-06-07  John Levon  <levon@movementarian.org>
+
+       * buffer.C:
+       * paragraph_funcs.C:
+       * paragraph_pimpl.C:
+       * text.C:
+       * text2.C:
+       * paragraph.h:
+       * paragraph.C: allow InsetERT to freely space lines,
+       and some consolidation of code
+
 2003-06-06  José Matos  <jamatos@fep.up.pt>
 
        * buffer.C (makeDocBookFile): fix bug #821
index 0562d3e7a84fab8c20cfca90fc4c3fabe8767ce4..1fd247b510f31415cb9cf7c32bf63b23bd35b727 100644 (file)
@@ -414,7 +414,7 @@ void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
        for(string::const_iterator cit = str.begin();
            cit != str.end(); ++cit) {
                if (*cit == '\n') {
-                       if (autobreakrows && (!par->empty() || layout->keepempty)) {
+                       if (autobreakrows && (!par->empty() || par->allowEmpty())) {
                                breakParagraph(params, paragraphs, par, pos,
                                               layout->isEnvironment());
                                ++par;
@@ -425,12 +425,10 @@ void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
                        }
                        // do not insert consecutive spaces if !free_spacing
                } else if ((*cit == ' ' || *cit == '\t') &&
-                          space_inserted && !layout->free_spacing &&
-                                  !par->isFreeSpacing())
-               {
+                          space_inserted && !par->isFreeSpacing()) {
                        continue;
                } else if (*cit == '\t') {
-                       if (!layout->free_spacing && !par->isFreeSpacing()) {
+                       if (!par->isFreeSpacing()) {
                                // tabs are like spaces here
                                par->insertChar(pos, ' ', font);
                                ++pos;
@@ -1522,7 +1520,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
                        bool ws;
                        string str;
                        boost::tie(ws, str) = sgml::escapeChar(c);
-                       if (ws && !style->free_spacing && !par->isFreeSpacing()) {
+                       if (ws && !par->isFreeSpacing()) {
                                // in freespacing mode, spaces are
                                // non-breaking characters
                                if (desc_on) {// if char is ' ' then...
@@ -1907,9 +1905,9 @@ void Buffer::simpleDocBookOnePar(ostream & os,
 
                        if (style->pass_thru) {
                                os << c;
-                       } else if (style->free_spacing || par->isFreeSpacing() || c != ' ') {
+                       } else if (par->isFreeSpacing() || c != ' ') {
                                        os << str;
-                       } else if (desc_on ==1) {
+                       } else if (desc_on == 1) {
                                ++char_line_count;
                                os << "\n</term><listitem><para>";
                                desc_on = 2;
index 4b03c88d47a34d3bb3789d0c7672bde0d15ec4ce..35fbc6fb33f5fa09214f2c58fd777bcdf0394bdf 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-07  John Levon  <levon@movementarian.org>
+
+       * insetert.C (latex): make a newline mean just that not
+       a new par
+
 2003-06-07  José Matos  <jamatos@fep.up.pt>
 
        * insethfill.[Ch] (linuxdoc, docbook): implement output
index f7c10d35b371d5ce1e6512f4868bafd1770bc684..4a6888091f1e5aca24a0a23463045ef511755fdb 100644 (file)
@@ -346,8 +346,8 @@ int InsetERT::latex(Buffer const *, ostream & os,
                }
                ++par;
                if (par != end) {
-                       os << "\n\n";
-                       lines += 2;
+                       os << "\n";
+                       ++lines;
                }
        }
 
index afe19346e2eaf6954b0a50bcbef138a2c648219c..ee094798506714b4d22f4f2cb3509c377aa908ea 100644 (file)
@@ -330,8 +330,12 @@ string const InsetGraphics::prepareFile(Buffer const * buf,
        string orig_file = params().filename;
        string const rel_file = MakeRelPath(orig_file, buf->filePath());
 
-       if (!IsFileReadable(rel_file))
+       if (!IsFileReadable(orig_file)) {
+               lyxerr[Debug::GRAPHICS]
+                       << "InsetGraphics::prepareFile\n"
+                       << "No file '" << orig_file << "' can be found!" << endl;
                return rel_file;
+       }
 
        bool const zipped = zippedFile(orig_file);
 
@@ -521,6 +525,8 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os,
                (before + '{' + relative_file + " not found!}" + after);
        os << latex_str;
 
+       lyxerr[Debug::GRAPHICS] << "InsetGraphics::latex outputting:\n"
+                               << latex_str << endl;
        // Return how many newlines we issued.
        return int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1);
 }
index 0da1d96d2c9906988607378d5b948512546a891c..5d711ee3c0dcdc552a56f14c005e7a92e58bf678 100644 (file)
@@ -623,7 +623,7 @@ void Paragraph::makeSameLayout(Paragraph const & par)
 
 int Paragraph::stripLeadingSpaces()
 {
-       if (layout()->free_spacing || isFreeSpacing())
+       if (isFreeSpacing())
                return 0;
 
        int i = 0;
@@ -1409,6 +1409,9 @@ ParagraphParameters const & Paragraph::params() const
 
 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.
        if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
@@ -1417,6 +1420,16 @@ bool Paragraph::isFreeSpacing() const
 }
 
 
+bool Paragraph::allowEmpty() const
+{
+       if (layout()->keepempty)
+               return true;
+       if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
+               return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
+       return false;
+}
+
+
 bool operator==(Paragraph const & lhs, Paragraph const & rhs)
 {
 #warning FIXME this implementatoin must be completely wrong...
index c89c15b787e06439330285ede006b3f86d7906fb..5c9ba843c3858caae9f60fad1929e90adcdea7cd 100644 (file)
@@ -283,9 +283,12 @@ public:
        ///
        int stripLeadingSpaces();
 
-       ///
+       /// return true if we allow multiple spaces
        bool isFreeSpacing() const;
 
+       /// return true if we allow this par to stay empty
+       bool allowEmpty() const;
+
        ///
        ParagraphParameters & params();
        ///
index 0842302dbb236d9a94a56b6c9bdf66f4982a69b8..7c42132308a852c0a11b3b9f87c312517abeb980 100644 (file)
@@ -71,7 +71,7 @@ void breakParagraph(BufferParams const & bparams,
                tmp->setLabelWidthString(par->params().labelWidthString());
        }
 
-       bool const isempty = (par->layout()->keepempty && par->empty());
+       bool const isempty = (par->allowEmpty() && par->empty());
 
        if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
                tmp->layout(par->layout());
@@ -937,10 +937,9 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                lex.next();
                font.setLyXColor(lex.getString());
        } else if (token == "\\InsetSpace" || token == "\\SpecialChar") {
-               LyXLayout_ptr const & layout = par.layout();
 
                // Insets don't make sense in a free-spacing context! ---Kayvan
-               if (layout->free_spacing || par.isFreeSpacing()) {
+               if (par.isFreeSpacing()) {
                        if (token == "\\InsetSpace")
                                par.insertChar(par.size(), ' ', font, change);
                        else if (lex.isOK()) {
index 912538e72df177cbfbd221e84a672fd10dc0760e..75eb764983061a905a2c1af73cdc580608f7e0ae 100644 (file)
@@ -429,8 +429,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
            && getChar(i - 1) != ' '
            && (i < size() - 1)
            // same in FreeSpacing mode
-           && !style.free_spacing
-               && !owner_->isFreeSpacing()
+           && !owner_->isFreeSpacing()
            // In typewriter mode, we want to avoid
            // ! . ? : at the end of a line
            && !(font.family() == LyXFont::TYPEWRITER_FAMILY
index bc95c353bd216582c69705fcd84df1fce687e817..bcc7c640e008e901c24ae79c6fc840d38e1f7a41 100644 (file)
@@ -1461,10 +1461,9 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
        LyXLayout_ptr const & layout = cursor.par()->layout();
 
        // this is only allowed, if the current paragraph is not empty or caption
-       // and if it has not the keepempty flag aktive
-       if (cursor.par()->empty()
-          && layout->labeltype != LABEL_SENSITIVE
-          && !layout->keepempty)
+       // and if it has not the keepempty flag active
+       if (cursor.par()->empty() && !cursor.par()->allowEmpty()
+          && layout->labeltype != LABEL_SENSITIVE)
                return;
 
        setUndo(bv(), Undo::FINISH, cursor.par());
@@ -1487,7 +1486,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
        // breakParagraph call should return a bool if it inserts the
        // paragraph before or behind and we should react on that one
        // but we can fix this in 1.3.0 (Jug 20020509)
-       bool const isempty = (layout->keepempty && cursor.par()->empty());
+       bool const isempty = (cursor.par()->allowEmpty() && cursor.par()->empty());
        ::breakParagraph(bv()->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
                       keep_layout);
 
index afa44ca91d7b7ba26e7b8d62a5e2e3b8c789a77f..1224d22cd5b1212dcab9bae9e60455f1f10567e1 100644 (file)
@@ -2224,7 +2224,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
                return false;
 
        // Do not delete empty paragraphs with keepempty set.
-       if (old_cursor.par()->layout()->keepempty)
+       if (old_cursor.par()->allowEmpty())
                return false;
 
        // only do our magic if we changed paragraph