bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
- int start, int & end, char tc, bool doclear)
+ int start, int & end, char tc, bool doclear,
+ bool realcut)
{
if (!startpar || (start > startpar->size()))
return false;
- DeleteBuffer();
+ if (realcut)
+ DeleteBuffer();
textclass = tc;
- if (!(*endpar) ||
- startpar == (*endpar)) {
+ if (!(*endpar) || startpar == (*endpar)) {
// only within one paragraph
- buf = new Paragraph;
+ if (realcut)
+ buf = new Paragraph;
Paragraph::size_type i = start;
if (end > startpar->size())
end = startpar->size();
for (; i < end; ++i) {
- startpar->copyIntoMinibuffer(*current_view->buffer(),
- start);
+ if (realcut)
+ startpar->copyIntoMinibuffer(*current_view->buffer(),
+ start);
startpar->erase(start);
-
- buf->insertFromMinibuffer(buf->size());
+ if (realcut)
+ buf->insertFromMinibuffer(buf->size());
}
end = start - 1;
} else {
// more than one paragraph
(*endpar)->breakParagraphConservative(current_view->buffer()->params,
- end);
+ end);
*endpar = (*endpar)->next();
end = 0;
startpar->breakParagraphConservative(current_view->buffer()->params,
- start);
+ start);
// store the selection
- buf = startpar->next();
-
- buf->previous(0);
+ if (realcut) {
+ buf = startpar->next();
+ buf->previous(0);
+ } else {
+ startpar->next()->previous(0);
+ }
(*endpar)->previous()->next(0);
// cut the selection
(*endpar)->previous(startpar);
// the cut selection should begin with standard layout
- buf->clear();
+ if (realcut)
+ buf->clear();
// paste the paragraphs again, if possible
if (doclear)
// copy more than one paragraph
// clone the paragraphs within the selection
Paragraph * tmppar = startpar;
- buf = new Paragraph(*tmppar);
+ buf = new Paragraph(*tmppar, false);
Paragraph * tmppar2 = buf;
while (tmppar != endpar
&& tmppar->next()) {
tmppar = tmppar->next();
- tmppar2->next(new Paragraph(*tmppar));
+ tmppar2->next(new Paragraph(*tmppar, false));
tmppar2->next()->previous(tmppar2);
tmppar2 = tmppar2->next();
}
bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
- int & pos, char tc)
+ int & pos, char tc)
{
if (!checkPastePossible(*par))
return false;
// There are two cases: cutbuffer only one paragraph or many
if (!buf->next()) {
// only within a paragraph
- Paragraph * tmpbuf = new Paragraph(*buf);
+ Paragraph * tmpbuf = new Paragraph(*buf, false);
// Some provisions should be done here for checking
// if we are inserting at the beginning of a
// make a copy of the simple cut_buffer
Paragraph * tmpbuf = buf;
- Paragraph * simple_cut_clone = new Paragraph(*tmpbuf);
+ Paragraph * simple_cut_clone = new Paragraph(*tmpbuf, false);
Paragraph * tmpbuf2 = simple_cut_clone;
while (tmpbuf->next()) {
tmpbuf = tmpbuf->next();
- tmpbuf2->next(new Paragraph(*tmpbuf));
+ tmpbuf2->next(new Paragraph(*tmpbuf, false));
tmpbuf2->next()->previous(tmpbuf2);
tmpbuf2 = tmpbuf2->next();
}