remove some debug output, simplyfy pasteSelectionHelper interface

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10234 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-16 00:28:50 +00:00
parent 88d9527776
commit ef68cb1128

View File

@ -99,14 +99,19 @@ bool checkPastePossible(int index)
}
pair<PitPosPair, pit_type>
pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
pit_type pit, int pos,
textclass_type tc, size_t cut_index, ErrorList & errorlist)
void pasteSelectionHelper(LCursor & cur, size_t cut_index)
{
if (!checkPastePossible(cut_index))
return make_pair(PitPosPair(pit, pos), pit);
recordUndo(cur);
Buffer const & buffer = cur.buffer();
InsetText & inset = static_cast<InsetText &>(cur.inset());
pit_type pit = cur.pit();
pos_type pos = cur.pos();
pit_type endpit = pit;
textclass_type const & tc = buffer.params().textclass;
ErrorList errorlist;
if (checkPastePossible(cut_index)) {
ParagraphList & pars = inset.paragraphs();
BOOST_ASSERT (pos <= pars[pit].size());
// Make a copy of the CaP paragraphs.
@ -163,7 +168,7 @@ pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
tmpbuf->setInsetOwner(pars[pit].inInset());
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
!inset.insetAllowed(tmpbuf->getInset(i)->lyxCode()))
tmpbuf->erase(i--);
}
}
@ -244,7 +249,17 @@ pasteSelectionHelper(Buffer const & buffer, ParagraphList & pars,
}
}
return make_pair(PitPosPair(pit, pos), last_paste + 1);
endpit = last_paste + 1;
}
bufferErrors(cur.buffer(), errorlist);
cur.bv().showErrorList(_("Paste"));
cur.clearSelection();
cur.resetAnchor();
BOOST_ASSERT(cur.text());
cur.text()->setCursor(cur, pit, pos);
cur.setSelection();
updateCounters(cur.buffer());
}
@ -342,23 +357,9 @@ void copySelectionHelper(ParagraphList & pars,
theCuts.push(make_pair(paragraphs, tc));
}
PitPosPair cutSelectionHelper(BufferParams const & params,
ParagraphList & pars, pit_type startpit, pit_type endpit,
int startpos, int endpos, textclass_type tc, bool doclear)
{
copySelectionHelper(pars, startpit, endpit, startpos, endpos, tc);
return eraseSelectionHelper(params, pars, startpit, endpit,
startpos, endpos, doclear);
}
} // namespace anon
namespace lyx {
namespace cap {
@ -575,7 +576,7 @@ void copySelection(LCursor & cur)
}
if (cur.inMathed()) {
lyxerr << "copySelection in mathed" << endl;
//lyxerr << "copySelection in mathed" << endl;
ParagraphList pars;
pars.push_back(Paragraph());
BufferParams const & bp = cur.buffer().params();
@ -598,41 +599,13 @@ std::string getSelection(Buffer const & buf, size_t sel_index)
void pasteSelection(LCursor & cur, size_t sel_index)
{
// this does not make sense, if there is nothing to paste
lyxerr << "#### pasteSelection " << sel_index << endl;
if (!checkPastePossible(sel_index))
return;
if (cur.inTexted()) {
LyXText * text = cur.text();
BOOST_ASSERT(text);
recordUndo(cur);
pit_type endpit;
PitPosPair ppp;
ErrorList el;
boost::tie(ppp, endpit) =
pasteSelectionHelper(cur.buffer(),
text->paragraphs(),
cur.pit(), cur.pos(),
cur.buffer().params().textclass,
sel_index, el);
bufferErrors(cur.buffer(), el);
cur.bv().showErrorList(_("Paste"));
cur.clearSelection();
cur.resetAnchor();
text->setCursor(cur, ppp.first, ppp.second);
cur.setSelection();
updateCounters(cur.buffer());
}
if (cur.inMathed()) {
if (cur.inTexted())
pasteSelectionHelper(cur, sel_index);
if (cur.inMathed())
lyxerr << "### should be handled in MathNest/GridInset" << endl;
}
}
void setSelectionRange(LCursor & cur, pos_type length)