+
+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>
* lfuns.h:
all_erased = false;
// Loop through the deleted pars if any, erasing as needed
-
- par_type pit = startpit + 1;
-
- while (pit != endpit && pit != par_type(pars.size())) {
- par_type const next = pit + 1;
+ for (par_type pit = startpit + 1; pit != endpit;) {
// "erase" the contents of the par
pars[pit].erase(0, pars[pit].size());
if (!pars[pit].size()) {
// remove the par if it's now empty
pars.erase(pars.begin() + pit);
- } else
+ --endpit;
+ } else {
+ ++pit;
all_erased = false;
- pit = next;
+ }
}
#if 0 // FIXME: why for cut but not copy ?
// Paste it!
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);
+ par_type last_paste = pit + insertion.size() - 1;
+
// Store the new cursor position.
pit = last_paste;
pos = pars[last_paste].size();
pars[last_paste + 1].makeSameLayout(pars[last_paste]);
mergeParagraph(buffer.params(), pars, last_paste);
} 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);
- } else
+ } else {
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);
}
-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
ouside offset to collapsable. Clean code a bit.
size_t nargs() const { return 1; }
///
ParagraphList & paragraphs() const;
-
+ ///
+ bool insetAllowed(Code) const { return true; }
+
protected:
///
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
// copy everything behind the break-position
// to the new paragraph
-#ifdef WITH_WARNINGS
-#warning this seems wrong
-#endif
- /* FIXME: if !keepempty, empty() == true, then we reach
- * here with size() == 0. So pos_end becomes - 1. Why
- * doesn't this cause problems ???
+ /* Note: if !keepempty, empty() == true, then we reach
+ * here with size() == 0. So pos_end becomes - 1. This
+ * doesn't cause problems because both loops below
+ * enforce pos <= pos_end and 0 <= pos
*/
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);
if (moveItem(pars[par], *tmp, bparams, i, j - pos)) {
tmp->setChange(j - pos, change);
}
}
- for (i = pos_end; i >= pos; --i)
+ for (pos_type i = pos_end; i >= pos; --i)
pars[par].eraseIntern(i);
}