cut'n paste buffer. Now this buffer is not touched by this operations.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2454
a592a061-630c-0410-9148-
cb99ea01b6c8
+ void cut(bool realcut = true);
+void BufferView::cut(bool realcut)
{
if (available()) {
hideCursor();
update(text, BufferView::SELECT|BufferView::FITCUR);
{
if (available()) {
hideCursor();
update(text, BufferView::SELECT|BufferView::FITCUR);
- text->cutSelection(this);
+ text->cutSelection(this, true, realcut);
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
owner()->message(_("Cut"));
}
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
owner()->message(_("Cut"));
}
// just comment out the line below...
showCursor();
} else {
// just comment out the line below...
showCursor();
} else {
}
moveCursorUpdate(false);
owner_->showState();
}
moveCursorUpdate(false);
owner_->showState();
| BufferView::CHANGE);
}
} else {
| BufferView::CHANGE);
}
} else {
}
owner_->showState();
setState();
}
owner_->showState();
setState();
| BufferView::CHANGE);
}
} else
| BufferView::CHANGE);
}
} else
if (lyxrc.auto_region_delete) {
if (lt->selection.set()) {
if (lyxrc.auto_region_delete) {
if (lt->selection.set()) {
- lt->cutSelection(bv_, false);
+ lt->cutSelection(bv_, false, false);
bv_->update(lt,
BufferView::SELECT
| BufferView::FITCUR
bv_->update(lt,
BufferView::SELECT
| BufferView::FITCUR
2001-08-08 Juergen Vigna <jug@sad.it>
2001-08-08 Juergen Vigna <jug@sad.it>
+ * BufferView_pimpl.C (Dispatch): use a non-cut-buffer cut on DELTE
+ BACKSPACE type functions.
+
+ * CutAndPaste.C (cutSelection): added a bool so that the stuff actually
+ is only cutted from the document but not put in the cut-buffer, where
+ still the old stuff should be.
+
+ * text2.C (cutSelection): added bool to pass to CutAndPaste::cutSelection.
+
+ * BufferView2.C (cut): added a bool to pass to LyXText::cutSelection.
+
* tabular.C (SetWidthOfCell): fixed special case where the width
was not updated!
(LeftLine): handle '|' in align_special.
* tabular.C (SetWidthOfCell): fixed special case where the width
was not updated!
(LeftLine): handle '|' in align_special.
bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
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;
{
if (!startpar || (start > startpar->size()))
return false;
+ if (realcut)
+ DeleteBuffer();
- if (!(*endpar) ||
- startpar == (*endpar)) {
+ if (!(*endpar) || startpar == (*endpar)) {
// only within one paragraph
// only within one paragraph
+ if (realcut)
+ buf = new Paragraph;
Paragraph::size_type i = start;
if (end > startpar->size())
end = startpar->size();
for (; i < end; ++i) {
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);
-
- 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 = start - 1;
} else {
// more than one paragraph
(*endpar)->breakParagraphConservative(current_view->buffer()->params,
*endpar = (*endpar)->next();
end = 0;
startpar->breakParagraphConservative(current_view->buffer()->params,
*endpar = (*endpar)->next();
end = 0;
startpar->breakParagraphConservative(current_view->buffer()->params,
- 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()->next(0);
// cut the selection
(*endpar)->previous(startpar);
// the cut selection should begin with standard layout
(*endpar)->previous(startpar);
// the cut selection should begin with standard layout
+ if (realcut)
+ buf->clear();
// paste the paragraphs again, if possible
if (doclear)
// paste the paragraphs again, if possible
if (doclear)
///
static
bool cutSelection(Paragraph * startpar, Paragraph ** endpar,
///
static
bool cutSelection(Paragraph * startpar, Paragraph ** endpar,
- int start, int & end, char tc, bool doclear = false);
+ int start, int & end, char tc, bool doclear = false,
+ bool realcut = true);
///
static
bool copySelection(Paragraph * startpar, Paragraph * endpar,
///
static
bool copySelection(Paragraph * startpar, Paragraph * endpar,
///
void toggleInset(BufferView *);
///
///
void toggleInset(BufferView *);
///
- void cutSelection(BufferView *, bool = true);
+ void cutSelection(BufferView *, bool doclear = true, bool realcut = true);
///
void copySelection(BufferView *);
///
///
void copySelection(BufferView *);
///
setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
selection.cursor = cursor;
cursor = tmpcursor;
setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
selection.cursor = cursor;
cursor = tmpcursor;
/* -----> Great, CutSelection() gets rid of multiple spaces. */
/* -----> Great, CutSelection() gets rid of multiple spaces. */
+ cutSelection(bview, true, false);
selection.cursor = cursor;
cursor = tmpcursor;
setSelection(bview);
selection.cursor = cursor;
cursor = tmpcursor;
setSelection(bview);
+ cutSelection(bview, true, false);
if (!selection.set()) {
deleteWordForward(bview);
} else {
if (!selection.set()) {
deleteWordForward(bview);
} else {
+ cutSelection(bview, true, false);
if ((cursor.par()->previous() ? cursor.par()->previous()->id() : 0)
== old_cur_par_prev_id
&& cursor.par()->id() != old_cur_par_id)
if ((cursor.par()->previous() ? cursor.par()->previous()->id() : 0)
== old_cur_par_prev_id
&& cursor.par()->id() != old_cur_par_id)
return; // delete-empty-paragraph-mechanism has done it
return; // delete-empty-paragraph-mechanism has done it
// if you had success make a backspace
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
// if you had success make a backspace
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
if (cursor.par()->previous()) {
setUndo(bview, Undo::DELETE,
if (cursor.par()->previous()) {
setUndo(bview, Undo::DELETE,
- cursor.par()->previous(),
- cursor.par()->next());
+ cursor.par()->previous(), cursor.par()->next());
}
Paragraph * tmppar = cursor.par();
}
Paragraph * tmppar = cursor.par();
if (cursor.par()->previous()) {
// steps into the above paragraph.
setCursorIntern(bview, cursor.par()->previous(),
if (cursor.par()->previous()) {
// steps into the above paragraph.
setCursorIntern(bview, cursor.par()->previous(),
- cursor.par()->previous()->size(),
- false);
+ cursor.par()->previous()->size(),
+ false);
}
/* Pasting is not allowed, if the paragraphs have different
}
/* Pasting is not allowed, if the paragraphs have different
if (cursor.par() != tmppar
&& (cursor.par()->getLayout() == tmppar->getLayout()
|| tmppar->getLayout() == 0 /*standard*/)
if (cursor.par() != tmppar
&& (cursor.par()->getLayout() == tmppar->getLayout()
|| tmppar->getLayout() == 0 /*standard*/)
- && cursor.par()->getAlign() == tmppar->getAlign()) {
-
+ && cursor.par()->getAlign() == tmppar->getAlign())
+ {
removeParagraph(tmprow);
removeRow(tmprow);
cursor.par()->pasteParagraph(bview->buffer()->params);
removeParagraph(tmprow);
removeRow(tmprow);
cursor.par()->pasteParagraph(bview->buffer()->params);
/* this is the code for a normal backspace, not pasting
* any paragraphs */
setUndo(bview, Undo::DELETE,
/* this is the code for a normal backspace, not pasting
* any paragraphs */
setUndo(bview, Undo::DELETE,
- cursor.par(), cursor.par()->next());
+ cursor.par(), cursor.par()->next());
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
setCursorIntern(bview, cursor.par(), cursor.pos()- 1,
// We used to do cursorLeftIntern() here, but it is
// not a good idea since it triggers the auto-delete
// mechanism. So we do a cursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
setCursorIntern(bview, cursor.par(), cursor.pos()- 1,
- false, cursor.boundary());
+ false, cursor.boundary());
// some insets are undeletable here
if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
// some insets are undeletable here
if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
if (cursor.pos() < rowLast(row) ||
!cursor.par()->isLineSeparator(cursor.pos())) {
row->fill(row->fill() + singleWidth(bview,
if (cursor.pos() < rowLast(row) ||
!cursor.par()->isLineSeparator(cursor.pos())) {
row->fill(row->fill() + singleWidth(bview,
- cursor.par(),
- cursor.pos()));
+ cursor.par(),
+ cursor.pos()));
}
/* some special code when deleting a newline. This is similar
}
/* some special code when deleting a newline. This is similar
-void LyXText::cutSelection(BufferView * bview, bool doclear)
+void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut)
{
// Stuff what we got on the clipboard. Even if there is no selection.
{
// Stuff what we got on the clipboard. Even if there is no selection.
endpar = selection.end.par();
int pos = selection.end.pos();
CutAndPaste::cutSelection(selection.start.par(), &endpar,
endpar = selection.end.par();
int pos = selection.end.pos();
CutAndPaste::cutSelection(selection.start.par(), &endpar,
- selection.start.pos(), pos,
- bview->buffer()->params.textclass, doclear);
+ selection.start.pos(), pos,
+ bview->buffer()->params.textclass, doclear,
+ realcut);
selection.end.pos(pos);
} else {
endpar = selection.end.par();
int pos = selection.end.pos();
CutAndPaste::cutSelection(selection.start.par(), &endpar,
selection.end.pos(pos);
} else {
endpar = selection.end.par();
int pos = selection.end.pos();
CutAndPaste::cutSelection(selection.start.par(), &endpar,
- selection.start.pos(), pos,
- bview->buffer()->params.textclass, doclear);
+ selection.start.pos(), pos,
+ bview->buffer()->params.textclass, doclear,
+ realcut);
cursor.par(endpar);
selection.end.par(endpar);
selection.end.pos(pos);
cursor.par(endpar);
selection.end.par(endpar);
selection.end.pos(pos);
+ cutSelection(bview, true, false);
{
InsetText * it = static_cast<InsetText *>(par->inInset());
if (it) {
{
InsetText * it = static_cast<InsetText *>(par->inInset());
if (it) {
- lyxerr << "InsetText is " << it << endl;
- lyxerr << "inset_owner is " << inset_owner << endl;
+ lyxerr << "InsetText is " << it << endl;
+ lyxerr << "inset_owner is " << inset_owner << endl;
#warning I belive this code is wrong. (Lgb)
#warning Jürgen, have a look at this. (Lgb)
#warning I belive this code is wrong. (Lgb)
#warning Jürgen, have a look at this. (Lgb)
+#warning Hmmm, I guess you are right but we
+#warning should verify when this is needed
// Jürgen, would you like to have a look?
// I guess we need to move the outer cursor
// and open and lock the inset (bla bla bla)
// stuff I don't know... so can you have a look?
// (Lgb)
// Jürgen, would you like to have a look?
// I guess we need to move the outer cursor
// and open and lock the inset (bla bla bla)
// stuff I don't know... so can you have a look?
// (Lgb)
+ // I moved the lyxerr stuff in here so we can see if this
+ // is actually really needed and where!
+ // (Jug)
it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont,
it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont,