mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-09 02:28:19 +00:00
* buffer_funcs.[Ch]: new needsUpdateCounters function
* text.C: - LyXText::breakParagraph(): test if needsUpdateCounters() is enough before a full updateCounter - LyXText::backspacePos0(): ditto * text2.C: - LyXText::deleteEmptyParagraphMechanism(): ditto git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13593 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
98e729c767
commit
4b0a5549b1
@ -503,6 +503,29 @@ void setCounter(Buffer const & buf, ParIterator & it)
|
||||
} // anon namespace
|
||||
|
||||
|
||||
bool needsUpdateCounters(Buffer const & buf, ParIterator & it)
|
||||
{
|
||||
switch (it->layout()->labeltype) {
|
||||
|
||||
case LABEL_NO_LABEL:
|
||||
case LABEL_MANUAL:
|
||||
case LABEL_BIBLIO:
|
||||
case LABEL_TOP_ENVIRONMENT:
|
||||
case LABEL_CENTERED_TOP_ENVIRONMENT:
|
||||
case LABEL_STATIC:
|
||||
case LABEL_ITEMIZE:
|
||||
setCounter(buf, it);
|
||||
return false;
|
||||
|
||||
case LABEL_SENSITIVE:
|
||||
case LABEL_COUNTER:
|
||||
// do more things with enumerate later
|
||||
case LABEL_ENUMERATE:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateCounters(Buffer const & buf)
|
||||
{
|
||||
// start over
|
||||
|
@ -21,6 +21,7 @@ class Buffer;
|
||||
class DocIterator;
|
||||
class ErrorList;
|
||||
class TeXErrors;
|
||||
class ParIterator;
|
||||
|
||||
/**
|
||||
* Loads a LyX file \c filename into \c Buffer
|
||||
@ -48,6 +49,13 @@ int countWords(DocIterator const & from, DocIterator const & to);
|
||||
std::string expandLabel(Buffer const & buf, LyXLayout_ptr const & layout,
|
||||
bool appendix);
|
||||
|
||||
/// updates current counter and/or label if possible.
|
||||
/**
|
||||
\retval true if a full updateCounters is required.
|
||||
\retval false if a full updateCounters is not required.
|
||||
*/
|
||||
bool needsUpdateCounters(Buffer const & buf, ParIterator & it);
|
||||
|
||||
/// updates all counters
|
||||
void updateCounters(Buffer const &);
|
||||
|
||||
|
13
src/text.C
13
src/text.C
@ -24,6 +24,7 @@
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "pariterator.h"
|
||||
#include "coordcache.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "debug.h"
|
||||
@ -1087,7 +1088,12 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
|
||||
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0))
|
||||
pars_[next_par].erase(0);
|
||||
|
||||
updateCounters(cur.buffer());
|
||||
ParIterator current_it(cur);
|
||||
ParIterator next_it(cur); next_it.pit() = next_par;
|
||||
|
||||
if (needsUpdateCounters(cur.buffer(), current_it)
|
||||
|| needsUpdateCounters(cur.buffer(), next_it))
|
||||
updateCounters(cur.buffer());
|
||||
|
||||
// Mark "carriage return" as inserted if change tracking:
|
||||
if (cur.buffer().params().tracking_changes) {
|
||||
@ -1669,7 +1675,10 @@ bool LyXText::backspacePos0(LCursor & cur)
|
||||
--cur.pos();
|
||||
|
||||
// the counters may have changed
|
||||
updateCounters(cur.buffer());
|
||||
ParIterator par_it(cur);
|
||||
if (needsUpdateCounters(cur.buffer(), par_it))
|
||||
updateCounters(cur.buffer());
|
||||
|
||||
setCursor(cur, cur.pit(), cur.pos(), false);
|
||||
}
|
||||
return needsUpdate;
|
||||
|
@ -1274,7 +1274,9 @@ bool LyXText::deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old)
|
||||
cur.resetAnchor();
|
||||
}
|
||||
}
|
||||
updateCounters(old.buffer());
|
||||
ParIterator par_it(old);
|
||||
if (needsUpdateCounters(old.buffer(), par_it))
|
||||
updateCounters(old.buffer());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user