- Fix erase selections broken by "changeTracking" it

seems. ChangeTracking responsible please verify all 
  erase/eraseChar where we added false or where it is 
  called without changetracking bool (jug).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15456 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Asger Ottar Alstrup 2006-10-21 17:05:20 +00:00
parent 2a9abde507
commit 51ed92d70c
9 changed files with 26 additions and 26 deletions

View File

@ -147,7 +147,7 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
for (pos_type j = 0; j < insertion[i].size(); ++j) { for (pos_type j = 0; j < insertion[i].size(); ++j) {
if (insertion[i].isNewline(j)) { if (insertion[i].isNewline(j)) {
// do not track deletion of newline // do not track deletion of newline
insertion[i].erase(j, false); insertion[i].eraseChar(j, false);
breakParagraphConservative( breakParagraphConservative(
buffer.params(), buffer.params(),
insertion, i, j); insertion, i, j);
@ -207,7 +207,7 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
if (tmpbuf->getChar(i) == Paragraph::META_INSET && if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode())) !pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
// do not track deletion of invalid insets // do not track deletion of invalid insets
tmpbuf->erase(i--, false); tmpbuf->eraseChar(i--, false);
} }
// FIXME: Change tracking (MG) // FIXME: Change tracking (MG)
@ -309,7 +309,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
// Start and end is inside same paragraph // Start and end is inside same paragraph
if (endpit == pit_type(pars.size()) || if (endpit == pit_type(pars.size()) ||
startpit == endpit) { startpit == endpit) {
endpos -= pars[startpit].erase(startpos, endpos); endpos -= pars[startpit].erase(startpos, endpos, false);
return PitPosPair(endpit, endpos); return PitPosPair(endpit, endpos);
} }
@ -325,7 +325,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
pos_type const right = ( pit == endpit ? endpos : pos_type const right = ( pit == endpit ? endpos :
pars[pit].size() + 1 ); pars[pit].size() + 1 );
// Logical erase only: // Logical erase only:
pars[pit].erase(left, right); pars[pit].erase(left, right, false);
// Separate handling of para break: // Separate handling of para break:
if (merge && pit != endpit && if (merge && pit != endpit &&
(pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) { (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
@ -363,11 +363,11 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
// Cut out the end of the last paragraph. // Cut out the end of the last paragraph.
Paragraph & back = paragraphs.back(); Paragraph & back = paragraphs.back();
back.erase(end, back.size()); back.erase(end, back.size(), false);
// Cut out the begin of the first paragraph // Cut out the begin of the first paragraph
Paragraph & front = paragraphs.front(); Paragraph & front = paragraphs.front();
front.erase(0, start); front.erase(0, start, false);
theCuts.push(make_pair(paragraphs, tc)); theCuts.push(make_pair(paragraphs, tc));
} }

View File

@ -354,7 +354,7 @@ void InsetText::setAutoBreakRows(bool flag)
if (it->isNewline(i)) if (it->isNewline(i))
// do not track the change, because the user // do not track the change, because the user
// is not allowed to revert/reject it // is not allowed to revert/reject it
it->erase(i, false); it->eraseChar(i, false);
} }

View File

@ -236,9 +236,9 @@ void Paragraph::validate(LaTeXFeatures & features) const
} }
bool Paragraph::erase(pos_type pos, bool trackChanges) bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
{ {
return pimpl_->erase(pos, trackChanges); return pimpl_->eraseChar(pos, trackChanges);
} }
@ -570,7 +570,7 @@ int Paragraph::stripLeadingSpaces()
int i = 0; int i = 0;
while (!empty() && (isNewline(0) || isLineSeparator(0)) while (!empty() && (isNewline(0) || isLineSeparator(0))
&& (lookupChange(0).type != Change::DELETED)) { && (lookupChange(0).type != Change::DELETED)) {
erase(0, false); // no change tracking here eraseChar(0, false); // no change tracking here
++i; ++i;
} }

View File

@ -241,7 +241,7 @@ public:
void applyLayout(LyXLayout_ptr const & new_layout); void applyLayout(LyXLayout_ptr const & new_layout);
/// erase the char at the given position /// erase the char at the given position
bool erase(pos_type pos, bool trackChanges); bool eraseChar(pos_type pos, bool trackChanges);
/// erase the given range. Returns the number of chars actually erased /// erase the given range. Returns the number of chars actually erased
int erase(pos_type start, pos_type end, bool trackChanges); int erase(pos_type start, pos_type end, bool trackChanges);

View File

@ -116,7 +116,7 @@ void breakParagraph(BufferParams const & bparams,
for (pos_type i = pos_end; i >= pos; --i) for (pos_type i = pos_end; i >= pos; --i)
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
par.erase(i, false); // erase without change tracking par.eraseChar(i, false); // erase without change tracking
} }
if (pos) { if (pos) {
@ -189,7 +189,7 @@ void breakParagraphConservative(BufferParams const & bparams,
// FIXME: Change tracking (MG) // FIXME: Change tracking (MG)
par.setChange(k, Change(Change::INSERTED)); par.setChange(k, Change(Change::INSERTED));
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
par.erase(k, false); par.eraseChar(k, false);
} }
} }
} }

View File

