void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
- textclass_type textclass)
+ textclass_type textclass, ErrorList & errorList)
{
if (cur.inTexted()) {
LyXText * text = cur.text();
pit_type endpit;
PitPosPair ppp;
- ErrorList el;
boost::tie(ppp, endpit) =
pasteSelectionHelper(cur.buffer(),
text->paragraphs(),
cur.pit(), cur.pos(),
parlist, textclass,
- el);
- bufferErrors(cur.buffer(), el);
+ errorList);
updateLabels(cur.buffer());
cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second);
}
-void pasteSelection(LCursor & cur, size_t sel_index)
+void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
{
// this does not make sense, if there is nothing to paste
if (!checkPastePossible(sel_index))
return;
pasteParagraphList(cur, theCuts[sel_index].first,
- theCuts[sel_index].second);
- cur.bv().owner()->showErrorList(_("Paste"));
- cur.setSelection();
-}
-
-
-void setSelectionRange(LCursor & cur, pos_type length)
-{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
- if (!length)
- return;
- cur.resetAnchor();
- while (length--)
- text->cursorRight(cur);
+ theCuts[sel_index].second, errorList);
cur.setSelection();
}
// simple replacing. The font of the first selected character is used
-void replaceSelectionWithString(LCursor & cur, string const & str)
+void replaceSelectionWithString(LCursor & cur, string const & str, bool backwards)
{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
recordUndo(cur);
+ DocIterator selbeg = cur.selectionBegin();
// Get font setting before we cut
- pos_type pos = cur.selEnd().pos();
- Paragraph & par = text->getPar(cur.selEnd().pit());
LyXFont const font =
- par.getFontSettings(cur.buffer().params(), cur.selBegin().pos());
+ selbeg.paragraph().getFontSettings(cur.buffer().params(), selbeg.pos());
// Insert the new string
+ pos_type pos = cur.selEnd().pos();
+ Paragraph & par = cur.selEnd().paragraph();
string::const_iterator cit = str.begin();
string::const_iterator end = str.end();
for (; cit != end; ++cit, ++pos)
// Cut the selection
cutSelection(cur, true, false);
+
+ // select the replacement
+ if (backwards) {
+ selbeg.pos() += str.length();
+ cur.setSelection(selbeg, -str.length());
+ } else
+ cur.setSelection(selbeg, str.length());
}
}
-// only used by the spellchecker
-void replaceWord(LCursor & cur, string const & replacestring)
-{
- LyXText * text = cur.text();
- BOOST_ASSERT(text);
-
- replaceSelectionWithString(cur, replacestring);
- setSelectionRange(cur, replacestring.length());
-
- // Go back so that replacement string is also spellchecked
- for (string::size_type i = 0; i < replacestring.length() + 1; ++i)
- text->cursorLeft(cur);
-}
-
-
void eraseSelection(LCursor & cur)
{
//lyxerr << "LCursor::eraseSelection begin: " << cur << endl;