Fixed cut&paste bugs and added freespacing for ERT Insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3115 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-11-29 16:29:30 +00:00
parent c968dac821
commit fcb37cc693
12 changed files with 68 additions and 14 deletions

View File

@ -1,5 +1,15 @@
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

View File

@ -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;
}

View File

@ -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;

View File

@ -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 <poenitz@gmx.net>

View File

@ -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,

View File

@ -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;
///

View File

@ -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;

View File

@ -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;
}

View File

@ -334,6 +334,8 @@ public:
#endif
///
bool sgmlConvertChar(char c, string & sgml_string);
///
bool isFreeSpacing() const;
ParagraphParameters & params();
ParagraphParameters const & params() const;

View File

@ -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 << "}";

View File

@ -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) {

View File

@ -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;