mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
Fixed bug where delete/backspace like operations on selections filled the
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
This commit is contained in:
parent
86e4a9bc8a
commit
0756c7aed1
@ -136,7 +136,7 @@ public:
|
||||
///
|
||||
void paste();
|
||||
///
|
||||
void cut();
|
||||
void cut(bool realcut = true);
|
||||
///
|
||||
void copy();
|
||||
///
|
||||
|
@ -295,12 +295,12 @@ void BufferView::copy()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::cut()
|
||||
void BufferView::cut(bool realcut)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
@ -2353,7 +2353,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
// just comment out the line below...
|
||||
showCursor();
|
||||
} else {
|
||||
bv_->cut();
|
||||
bv_->cut(false);
|
||||
}
|
||||
moveCursorUpdate(false);
|
||||
owner_->showState();
|
||||
@ -2409,7 +2409,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
| BufferView::CHANGE);
|
||||
}
|
||||
} else {
|
||||
bv_->cut();
|
||||
bv_->cut(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2496,7 +2496,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
showCursor();
|
||||
}
|
||||
} else {
|
||||
bv_->cut();
|
||||
bv_->cut(false);
|
||||
}
|
||||
owner_->showState();
|
||||
setState();
|
||||
@ -2536,7 +2536,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
| BufferView::CHANGE);
|
||||
}
|
||||
} else
|
||||
bv_->cut();
|
||||
bv_->cut(false);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3103,7 +3103,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
|
||||
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
|
||||
|
@ -1,5 +1,16 @@
|
||||
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.
|
||||
|
@ -73,27 +73,30 @@ void DeleteBuffer()
|
||||
|
||||
|
||||
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 (realcut)
|
||||
DeleteBuffer();
|
||||
|
||||
textclass = tc;
|
||||
|
||||
if (!(*endpar) ||
|
||||
startpar == (*endpar)) {
|
||||
if (!(*endpar) || startpar == (*endpar)) {
|
||||
// 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) {
|
||||
if (realcut)
|
||||
startpar->copyIntoMinibuffer(*current_view->buffer(),
|
||||
start);
|
||||
startpar->erase(start);
|
||||
|
||||
if (realcut)
|
||||
buf->insertFromMinibuffer(buf->size());
|
||||
}
|
||||
end = start - 1;
|
||||
@ -108,9 +111,12 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
|
||||
start);
|
||||
|
||||
// store the selection
|
||||
if (realcut) {
|
||||
buf = startpar->next();
|
||||
|
||||
buf->previous(0);
|
||||
} else {
|
||||
startpar->next()->previous(0);
|
||||
}
|
||||
(*endpar)->previous()->next(0);
|
||||
|
||||
// cut the selection
|
||||
@ -119,6 +125,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
|
||||
(*endpar)->previous(startpar);
|
||||
|
||||
// the cut selection should begin with standard layout
|
||||
if (realcut)
|
||||
buf->clear();
|
||||
|
||||
// paste the paragraphs again, if possible
|
||||
|
@ -25,7 +25,8 @@ public:
|
||||
///
|
||||
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,
|
||||
|
@ -397,7 +397,7 @@ public:
|
||||
///
|
||||
void toggleInset(BufferView *);
|
||||
///
|
||||
void cutSelection(BufferView *, bool = true);
|
||||
void cutSelection(BufferView *, bool doclear = true, bool realcut = true);
|
||||
///
|
||||
void copySelection(BufferView *);
|
||||
///
|
||||
|
15
src/text.C
15
src/text.C
@ -2403,7 +2403,7 @@ void LyXText::deleteWordForward(BufferView * bview)
|
||||
setSelection(bview);
|
||||
|
||||
/* -----> Great, CutSelection() gets rid of multiple spaces. */
|
||||
cutSelection(bview);
|
||||
cutSelection(bview, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2422,7 +2422,7 @@ void LyXText::deleteWordBackward(BufferView * bview)
|
||||
selection.cursor = cursor;
|
||||
cursor = tmpcursor;
|
||||
setSelection(bview);
|
||||
cutSelection(bview);
|
||||
cutSelection(bview, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2448,7 +2448,7 @@ void LyXText::deleteLineForward(BufferView * bview)
|
||||
if (!selection.set()) {
|
||||
deleteWordForward(bview);
|
||||
} else {
|
||||
cutSelection(bview);
|
||||
cutSelection(bview, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2576,7 +2576,9 @@ void LyXText::Delete(BufferView * bview)
|
||||
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
|
||||
}
|
||||
|
||||
// if you had success make a backspace
|
||||
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
||||
@ -2639,8 +2641,7 @@ void LyXText::backspace(BufferView * bview)
|
||||
|
||||
if (cursor.par()->previous()) {
|
||||
setUndo(bview, Undo::DELETE,
|
||||
cursor.par()->previous(),
|
||||
cursor.par()->next());
|
||||
cursor.par()->previous(), cursor.par()->next());
|
||||
}
|
||||
|
||||
Paragraph * tmppar = cursor.par();
|
||||
@ -2670,8 +2671,8 @@ void LyXText::backspace(BufferView * bview)
|
||||
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);
|
||||
|
17
src/text2.C
17
src/text2.C
@ -1663,7 +1663,7 @@ void LyXText::pasteEnvironmentType(BufferView * bview)
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
|
||||
@ -1706,14 +1706,16 @@ void LyXText::cutSelection(BufferView * bview, bool doclear)
|
||||
int pos = selection.end.pos();
|
||||
CutAndPaste::cutSelection(selection.start.par(), &endpar,
|
||||
selection.start.pos(), pos,
|
||||
bview->buffer()->params.textclass, doclear);
|
||||
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.start.pos(), pos,
|
||||
bview->buffer()->params.textclass, doclear);
|
||||
bview->buffer()->params.textclass, doclear,
|
||||
realcut);
|
||||
cursor.par(endpar);
|
||||
selection.end.par(endpar);
|
||||
selection.end.pos(pos);
|
||||
@ -1845,7 +1847,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview,
|
||||
}
|
||||
|
||||
// Cut the selection
|
||||
cutSelection(bview);
|
||||
cutSelection(bview, true, false);
|
||||
|
||||
unFreezeUndo();
|
||||
}
|
||||
@ -2138,16 +2140,21 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
|
||||
{
|
||||
InsetText * it = static_cast<InsetText *>(par->inInset());
|
||||
if (it) {
|
||||
if (it != inset_owner) {
|
||||
lyxerr << "InsetText is " << it << endl;
|
||||
lyxerr << "inset_owner is " << inset_owner << endl;
|
||||
if (it != inset_owner) {
|
||||
#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)
|
||||
// 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,
|
||||
boundary);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user