2001-11-29 Juergen Vigna <jug@sad.it>
+ * 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
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;
}
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;
}
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();
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);
}
// 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;
} 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...
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;
* 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 <poenitz@gmx.net>
return inset.latex(buf, os, fragile, free_spc);
}
-
+#if 0
int InsetCollapsable::getMaxWidth(BufferView * bv,
UpdatableInset const * in) const
{
return UpdatableInset::getMaxWidth(bv, in);
#endif
}
+#endif
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
///
void setAutoCollapse(bool f) { autocollapse = f; }
#endif
+#if 0
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
+#endif
///
LyXText * getLyXText(BufferView const *, bool const recursive) 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;
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()
{
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;
+}
#endif
///
bool sgmlConvertChar(char c, string & sgml_string);
+ ///
+ bool isFreeSpacing() const;
ParagraphParameters & params();
ParagraphParameters const & params() const;
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
&& (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
}
int tmp = inset->latex(buf, os, moving_arg,
- style.free_spacing);
+ style.free_spacing);
if (close)
os << "}";
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) {
// 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;