mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
fixes 3 c&p crashes, and a vanishing insets bug fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8553 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
39ec3d0eb8
commit
979a4d8ecf
@ -1,3 +1,10 @@
|
|||||||
|
|
||||||
|
2004-03-28 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* CutAndPaste.C (pasteSelection): fix 2 crashes
|
||||||
|
(eraseSelection): fix a crash
|
||||||
|
* paragraph_funcs.C: remove a warning
|
||||||
|
|
||||||
2004-03-28 Angus Leeming <leeming@lyx.org>
|
2004-03-28 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* lfuns.h:
|
* lfuns.h:
|
||||||
|
@ -161,19 +161,17 @@ PitPosPair eraseSelection(BufferParams const & params, ParagraphList & pars,
|
|||||||
all_erased = false;
|
all_erased = false;
|
||||||
|
|
||||||
// Loop through the deleted pars if any, erasing as needed
|
// Loop through the deleted pars if any, erasing as needed
|
||||||
|
for (par_type pit = startpit + 1; pit != endpit;) {
|
||||||
par_type pit = startpit + 1;
|
|
||||||
|
|
||||||
while (pit != endpit && pit != par_type(pars.size())) {
|
|
||||||
par_type const next = pit + 1;
|
|
||||||
// "erase" the contents of the par
|
// "erase" the contents of the par
|
||||||
pars[pit].erase(0, pars[pit].size());
|
pars[pit].erase(0, pars[pit].size());
|
||||||
if (!pars[pit].size()) {
|
if (!pars[pit].size()) {
|
||||||
// remove the par if it's now empty
|
// remove the par if it's now empty
|
||||||
pars.erase(pars.begin() + pit);
|
pars.erase(pars.begin() + pit);
|
||||||
} else
|
--endpit;
|
||||||
|
} else {
|
||||||
|
++pit;
|
||||||
all_erased = false;
|
all_erased = false;
|
||||||
pit = next;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // FIXME: why for cut but not copy ?
|
#if 0 // FIXME: why for cut but not copy ?
|
||||||
@ -333,14 +331,10 @@ pasteSelection(Buffer const & buffer, ParagraphList & pars,
|
|||||||
|
|
||||||
// Paste it!
|
// Paste it!
|
||||||
pars.insert(pars.begin() + pit + 1, insertion.begin(), insertion.end());
|
pars.insert(pars.begin() + pit + 1, insertion.begin(), insertion.end());
|
||||||
par_type last_paste = pit + insertion.size();
|
|
||||||
|
|
||||||
// If we only inserted one paragraph.
|
|
||||||
if (insertion.size() == 1)
|
|
||||||
last_paste = pit;
|
|
||||||
|
|
||||||
mergeParagraph(buffer.params(), pars, pit);
|
mergeParagraph(buffer.params(), pars, pit);
|
||||||
|
|
||||||
|
par_type last_paste = pit + insertion.size() - 1;
|
||||||
|
|
||||||
// Store the new cursor position.
|
// Store the new cursor position.
|
||||||
pit = last_paste;
|
pit = last_paste;
|
||||||
pos = pars[last_paste].size();
|
pos = pars[last_paste].size();
|
||||||
@ -353,13 +347,15 @@ pasteSelection(Buffer const & buffer, ParagraphList & pars,
|
|||||||
pars[last_paste + 1].makeSameLayout(pars[last_paste]);
|
pars[last_paste + 1].makeSameLayout(pars[last_paste]);
|
||||||
mergeParagraph(buffer.params(), pars, last_paste);
|
mergeParagraph(buffer.params(), pars, last_paste);
|
||||||
} else if (pars[last_paste].empty()) {
|
} else if (pars[last_paste].empty()) {
|
||||||
pars[last_paste].makeSameLayout(pars[last_paste]);
|
pars[last_paste].makeSameLayout(pars[last_paste + 1]);
|
||||||
mergeParagraph(buffer.params(), pars, last_paste);
|
mergeParagraph(buffer.params(), pars, last_paste);
|
||||||
} else
|
} else {
|
||||||
pars[last_paste + 1].stripLeadingSpaces();
|
pars[last_paste + 1].stripLeadingSpaces();
|
||||||
|
++last_paste;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return make_pair(PitPosPair(pit, pos), pit + insertion.size() + 1);
|
return make_pair(PitPosPair(pit, pos), last_paste + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
2004-03-27 Alfredo Braunstein <abraunst@lyx.org>
|
|
||||||
|
2004-03-28 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* insettext.h: add insetAllowed returning true by default (fixing
|
||||||
|
vanishing insets problem)
|
||||||
|
|
||||||
* insettext.C (draw): handle the responsability of adding the
|
* insettext.C (draw): handle the responsability of adding the
|
||||||
ouside offset to collapsable. Clean code a bit.
|
ouside offset to collapsable. Clean code a bit.
|
||||||
|
@ -142,7 +142,9 @@ public:
|
|||||||
size_t nargs() const { return 1; }
|
size_t nargs() const { return 1; }
|
||||||
///
|
///
|
||||||
ParagraphList & paragraphs() const;
|
ParagraphList & paragraphs() const;
|
||||||
|
///
|
||||||
|
bool insetAllowed(Code) const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
|
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
|
||||||
|
@ -126,18 +126,14 @@ void breakParagraph(BufferParams const & bparams,
|
|||||||
// copy everything behind the break-position
|
// copy everything behind the break-position
|
||||||
// to the new paragraph
|
// to the new paragraph
|
||||||
|
|
||||||
#ifdef WITH_WARNINGS
|
/* Note: if !keepempty, empty() == true, then we reach
|
||||||
#warning this seems wrong
|
* here with size() == 0. So pos_end becomes - 1. This
|
||||||
#endif
|
* doesn't cause problems because both loops below
|
||||||
/* FIXME: if !keepempty, empty() == true, then we reach
|
* enforce pos <= pos_end and 0 <= pos
|
||||||
* here with size() == 0. So pos_end becomes - 1. Why
|
|
||||||
* doesn't this cause problems ???
|
|
||||||
*/
|
*/
|
||||||
pos_type pos_end = pars[par].size() - 1;
|
pos_type pos_end = pars[par].size() - 1;
|
||||||
pos_type i = pos;
|
|
||||||
pos_type j = pos;
|
|
||||||
|
|
||||||
for (; i <= pos_end; ++i) {
|
for (pos_type i = pos, j = pos; i <= pos_end; ++i) {
|
||||||
Change::Type change = pars[par].lookupChange(i);
|
Change::Type change = pars[par].lookupChange(i);
|
||||||
if (moveItem(pars[par], *tmp, bparams, i, j - pos)) {
|
if (moveItem(pars[par], *tmp, bparams, i, j - pos)) {
|
||||||
tmp->setChange(j - pos, change);
|
tmp->setChange(j - pos, change);
|
||||||
@ -145,7 +141,7 @@ void breakParagraph(BufferParams const & bparams,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = pos_end; i >= pos; --i)
|
for (pos_type i = pos_end; i >= pos; --i)
|
||||||
pars[par].eraseIntern(i);
|
pars[par].eraseIntern(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user