]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
Fixed cut&paste bugs and added freespacing for ERT Insets.
[lyx.git] / src / buffer.C
index c9777568b1f7cd743167b087de6efd454a4b3ffb..a253c872291b18ea5f3c3823c05852b3301dbdfb 100644 (file)
@@ -123,6 +123,8 @@ using std::set;
 using std::stack;
 using std::list;
 
+using lyx::pos_type;
+
 // all these externs should eventually be removed.
 extern BufferList bufferlist;
 
@@ -531,6 +533,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                                        + textclasslist.NameOfLayout(params.textclass, par->layout);
                                InsetError * new_inset = new InsetError(s);
                                par->insertInset(0, new_inset);
+                               par->setFont(0, LyXFont(LyXFont::ALL_INHERIT,
+                                                       params.language));
                        }
                        // Test whether the layout is obsolete.
                        LyXLayout const & layout =
@@ -1061,7 +1065,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                                            par->getLayout());
 
                // Insets don't make sense in a free-spacing context! ---Kayvan
-               if (layout.free_spacing) {
+               if (layout.free_spacing || par->isFreeSpacing()) {
                        if (lex.isOK()) {
                                lex.next();
                                string next_token = lex.getString();
@@ -1119,7 +1123,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                        textclasslist.Style(params.textclass, 
                                            par->getLayout());
 
-               if (layout.free_spacing) {
+               if (layout.free_spacing || par->isFreeSpacing()) {
                        par->insertChar(pos, ' ', font);
                } else {
                        Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
@@ -1169,6 +1173,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
 
                InsetError * new_inset = new InsetError(s);
                par->insertInset(pos, new_inset);
+               par->setFont(pos, LyXFont(LyXFont::ALL_INHERIT,
+                                         params.language));
 
 #ifndef NO_COMPABILITY
                }
@@ -1334,7 +1340,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
 }
 
 // needed to insert the selection
-void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
+void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
                                  LyXFont const & fn,string const & str) const
 {
        LyXLayout const & layout = textclasslist.Style(params.textclass, 
@@ -1358,19 +1364,19 @@ void Buffer::insertStringAsLines(Paragraph *& par, Paragraph::size_type & pos,
                        }
                        // do not insert consecutive spaces if !free_spacing
                } else if ((*cit == ' ' || *cit == '\t') &&
-                          space_inserted && !layout.free_spacing)
+                          space_inserted && !layout.free_spacing &&
+                                  !par->isFreeSpacing())
                {
                        continue;
                } else if (*cit == '\t') {
-                       if (!layout.free_spacing) {
+                       if (!layout.free_spacing && !par->isFreeSpacing()) {
                                // tabs are like spaces here
                                par->insertChar(pos, ' ', font);
                                ++pos;
                                space_inserted = true;
                        } else {
-                               const Paragraph::size_type nb = 8 - pos % 8;
-                               for (Paragraph::size_type a = 0; 
-                                    a < nb ; ++a) {
+                               const pos_type nb = 8 - pos % 8;
+                               for (pos_type a = 0; a < nb ; ++a) {
                                        par->insertChar(pos, ' ', font);
                                        ++pos;
                                }
@@ -1808,7 +1814,7 @@ string const Buffer::asciiParagraph(Paragraph const * par,
                lyxerr << "Should this ever happen?" << endl;
        }
 
-       for (Paragraph::size_type i = 0; i < par->size(); ++i) {
+       for (pos_type i = 0; i < par->size(); ++i) {
                if (!i && !noparbreak) {
                        if (linelen > 0)
                                buffer << "\n\n";
@@ -2156,8 +2162,6 @@ void Buffer::makeLaTeXFile(string const & fname,
                        ofs << "\\usepackage{geometry}\n";
                        texrow.newline();
                        ofs << "\\geometry{verbose";
-                       if (params.sides == LyXTextClass::TwoSides)
-                               ofs << ",twoside";
                        if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
                                ofs << ",landscape";
                        switch (params.papersize2) {
@@ -2793,7 +2797,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
 
        stack<PAR_TAG> tag_state;
        // parsing main loop
-       for (Paragraph::size_type i = 0; i < par->size(); ++i) {
+       for (pos_type i = 0; i < par->size(); ++i) {
 
                PAR_TAG tag_close = NONE;
                list < PAR_TAG > tag_open;
@@ -2924,7 +2928,8 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
                } else {
                        string sgml_string;
                        if (par->sgmlConvertChar(c, sgml_string)
-                           && !style.free_spacing) { 
+                           && !style.free_spacing && !par->isFreeSpacing())
+                       { 
                                // in freespacing mode, spaces are
                                // non-breaking characters
                                if (desc_on) {// if char is ' ' then...
@@ -2966,6 +2971,7 @@ void Buffer::sgmlError(Paragraph * par, int pos,
        // insert an error marker in text
        InsetError * new_inset = new InsetError(message);
        par->insertInset(pos, new_inset);
+       par->setFont(pos, LyXFont(LyXFont::ALL_INHERIT, params.language));
 }
 
 
@@ -3285,8 +3291,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
        //      os << string(depth,' ');
 
        // parsing main loop
-       for (Paragraph::size_type i = 0;
-            i < par->size(); ++i) {
+       for (pos_type i = 0; i < par->size(); ++i) {
                LyXFont font = par->getFont(params, i);
 
                // handle <emphasis> tag
@@ -3311,7 +3316,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
 
                        if (style.pass_thru) {
                                os << c;
-                       } else if(style.free_spacing || c != ' ') {
+                       } else if(style.free_spacing || par->isFreeSpacing() || c != ' ') {
                                        os << sgml_string;
                        } else if (desc_on ==1) {
                                ++char_line_count;
@@ -3695,8 +3700,7 @@ bool Buffer::isMultiLingual()
 }
 
 
-Buffer::inset_iterator::inset_iterator(Paragraph * paragraph,
-                                      Paragraph::size_type pos)
+Buffer::inset_iterator::inset_iterator(Paragraph * paragraph, pos_type pos)
        : par(paragraph)
 {
        it = par->InsetIterator(pos);