X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCutAndPaste.cpp;h=ccde5878f9255c7eeb0bda2d6d81280b0103e228;hb=57b69a5efddf9f3c148007322f00dad6c253a2ed;hp=6333892cd6cc6e2d1bfe6729a50657f46cc56fab;hpb=c5782ff4bbf0129b8ef95c92b33560d67e593024;p=lyx.git diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 6333892cd6..ccde5878f9 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -60,16 +60,16 @@ #include "support/lassert.h" #include "support/limited_stack.h" #include "support/lstrings.h" +#include "support/lyxalgo.h" #include "support/TempFile.h" +#include "support/unique_ptr.h" #include "frontends/alert.h" #include "frontends/Clipboard.h" #include "frontends/Selection.h" -#include -#include - #include +#include using namespace std; using namespace lyx::support; @@ -100,11 +100,11 @@ bool checkPastePossible(int index) struct PasteReturnValue { - PasteReturnValue(pit_type r_par, pos_type r_pos, bool r_nu) : - par(r_par), pos(r_pos), needupdate(r_nu) + PasteReturnValue(pit_type r_pit, pos_type r_pos, bool r_nu) : + pit(r_pit), pos(r_pos), needupdate(r_nu) {} - pit_type par; + pit_type pit; pos_type pos; bool needupdate; }; @@ -387,7 +387,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist, // Paste it! if (empty) { - pars.insert(boost::next(pars.begin(), pit), + pars.insert(lyx::next(pars.begin(), pit), insertion.begin(), insertion.end()); @@ -395,7 +395,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist, mergeParagraph(buffer.params(), pars, pit + insertion.size() - 1); } else { - pars.insert(boost::next(pars.begin(), pit + 1), + pars.insert(lyx::next(pars.begin(), pit + 1), insertion.begin(), insertion.end()); @@ -599,8 +599,8 @@ void copySelectionHelper(Buffer const & buf, Text const & text, LASSERT(startpit != endpit || start <= end, return); // Clone the paragraphs within the selection. - ParagraphList copy_pars(boost::next(pars.begin(), startpit), - boost::next(pars.begin(), endpit + 1)); + ParagraphList copy_pars(lyx::next(pars.begin(), startpit), + lyx::next(pars.begin(), endpit + 1)); // Remove the end of the last paragraph; afterwards, remove the // beginning of the first paragraph. Keep this order - there may only @@ -811,22 +811,20 @@ vector availableSelections(Buffer const * buf) // we do not use cit-> here because gcc 2.9x does not // like it (JMarc) ParagraphList const & pars = (*cit).first; - docstring asciiSel; + docstring textSel; ParagraphList::const_iterator pit = pars.begin(); ParagraphList::const_iterator pend = pars.end(); for (; pit != pend; ++pit) { - Paragraph par(*pit, 0, 26); + Paragraph par(*pit, 0, 46); // adapt paragraph to current buffer. par.setBuffer(const_cast(*buf)); - asciiSel += par.asString(AS_STR_INSETS); - if (asciiSel.size() > 25) { - asciiSel.replace(22, docstring::npos, - from_ascii("...")); + textSel += par.asString(AS_STR_INSETS); + if (textSel.size() > 45) { + support::truncateWithEllipsis(textSel,45); break; } } - - selList.push_back(asciiSel); + selList.push_back(textSel); } return selList; @@ -877,11 +875,9 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut) if (begpit != endpit) cur.screenUpdateFlags(Update::Force | Update::FitCursor); - boost::tie(endpit, endpos) = - eraseSelectionHelper(bp, - text->paragraphs(), - begpit, endpit, - cur.selBegin().pos(), endpos); + tie(endpit, endpos) = + eraseSelectionHelper(bp, text->paragraphs(), begpit, endpit, + cur.selBegin().pos(), endpos); // cutSelection can invalidate the cursor so we need to set // it anew. (Lgb) @@ -963,20 +959,11 @@ void copySelectionToStack(Cursor const & cur, CutStack & cutstack) LBUFERR(text); // ok we have a selection. This is always between cur.selBegin() // and sel_end cursor - - // copy behind a space if there is one - ParagraphList & pars = text->paragraphs(); - pos_type pos = cur.selBegin().pos(); - pit_type par = cur.selBegin().pit(); - while (pos < pars[par].size() && - pars[par].isLineSeparator(pos) && - (par != cur.selEnd().pit() || pos < cur.selEnd().pos())) - ++pos; - - copySelectionHelper(*cur.buffer(), *text, par, cur.selEnd().pit(), - pos, cur.selEnd().pos(), - cur.buffer()->params().documentClassPtr(), cutstack); - + copySelectionHelper(*cur.buffer(), *text, + cur.selBegin().pit(), cur.selEnd().pit(), + cur.selBegin().pos(), cur.selEnd().pos(), + cur.buffer()->params().documentClassPtr(), + cutstack); // Reset the dirty_tabular_stack_ flag only when something // is copied to the clipboard (not to the selectionBuffer). if (&cutstack == &theCuts) @@ -1066,7 +1053,8 @@ docstring selection(size_t sel_index, DocumentClassConstPtr docclass) if (sel_index >= theCuts.size()) return docstring(); - boost::scoped_ptr buffer(copyToTempBuffer(theCuts[sel_index].first, docclass)); + unique_ptr buffer(copyToTempBuffer(theCuts[sel_index].first, + docclass)); if (!buffer) return docstring(); @@ -1085,7 +1073,7 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist, pasteSelectionHelper(cur, parlist, docclass, 0, errorList); cur.forceBufferUpdate(); cur.clearSelection(); - text->setCursor(cur, prv.par, prv.pos); + text->setCursor(cur, prv.pit, prv.pos); } // mathed is handled in InsetMathNest/InsetMathGrid @@ -1336,7 +1324,7 @@ void selClearOrDel(Cursor & cur) if (lyxrc.auto_region_delete) selDel(cur); else - cur.setSelection(false); + cur.selection(false); }