diff --git a/src/BufferView.h b/src/BufferView.h index 027d46cb90..ff0a3ffbfe 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -136,7 +136,7 @@ public: /// void paste(); /// - void cut(); + void cut(bool realcut = true); /// void copy(); /// diff --git a/src/BufferView2.C b/src/BufferView2.C index c7f58f9bf6..21f99d0e33 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -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")); } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index f8bcd15520..d5d677604b 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index e8775d62e8..a4ad4a6f96 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2001-08-08 Juergen Vigna + * 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. diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 428c9c9980..a3c6f64d87 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -73,44 +73,50 @@ 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; - DeleteBuffer(); + if (realcut) + DeleteBuffer(); textclass = tc; - if (!(*endpar) || - startpar == (*endpar)) { + if (!(*endpar) || startpar == (*endpar)) { // only within one paragraph - buf = new Paragraph; + if (realcut) + buf = new Paragraph; 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); startpar->erase(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); + end); *endpar = (*endpar)->next(); end = 0; startpar->breakParagraphConservative(current_view->buffer()->params, - start); + start); // store the selection - 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 @@ -119,7 +125,8 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar, (*endpar)->previous(startpar); // the cut selection should begin with standard layout - buf->clear(); + if (realcut) + buf->clear(); // paste the paragraphs again, if possible if (doclear) diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 173de5ce75..13ff9ed33d 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -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, diff --git a/src/lyxtext.h b/src/lyxtext.h index 440ad32691..a3d5f0930b 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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 *); /// diff --git a/src/text.C b/src/text.C index 1c13e8eb9e..0d49609619 100644 --- a/src/text.C +++ b/src/text.C @@ -2400,10 +2400,10 @@ void LyXText::deleteWordForward(BufferView * bview) setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); selection.cursor = cursor; cursor = tmpcursor; - setSelection(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(); @@ -2653,8 +2654,8 @@ void LyXText::backspace(BufferView * bview) 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 @@ -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); @@ -2708,13 +2709,13 @@ void LyXText::backspace(BufferView * bview) /* 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, - false, cursor.boundary()); + false, cursor.boundary()); // some insets are undeletable here if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) { @@ -2738,8 +2739,8 @@ void LyXText::backspace(BufferView * 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 diff --git a/src/text2.C b/src/text2.C index d7a122f79b..7d4172e5ff 100644 --- a/src/text2.C +++ b/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. @@ -1705,15 +1705,17 @@ void LyXText::cutSelection(BufferView * bview, bool doclear) 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.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); @@ -1845,7 +1847,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview, } // Cut the selection - cutSelection(bview); + cutSelection(bview, true, false); unFreezeUndo(); } @@ -2138,18 +2140,23 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par, { InsetText * it = static_cast(par->inInset()); if (it) { - lyxerr << "InsetText is " << it << endl; - lyxerr << "inset_owner is " << inset_owner << endl; if (it != inset_owner) { + 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 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); + boundary); return; } }