mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
change tracking:
* src/paragraph.h: remove eraseIntern(); pass trackChanges to erase(...) (2 methods) * src/paragraph_pimpl.h: rename eraseIntern() to erase(); pass trackChanges to other erase(...) (2 methods) * src/insets/insettext.C: * src/*.C: adjust properly git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15380 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
850962d0ba
commit
9acb432b0c
@ -149,7 +149,8 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
|
||||
for (ParagraphList::size_type i = 0; i < insertion.size(); ++i) {
|
||||
for (pos_type j = 0; j < insertion[i].size(); ++j) {
|
||||
if (insertion[i].isNewline(j)) {
|
||||
insertion[i].erase(j);
|
||||
// do not track deletion of newline
|
||||
insertion[i].erase(j, false);
|
||||
breakParagraphConservative(
|
||||
buffer.params(),
|
||||
insertion, i, j);
|
||||
@ -208,7 +209,8 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
|
||||
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
|
||||
if (tmpbuf->getChar(i) == Paragraph::META_INSET &&
|
||||
!pars[pit].insetAllowed(tmpbuf->getInset(i)->lyxCode()))
|
||||
tmpbuf->erase(i--);
|
||||
// do not track deletion of invalid insets
|
||||
tmpbuf->erase(i--, false);
|
||||
}
|
||||
|
||||
// FIXME: Change tracking (MG)
|
||||
|
@ -356,7 +356,9 @@ void InsetText::setAutoBreakRows(bool flag)
|
||||
for (; it != end; ++it)
|
||||
for (int i = 0; i < it->size(); ++i)
|
||||
if (it->isNewline(i))
|
||||
it->erase(i);
|
||||
// do not track the change, because the user
|
||||
// is not allowed to revert/reject it
|
||||
it->erase(i, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,21 +238,15 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::eraseIntern(lyx::pos_type pos)
|
||||
bool Paragraph::erase(pos_type pos, bool trackChanges)
|
||||
{
|
||||
pimpl_->eraseIntern(pos);
|
||||
return pimpl_->erase(pos, trackChanges);
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::erase(pos_type pos)
|
||||
int Paragraph::erase(pos_type start, pos_type end, bool trackChanges)
|
||||
{
|
||||
return pimpl_->erase(pos);
|
||||
}
|
||||
|
||||
|
||||
int Paragraph::erase(pos_type start, pos_type end)
|
||||
{
|
||||
return pimpl_->erase(start, end);
|
||||
return pimpl_->erase(start, end, trackChanges);
|
||||
}
|
||||
|
||||
|
||||
@ -568,7 +562,7 @@ int Paragraph::stripLeadingSpaces()
|
||||
int i = 0;
|
||||
while (!empty() && (isNewline(0) || isLineSeparator(0))
|
||||
&& (lookupChange(0).type != Change::DELETED)) {
|
||||
erase(0);
|
||||
erase(0, false); // no change tracking here
|
||||
++i;
|
||||
}
|
||||
|
||||
|
@ -239,12 +239,10 @@ public:
|
||||
///
|
||||
void applyLayout(LyXLayout_ptr const & new_layout);
|
||||
|
||||
/// definite erase
|
||||
void eraseIntern(lyx::pos_type pos);
|
||||
/// erase the char at the given position
|
||||
bool erase(lyx::pos_type pos);
|
||||
bool erase(lyx::pos_type pos, bool trackChanges);
|
||||
/// erase the given range. Returns the number of chars actually erased
|
||||
int erase(lyx::pos_type start, lyx::pos_type end);
|
||||
int erase(lyx::pos_type start, lyx::pos_type end, bool trackChanges);
|
||||
|
||||
/** Get uninstantiated font setting. Returns the difference
|
||||
between the characters font and the layoutfont.
|
||||
|
@ -123,7 +123,7 @@ void breakParagraph(BufferParams const & bparams,
|
||||
}
|
||||
|
||||
for (pos_type i = pos_end; i >= pos; --i)
|
||||
par.eraseIntern(i);
|
||||
par.erase(i, false); // erase without change tracking
|
||||
}
|
||||
|
||||
if (pos) {
|
||||
@ -195,7 +195,8 @@ void breakParagraphConservative(BufferParams const & bparams,
|
||||
if (bparams.trackChanges)
|
||||
// FIXME: Change tracking (MG)
|
||||
par.setChange(k, Change(Change::INSERTED));
|
||||
par.erase(k);
|
||||
// FIXME: change tracking (MG)
|
||||
par.erase(k, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,8 +161,7 @@ void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
|
||||
// Suppress access to nonexistent
|
||||
// "end-of-paragraph char":
|
||||
if (i < size()) {
|
||||
eraseIntern(i);
|
||||
changes_->erase(i);
|
||||
erase(i);
|
||||
--end;
|
||||
--i;
|
||||
}
|
||||
@ -194,8 +193,7 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
|
||||
|
||||
case Change::INSERTED:
|
||||
if (i < size()) {
|
||||
eraseIntern(i);
|
||||
changes_->erase(i);
|
||||
erase(i);
|
||||
--end;
|
||||
--i;
|
||||
}
|
||||
@ -266,8 +264,13 @@ void Paragraph::Pimpl::insertInset(pos_type pos,
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::Pimpl::eraseIntern(pos_type pos)
|
||||
void Paragraph::Pimpl::erase(pos_type pos)
|
||||
{
|
||||
// FIXME: change tracking (MG)
|
||||
// do something like changes_->erase(i);
|
||||
// in one of the next patches, the two erase functions
|
||||
// will be merged but I don't want to break too many things at the same time :-)
|
||||
|
||||
// if it is an inset, delete the inset entry
|
||||
if (owner_->text_[pos] == Paragraph::META_INSET) {
|
||||
owner_->insetlist.erase(pos);
|
||||
@ -300,18 +303,19 @@ void Paragraph::Pimpl::eraseIntern(pos_type pos)
|
||||
}
|
||||
}
|
||||
|
||||
// Update all other entries.
|
||||
// Update all other entries
|
||||
FontList::iterator fend = fontlist.end();
|
||||
for (; it != fend; ++it)
|
||||
it->pos(it->pos() - 1);
|
||||
|
||||
// Update the insetlist.
|
||||
// Update the insetlist
|
||||
owner_->insetlist.decreasePosAfterPos(pos);
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::Pimpl::erase(pos_type pos)
|
||||
bool Paragraph::Pimpl::erase(pos_type pos, bool trackChanges)
|
||||
{
|
||||
// FIXME: change tracking (MG)
|
||||
BOOST_ASSERT(pos <= size());
|
||||
|
||||
if (tracking()) {
|
||||
@ -328,7 +332,7 @@ bool Paragraph::Pimpl::erase(pos_type pos)
|
||||
|
||||
// Don't physically access nonexistent end-of-paragraph char
|
||||
if (pos < size()) {
|
||||
eraseIntern(pos);
|
||||
erase(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -336,11 +340,11 @@ bool Paragraph::Pimpl::erase(pos_type pos)
|
||||
}
|
||||
|
||||
|
||||
int Paragraph::Pimpl::erase(pos_type start, pos_type end)
|
||||
int Paragraph::Pimpl::erase(pos_type start, pos_type end, bool trackChanges)
|
||||
{
|
||||
pos_type i = start;
|
||||
for (pos_type count = end - start; count; --count) {
|
||||
if (!erase(i))
|
||||
if (!erase(i, trackChanges))
|
||||
++i;
|
||||
}
|
||||
return end - i;
|
||||
|
@ -62,11 +62,11 @@ public:
|
||||
///
|
||||
void insertInset(lyx::pos_type pos, InsetBase * inset, Change const & change);
|
||||
/// definite erase
|
||||
void eraseIntern(lyx::pos_type pos);
|
||||
void erase(lyx::pos_type pos);
|
||||
/// erase the given position. Returns true if it was actually erased
|
||||
bool erase(lyx::pos_type pos);
|
||||
bool erase(lyx::pos_type pos, bool trackChanges);
|
||||
/// erase the given range
|
||||
int erase(lyx::pos_type start, lyx::pos_type end);
|
||||
int erase(lyx::pos_type start, lyx::pos_type end, bool trackChanges);
|
||||
///
|
||||
InsetBase * inset_owner;
|
||||
|
||||
|
14
src/text.C
14
src/text.C
@ -1104,7 +1104,8 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
|
||||
// Always break behind a space
|
||||
// It is better to erase the space (Dekel)
|
||||
if (cur.pos() != cur.lastpos() && cpar.isLineSeparator(cur.pos()))
|
||||
cpar.erase(cur.pos());
|
||||
// FIXME: change tracking (MG)
|
||||
cpar.erase(cur.pos(), cur.buffer().params().trackChanges);
|
||||
|
||||
// How should the layout for the new paragraph be?
|
||||
int preserve_layout = 0;
|
||||
@ -1139,7 +1140,8 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
|
||||
}
|
||||
|
||||
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
|
||||
pars_[next_par].erase(0);
|
||||
// FIXME: change tracking (MG)
|
||||
pars_[next_par].erase(0, cur.buffer().params().trackChanges);
|
||||
|
||||
ParIterator current_it(cur);
|
||||
ParIterator last_it(cur);
|
||||
@ -1787,7 +1789,8 @@ bool LyXText::backspace(LCursor & cur)
|
||||
// without the dreaded mechanism. (JMarc)
|
||||
setCursorIntern(cur, cur.pit(), cur.pos() - 1,
|
||||
false, cur.boundary());
|
||||
cur.paragraph().erase(cur.pos());
|
||||
// FIXME: change tracking (MG)
|
||||
cur.paragraph().erase(cur.pos(), cur.buffer().params().trackChanges);
|
||||
}
|
||||
|
||||
if (cur.pos() == cur.lastpos())
|
||||
@ -1818,9 +1821,10 @@ bool LyXText::dissolveInset(LCursor & cur) {
|
||||
if (spit == 0)
|
||||
spos += cur.pos();
|
||||
spit += cur.pit();
|
||||
cur.paragraph().erase(cur.pos());
|
||||
Buffer & b = cur.buffer();
|
||||
// FIXME: change tracking (MG)
|
||||
cur.paragraph().erase(cur.pos(), b.params().trackChanges);
|
||||
if (!plist.empty()) {
|
||||
Buffer & b = cur.buffer();
|
||||
pasteParagraphList(cur, plist, b.params().textclass,
|
||||
b.errorList("Paste"));
|
||||
// restore position
|
||||
|
@ -1264,11 +1264,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old)
|
||||
&& oldpar.isLineSeparator(old.pos() - 1)
|
||||
// FIXME: change tracking (MG)
|
||||
&& oldpar.lookupChange(old.pos() - 1) != Change(Change::DELETED)) {
|
||||
// We need to set the text to Change::INSERTED to
|
||||
// get it erased properly
|
||||
// FIXME: change tracking (MG)
|
||||
oldpar.setChange(old.pos() -1, Change(Change::INSERTED));
|
||||
oldpar.erase(old.pos() - 1);
|
||||
oldpar.erase(old.pos() - 1, false); // do not track changes in DEPM
|
||||
#ifdef WITH_WARNINGS
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user