From b8dd79b64d49fc0136579341a213eb1278966b67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 31 Mar 2000 10:35:53 +0000 Subject: [PATCH] Various small fixes, look in ChangeLog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@636 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 17 +++++++++++++++++ src/BufferView2.C | 13 +++++++++++++ src/insets/inset.C | 7 +++++++ src/insets/insetcollapsable.C | 4 +++- src/insets/insetcommand.C | 4 ++-- src/insets/insetfoot.C | 4 +++- src/insets/insettext.C | 14 ++++---------- src/insets/lyxinset.h | 6 +++++- src/lyxfunc.C | 13 +++++++++---- src/paragraph.C | 20 ++++++++++++++++++-- 10 files changed, 81 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a3643c01b..2ec7f801cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2000-03-31 Juergen Vigna + + * src/paragraph.C (GetInset): commented out text[pos] = ' ' + (Clone): changed mode how the paragraph-data is copied to the + new clone-paragraph. + + * src/lyxfunc.C (Dispatch): fixed small problem when calling + GetInset(pos) with no inset anymore there (in inset UNDO) + + * src/insets/insetcommand.C (draw): small fix as here x is + incremented not as much as width() returns (2 before, 2 behind = 4) + +2000-03-30 Juergen Vigna + + * src/insets/insettext.C (InsetText): small fix in initialize + widthOffset (should not be done in the init() function) + 2000-03-29 Amir Karger * lib/examples/it_ItemizeBullets.lyx: translation by diff --git a/src/BufferView2.C b/src/BufferView2.C index 956f0f0353..6aa4869c32 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -230,6 +230,19 @@ void BufferView::insertInset(Inset * inset, string const & lout, } text->InsertInset(inset); +#if 1 + // if we enter a text-inset the cursor should be to the left side + // of it! This couldn't happen before as Undo was not handled inside + // inset now after the Undo LyX tries to call inset->Edit(...) again + // and cannot do this as the cursor is behind the inset and GetInset + // does not return the inset! + if (inset->IsTextInset()) { + if (text->cursor.par->getParDirection()==LYX_DIR_LEFT_TO_RIGHT) + text->CursorLeft(); + else + text->CursorRight(); + } +#endif update(-1); text->UnFreezeUndo(); diff --git a/src/insets/inset.C b/src/insets/inset.C index 0c9d6602b2..bf30dfd85d 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -41,6 +41,13 @@ Inset::EDITABLE Inset::Editable() const return NOT_EDITABLE; } +bool Inset::IsTextInset() const +{ + return ((LyxCode() == TEXT_CODE) || + (LyxCode() == ERT_CODE) || + (LyxCode() == FOOT_CODE) || + (LyxCode() == MARGIN_CODE)); +} void Inset::Validate(LaTeXFeatures &) const { diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index ba13a0c950..532abb133b 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -20,7 +20,8 @@ #include "Painter.h" -InsetCollapsable::InsetCollapsable(Buffer * bf): InsetText(bf) +InsetCollapsable::InsetCollapsable(Buffer * bf) + : InsetText(bf) { collapsed = true; label = "Label"; @@ -37,6 +38,7 @@ Inset * InsetCollapsable::Clone() const InsetCollapsable * result = new InsetCollapsable(buffer); result->init(buffer, par); + result->collapsed = collapsed; return result; } diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 0a566e3463..3fada648cf 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -89,7 +89,7 @@ int InsetCommand::width(Painter & pain, LyXFont const &) const LColor::commandbg, LColor::commandframe, false, width, ascent, descent); } - return width+4; + return width + 4; } @@ -111,7 +111,7 @@ void InsetCommand::draw(Painter & pain, LyXFont const &, true, width); } - x += width; + x += width + 4; } diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index 05087bb391..37a294aef8 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -21,7 +21,8 @@ #include "Painter.h" -InsetFoot::InsetFoot(Buffer * bf): InsetCollapsable(bf) +InsetFoot::InsetFoot(Buffer * bf) + : InsetCollapsable(bf) { setLabel(_("foot")); LyXFont font(LyXFont::ALL_SANE); @@ -38,6 +39,7 @@ Inset * InsetFoot::Clone() const InsetFoot * result = new InsetFoot(buffer); result->init(buffer, par); + result->collapsed = collapsed; return result; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 54083dbacb..f3c0367203 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -60,6 +60,7 @@ extern unsigned char getCurrentTextClass(Buffer *); InsetText::InsetText(Buffer * buf) { par = new LyXParagraph(); + widthOffset = 0; init(buf); } @@ -67,6 +68,7 @@ InsetText::InsetText(Buffer * buf) InsetText::InsetText(InsetText const & ins, Buffer * buf) { par = 0; + widthOffset = 0; init(buf, ins.par); } @@ -75,15 +77,7 @@ void InsetText::init(Buffer * buf, LyXParagraph *p) if (p) { if (par) delete par; - par = new LyXParagraph(p); - for(int pos = 0; pos < p->Last(); ++pos) { - par->InsertChar(pos, p->GetChar(pos)); - par->SetFont(pos, p->GetFontSettings(pos)); - if ((p->GetChar(pos) == LyXParagraph::META_INSET) && - p->GetInset(pos)) { - par->InsertInset(pos, p->GetInset(pos)->Clone()); - } - } + par = p->Clone(); } the_locking_inset = 0; buffer = buf; @@ -93,7 +87,7 @@ void InsetText::init(Buffer * buf, LyXParagraph *p) interline_space = 1; no_selection = false; init_inset = true; - maxAscent = maxDescent = insetWidth = widthOffset = 0; + maxAscent = maxDescent = insetWidth = 0; autoBreakRows = false; xpos = 0.0; } diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index dd6b1bc3a3..bf45450c71 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -83,6 +83,8 @@ public: /// TEXT_CODE, /// + ERT_CODE, + /// FOOT_CODE, /// MARGIN_CODE, @@ -116,6 +118,8 @@ public: /// virtual EDITABLE Editable() const; /// + bool IsTextInset() const; + /// virtual bool AutoDelete() const; /// virtual void Write(ostream &) const = 0; @@ -140,7 +144,7 @@ public: virtual bool Deletable() const; /// returns LyX code associated with the inset. Used for TOC, ...) - virtual Inset::Code LyxCode() const = 0; + virtual Inset::Code LyxCode() const { return NO_CODE; } /// Get the label that appears at screen virtual string getLabel(int) const { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 8a40823412..11bcf8ba29 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -532,10 +532,15 @@ string LyXFunc::Dispatch(int ac, inset->GetCursorPos(slx, sly); owner->view()->unlockInset(inset); owner->view()->menuUndo(); - inset = static_cast( - owner->view()->text->cursor.par-> - GetInset(owner->view()->text-> - cursor.pos)); + if (owner->view()->text->cursor.par-> + IsInset(owner->view()->text->cursor.pos)) { + inset = static_cast( + owner->view()->text->cursor.par-> + GetInset(owner->view()->text-> + cursor.pos)); + } else { + inset = 0; + } if (inset) inset->Edit(owner->view(),slx,sly,0); return string(); diff --git a/src/paragraph.C b/src/paragraph.C index 3678cf6084..12cb47523c 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -659,7 +659,7 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos) } lyxerr << "ERROR (LyXParagraph::GetInset): " "Inset does not exist: " << pos << endl; - text[pos] = ' '; // WHY!!! does this set the pos to ' '???? + // text[pos] = ' '; // WHY!!! does this set the pos to ' '???? // Did this commenting out introduce a bug? So far I have not // see any, please enlighten me. (Lgb) // My guess is that since the inset does not exist, we might @@ -1477,11 +1477,27 @@ LyXParagraph * LyXParagraph::Clone() const // copy everything behind the break-position to the new paragraph - + + // IMO this is not correct. Here we should not use the Minibuffer to + // copy stuff, as the Minibuffer is global and we could be in a + // situation where we copy a paragraph inside a paragraph (this now + // is possible think of Text-Insets!). So I'm changing this so that + // then inside the Text-Inset I can use par->Clone() to copy the + // paragraph data from one inset to the other! +#if 0 for (size_type i = 0; i < size(); ++i) { CopyIntoMinibuffer(i); result->InsertFromMinibuffer(i); } +#else + for(size_type i = 0; i < size(); ++i) { + result->InsertChar(i, GetChar(i)); + result->SetFont(i, GetFontSettings(i)); + if ((GetChar(i) == LyXParagraph::META_INSET) && GetInset(i)) { + result->InsertInset(i, GetInset(i)->Clone()); + } + } +#endif result->text.resize(result->text.size()); return result; } -- 2.39.2