@ -155,7 +155,7 @@ void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
// Suppress access to nonexistent // Suppress access to nonexistent
// "end-of-paragraph char": // "end-of-paragraph char":
if (i < size()) { if (i < size()) {
erase(i); eraseChar(i);
--end; --end;
--i; --i;
} }
@ -185,7 +185,7 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
case Change::INSERTED: case Change::INSERTED:
if (i < size()) { if (i < size()) {
erase(i); eraseChar(i);
--end; --end;
--i; --i;
} }
@ -260,7 +260,7 @@ void Paragraph::Pimpl::insertInset(pos_type pos,
} }
void Paragraph::Pimpl::erase(pos_type pos) void Paragraph::Pimpl::eraseChar(pos_type pos)
{ {
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
// do something like changes_.erase(i); // do something like changes_.erase(i);
@ -309,7 +309,7 @@ void Paragraph::Pimpl::erase(pos_type pos)
} }
bool Paragraph::Pimpl::erase(pos_type pos, bool /*trackChanges*/) bool Paragraph::Pimpl::eraseChar(pos_type pos, bool /*trackChanges*/)
{ {
BOOST_ASSERT(pos <= size()); BOOST_ASSERT(pos <= size());
@ -329,7 +329,7 @@ bool Paragraph::Pimpl::erase(pos_type pos, bool /*trackChanges*/)
// Don't physically access nonexistent end-of-paragraph char // Don't physically access nonexistent end-of-paragraph char
if (pos < size()) { if (pos < size()) {
erase(pos); eraseChar(pos);
return true; return true;
} }
@ -341,7 +341,7 @@ int Paragraph::Pimpl::erase(pos_type start, pos_type end, bool trackChanges)
{ {
pos_type i = start; pos_type i = start;
for (pos_type count = end - start; count; --count) { for (pos_type count = end - start; count; --count) {
if (!erase(i, trackChanges)) if (!eraseChar(i, trackChanges))
++i; ++i;
} }
return end - i; return end - i;

View File

@ -61,9 +61,9 @@ public:
/// ///
void insertInset(pos_type pos, InsetBase * inset, Change const & change); void insertInset(pos_type pos, InsetBase * inset, Change const & change);
/// definite erase /// definite erase
void erase(pos_type pos); void eraseChar(pos_type pos);
/// erase the given position. Returns true if it was actually erased /// erase the given position. Returns true if it was actually erased
bool erase(pos_type pos, bool trackChanges); bool eraseChar(pos_type pos, bool trackChanges);
/// erase the given range /// erase the given range
int erase(pos_type start, pos_type end, bool trackChanges); int erase(pos_type start, pos_type end, bool trackChanges);
/// ///

View File

@ -1101,7 +1101,7 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
// It is better to erase the space (Dekel) // It is better to erase the space (Dekel)
if (cur.pos() != cur.lastpos() && cpar.isLineSeparator(cur.pos())) if (cur.pos() != cur.lastpos() && cpar.isLineSeparator(cur.pos()))
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
cpar.erase(cur.pos(), cur.buffer().params().trackChanges); cpar.eraseChar(cur.pos(), cur.buffer().params().trackChanges);
// How should the layout for the new paragraph be? // How should the layout for the new paragraph be?
int preserve_layout = 0; int preserve_layout = 0;
@ -1137,7 +1137,7 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0)) while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
pars_[next_par].erase(0, cur.buffer().params().trackChanges); pars_[next_par].eraseChar(0, cur.buffer().params().trackChanges);
ParIterator current_it(cur); ParIterator current_it(cur);
ParIterator last_it(cur); ParIterator last_it(cur);
@ -1787,7 +1787,7 @@ bool LyXText::backspace(LCursor & cur)
setCursorIntern(cur, cur.pit(), cur.pos() - 1, setCursorIntern(cur, cur.pit(), cur.pos() - 1,
false, cur.boundary()); false, cur.boundary());
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
cur.paragraph().erase(cur.pos(), cur.buffer().params().trackChanges); cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges);
} }
if (cur.pos() == cur.lastpos()) if (cur.pos() == cur.lastpos())
@ -1820,7 +1820,7 @@ bool LyXText::dissolveInset(LCursor & cur) {
spit += cur.pit(); spit += cur.pit();
Buffer & b = cur.buffer(); Buffer & b = cur.buffer();
// FIXME: change tracking (MG) // FIXME: change tracking (MG)
cur.paragraph().erase(cur.pos(), b.params().trackChanges); cur.paragraph().eraseChar(cur.pos(), b.params().trackChanges);
if (!plist.empty()) { if (!plist.empty()) {
pasteParagraphList(cur, plist, b.params().textclass, pasteParagraphList(cur, plist, b.params().textclass,
b.errorList("Paste")); b.errorList("Paste"));

View File

@ -1262,7 +1262,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old)
&& oldpar.isLineSeparator(old.pos()) && oldpar.isLineSeparator(old.pos())
&& oldpar.isLineSeparator(old.pos() - 1) && oldpar.isLineSeparator(old.pos() - 1)
&& oldpar.lookupChange(old.pos() - 1).type != Change::DELETED) { && oldpar.lookupChange(old.pos() - 1).type != Change::DELETED) {
oldpar.erase(old.pos() - 1, false); // do not track changes in DEPM oldpar.eraseChar(old.pos() - 1, false); // do not track changes in DEPM
#ifdef WITH_WARNINGS #ifdef WITH_WARNINGS
#warning This will not work anymore when we have multiple views of the same buffer #warning This will not work anymore when we have multiple views of the same buffer
// In this case, we will have to correct also the cursors held by // In this case, we will have to correct also the cursors held by