// then do a middle mouse button click in the application you want and have
// the whole formula there in LaTeX-Code. (Jug)
-static LyXParagraph * buf = 0;
-static LyXTextClassList::size_type textclass = 0;
+namespace {
+
+LyXParagraph * buf = 0;
+LyXTextClassList::size_type textclass = 0;
// for now here this should be in another Cut&Paste Class!
// Jürgen, I moved this out of CutAndPaste since it does not operate on any
// member of the CutAndPaste class and in addition it was private.
// Perhaps it even should take a parameter? (Lgb)
-static
void DeleteBuffer()
{
if (!buf)
buf = 0;
}
+} // namespace anon
bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
int start, int & end, char tc, bool doclear)
{
+#ifndef NEW_INSETS
if (!startpar || (start > startpar->Last()))
return false;
+#else
+ if (!startpar || (start > startpar->size()))
+ return false;
+#endif
DeleteBuffer();
// only within one paragraph
buf = new LyXParagraph;
LyXParagraph::size_type i = start;
+#ifndef NEW_INSETS
if (end > startpar->Last())
end = startpar->Last();
+#else
+ if (end > startpar->size())
+ end = startpar->size();
+#endif
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(*current_view->buffer(), start);
startpar->Erase(start);
+#ifndef NEW_INSETS
buf->InsertFromMinibuffer(buf->Last());
+#else
+ buf->InsertFromMinibuffer(buf->size());
+#endif
}
end = start-1;
} else {
startpar->next()->StripLeadingSpaces(textclass);
#ifndef NEW_INSETS
if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->next()) ||
+ !startpar->next()->Last()) {
#else
if (startpar->HasSameLayout(startpar->next()) ||
+ !startpar->next()->size()) {
#endif
- !startpar->next()->Last()) {
#ifndef NEW_INSETS
startpar->ParFromPos(start)->PasteParagraph(current_view->buffer()->params);
#else
bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
int start, int end, char tc)
{
+#ifndef NEW_INSETS
if (!startpar || (start > startpar->Last()))
return false;
+#else
+ if (!startpar || (start > startpar->size()))
+ return false;
+#endif
DeleteBuffer();
// only within one paragraph
buf = new LyXParagraph;
LyXParagraph::size_type i = start;
+#ifndef NEW_INSETS
if (end > startpar->Last())
end = startpar->Last();
+#else
+ if (end > startpar->size())
+ end = startpar->size();
+#endif
for (; i < end; ++i) {
startpar->CopyIntoMinibuffer(*current_view->buffer(), i);
+#ifndef NEW_INSETS
buf->InsertFromMinibuffer(buf->Last());
+#else
+ buf->InsertFromMinibuffer(buf->size());
+#endif
}
} else {
// copy more than one paragraph
bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
int & pos, char tc)
{
- if (!checkPastePossible(*par, pos))
+ if (!checkPastePossible(*par))
return false;
+#ifndef NEW_INSETS
if (pos > (*par)->Last())
pos = (*par)->Last();
-
+#else
+ if (pos > (*par)->size())
+ pos = (*par)->size();
+#endif
+
LyXParagraph * tmpbuf;
LyXParagraph * tmppar = *par;
int tmppos = pos;
bool paste_the_end = false;
+#ifndef NEW_INSETS
// open the paragraph for inserting the buf
// if necessary
if (((*par)->Last() > pos) || !(*par)->next()) {
pos);
paste_the_end = true;
}
-
// set the end for redoing later
-#ifndef NEW_INSETS
*endpar = (*par)->ParFromPos(pos)->next_->next();
// paste it!
lastbuffer = *par;
(*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params);
+ // store the new cursor position
+ *par = lastbuffer;
+ pos = lastbuffer->Last();
+ // maybe some pasting
+ if (lastbuffer->next() && paste_the_end) {
+ if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else if (!lastbuffer->next()->Last()) {
+ lastbuffer->next()->MakeSameLayout(lastbuffer);
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else if (!lastbuffer->Last()) {
+ lastbuffer->MakeSameLayout(lastbuffer->next_);
+ lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
+ } else
+ lastbuffer->next()->StripLeadingSpaces(tc);
+ }
+ // restore the simple cut buffer
+ buf = simple_cut_clone;
+ }
#else
+ // open the paragraph for inserting the buf
+ // if necessary
+ if (((*par)->size() > pos) || !(*par)->next()) {
+ (*par)->BreakParagraphConservative(current_view->buffer()->params,
+ pos);
+ paste_the_end = true;
+ }
+ // set the end for redoing later
*endpar = (*par)->next()->next();
// paste it!
lastbuffer = *par;
(*par)->PasteParagraph(current_view->buffer()->params);
-#endif
// store the new cursor position
*par = lastbuffer;
- pos = lastbuffer->Last();
-
+ pos = lastbuffer->size();
// maybe some pasting
if (lastbuffer->next() && paste_the_end) {
-#ifndef NEW_INSETS
- if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->next()->Last()) {
- lastbuffer->next()->MakeSameLayout(lastbuffer);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->Last()) {
- lastbuffer->MakeSameLayout(lastbuffer->next_);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
-#else
if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
lastbuffer->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->next()->Last()) {
+ } else if (!lastbuffer->next()->size()) {
lastbuffer->next()->MakeSameLayout(lastbuffer);
lastbuffer->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->Last()) {
+ } else if (!lastbuffer->size()) {
lastbuffer->MakeSameLayout(lastbuffer->next());
lastbuffer->PasteParagraph(current_view->buffer()->params);
-#endif
} else
lastbuffer->next()->StripLeadingSpaces(tc);
}
// restore the simple cut buffer
buf = simple_cut_clone;
}
+#endif
return true;
}
}
-bool CutAndPaste::checkPastePossible(LyXParagraph * par, int)
+bool CutAndPaste::checkPastePossible(LyXParagraph * par)
{
if (!buf) return false;