diff --git a/src/ChangeLog b/src/ChangeLog index f1750532da..1c8fc58a78 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,15 @@ 2001-11-29 Juergen Vigna + * text.C: added support for paragraph::isFreeSpacing() + + * buffer.C: same as above + + * paragraph.h: inserted isFreeSpacing() function to enable + FreeSpacing inside InsetERT. + + * CutAndPaste.C (cutSelection/copySelection): set the inset_owner + of the paragraph's in the cut/copy buffer to 0! + * text2.C (removeRow): remove the assert as it can! * lyxtext.h: added helper function firstRow returning firstrow and diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 058ee2d6a4..80c62c28f2 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -137,6 +137,12 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar, startpar->pasteParagraph(current_view->buffer()->params); (*endpar) = startpar; // this because endpar gets deleted here! } + // this paragraph's are of noone's owner! + Paragraph * p = buf; + while(p) { + p->setInsetOwner(0); + p = p->next(); + } } return true; } @@ -188,6 +194,12 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar, while (tmppar2->size() > tmpi2) { tmppar2->erase(tmppar2->size() - 1); } + // this paragraph's are of noone's owner! + tmppar = buf; + while(tmppar) { + tmppar->setInsetOwner(0); + tmppar = tmppar->next(); + } } return true; } diff --git a/src/buffer.C b/src/buffer.C index d58ef540ab..a253c87229 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1065,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(); @@ -1123,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); @@ -1364,11 +1364,12 @@ void Buffer::insertStringAsLines(Paragraph *& par, pos_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; @@ -2927,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... @@ -3314,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; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 310c2b1739..f83fa34f21 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -3,6 +3,7 @@ * insettext.C: inserted a reinitLyXText function everywhere I delete the paragraphs! This should fixe the crashes we had. Also use the new function firstRow() instead of getRowNearY(dummy_y) + (paragraph): set the InsetOwner() of the new paragraphs! 2001-11-28 André Pönitz diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 1acb5541d0..01e0d11abf 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -376,7 +376,7 @@ int InsetCollapsable::latex(Buffer const * buf, ostream & os, return inset.latex(buf, os, fragile, free_spc); } - +#if 0 int InsetCollapsable::getMaxWidth(BufferView * bv, UpdatableInset const * in) const { @@ -394,6 +394,7 @@ int InsetCollapsable::getMaxWidth(BufferView * bv, return UpdatableInset::getMaxWidth(bv, in); #endif } +#endif void InsetCollapsable::update(BufferView * bv, LyXFont const & font, diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 06cb34f342..0e15112f60 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -136,8 +136,10 @@ public: /// void setAutoCollapse(bool f) { autocollapse = f; } #endif +#if 0 /// int getMaxWidth(BufferView *, UpdatableInset const *) const; +#endif /// LyXText * getLyXText(BufferView const *, bool const recursive) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index c85c6be95f..73c43939e2 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -2335,6 +2335,12 @@ Paragraph * InsetText::paragraph() const void InsetText::paragraph(Paragraph * p) { par = p; + // set ourself as owner for all the paragraphs inserted! + Paragraph * np = par; + while (np) { + np->setInsetOwner(this); + np = np->next(); + } reinitLyXText(); // redraw myself when asked for need_update = INIT; diff --git a/src/paragraph.C b/src/paragraph.C index df3964ccc4..76311c2558 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -928,8 +928,11 @@ void Paragraph::makeSameLayout(Paragraph const * par) int Paragraph::stripLeadingSpaces(LyXTextClassList::size_type tclass) { - if (textclasslist.Style(tclass, getLayout()).free_spacing) + if (textclasslist.Style(tclass, getLayout()).free_spacing || + isFreeSpacing()) + { return 0; + } int i = 0; while (size() @@ -2156,3 +2159,13 @@ Paragraph * Paragraph::getParFromID(int id) const { return pimpl_->getParFromID(id); } + + +bool Paragraph::isFreeSpacing() const +{ + // 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()) + return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE); + return false; +} diff --git a/src/paragraph.h b/src/paragraph.h index d97b8c62a4..3662fee3e5 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -334,6 +334,8 @@ public: #endif /// bool sgmlConvertChar(char c, string & sgml_string); + /// + bool isFreeSpacing() const; ParagraphParameters & params(); ParagraphParameters const & params() const; diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index c28db75b33..82e73c9ddd 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -219,9 +219,9 @@ void Paragraph::Pimpl::erase(pos_type pos) void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow, - pos_type const i, - int & column, LyXFont const & font, - LyXLayout const & style) + pos_type const i, + int & column, LyXFont const & font, + LyXLayout const & style) { if (style.pass_thru) return; if (column > tex_code_break_column @@ -230,6 +230,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow, && (i < size() - 1) // same in FreeSpacing mode && !style.free_spacing + && !owner_->isFreeSpacing() // In typewriter mode, we want to avoid // ! . ? : at the end of a line && !(font.family() == LyXFont::TYPEWRITER_FAMILY @@ -307,7 +308,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, } int tmp = inset->latex(buf, os, moving_arg, - style.free_spacing); + style.free_spacing); if (close) os << "}"; diff --git a/src/text.C b/src/text.C index 3732c0c416..8e5d3ea8d4 100644 --- a/src/text.C +++ b/src/text.C @@ -1746,7 +1746,8 @@ void LyXText::insertChar(BufferView * bview, char c) bool const freeSpacing = textclasslist.Style(bview->buffer()->params.textclass, - cursor.row()->par()->getLayout()).free_spacing; + cursor.row()->par()->getLayout()).free_spacing || + cursor.row()->par()->isFreeSpacing(); if (lyxrc.auto_number) { diff --git a/src/text2.C b/src/text2.C index 3350c4367b..0c092dff9a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2376,8 +2376,11 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview, // We allow all kinds of "mumbo-jumbo" when freespacing. if (textclasslist.Style(bview->buffer()->params.textclass, - old_cursor.par()->getLayout()).free_spacing) + old_cursor.par()->getLayout()).free_spacing || + old_cursor.par()->isFreeSpacing()) + { return; + } bool deleted = false;