mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
add Buffer * member to DocIterator
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27603 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
90a4256e03
commit
6192345f60
@ -1515,17 +1515,18 @@ bool Buffer::isMultiLingual() const
|
|||||||
|
|
||||||
DocIterator Buffer::getParFromID(int const id) const
|
DocIterator Buffer::getParFromID(int const id) const
|
||||||
{
|
{
|
||||||
|
Buffer * buf = const_cast<Buffer *>(this);
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
// John says this is called with id == -1 from undo
|
// John says this is called with id == -1 from undo
|
||||||
lyxerr << "getParFromID(), id: " << id << endl;
|
lyxerr << "getParFromID(), id: " << id << endl;
|
||||||
return doc_iterator_end(inset());
|
return doc_iterator_end(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DocIterator it = doc_iterator_begin(inset()); !it.atEnd(); it.forwardPar())
|
for (DocIterator it = doc_iterator_begin(buf); !it.atEnd(); it.forwardPar())
|
||||||
if (it.paragraph().id() == id)
|
if (it.paragraph().id() == id)
|
||||||
return it;
|
return it;
|
||||||
|
|
||||||
return doc_iterator_end(inset());
|
return doc_iterator_end(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1537,25 +1538,25 @@ bool Buffer::hasParWithID(int const id) const
|
|||||||
|
|
||||||
ParIterator Buffer::par_iterator_begin()
|
ParIterator Buffer::par_iterator_begin()
|
||||||
{
|
{
|
||||||
return ParIterator(doc_iterator_begin(inset()));
|
return ParIterator(doc_iterator_begin(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ParIterator Buffer::par_iterator_end()
|
ParIterator Buffer::par_iterator_end()
|
||||||
{
|
{
|
||||||
return ParIterator(doc_iterator_end(inset()));
|
return ParIterator(doc_iterator_end(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ParConstIterator Buffer::par_iterator_begin() const
|
ParConstIterator Buffer::par_iterator_begin() const
|
||||||
{
|
{
|
||||||
return lyx::par_const_iterator_begin(inset());
|
return ParConstIterator(doc_iterator_begin(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ParConstIterator Buffer::par_iterator_end() const
|
ParConstIterator Buffer::par_iterator_end() const
|
||||||
{
|
{
|
||||||
return lyx::par_const_iterator_end(inset());
|
return ParConstIterator(doc_iterator_end(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1737,7 +1738,7 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
|
|||||||
Impl::BufferPositionMap::iterator it;
|
Impl::BufferPositionMap::iterator it;
|
||||||
it = d->children_positions.find(child);
|
it = d->children_positions.find(child);
|
||||||
if (it == d->children_positions.end())
|
if (it == d->children_positions.end())
|
||||||
return DocIterator();
|
return DocIterator(this);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2000,8 +2001,8 @@ void Buffer::updateMacroInstances() const
|
|||||||
{
|
{
|
||||||
LYXERR(Debug::MACROS, "updateMacroInstances for "
|
LYXERR(Debug::MACROS, "updateMacroInstances for "
|
||||||
<< d->filename.onlyFileName());
|
<< d->filename.onlyFileName());
|
||||||
DocIterator it = doc_iterator_begin(inset());
|
DocIterator it = doc_iterator_begin(this);
|
||||||
DocIterator end = doc_iterator_end(inset());
|
DocIterator end = doc_iterator_end(this);
|
||||||
for (; it != end; it.forwardPos()) {
|
for (; it != end; it.forwardPos()) {
|
||||||
// look for MathData cells in InsetMathNest insets
|
// look for MathData cells in InsetMathNest insets
|
||||||
Inset * inset = it.nextInset();
|
Inset * inset = it.nextInset();
|
||||||
|
@ -110,10 +110,7 @@ public:
|
|||||||
timestamp_method, ///< Use timestamp, and checksum if timestamp has changed
|
timestamp_method, ///< Use timestamp, and checksum if timestamp has changed
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Constructor
|
/// Constructor
|
||||||
\param file
|
|
||||||
\param b optional \c false by default
|
|
||||||
*/
|
|
||||||
explicit Buffer(std::string const & file, bool b = false);
|
explicit Buffer(std::string const & file, bool b = false);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
@ -150,12 +150,14 @@ bool findInset(DocIterator & dit, vector<InsetCode> const & codes,
|
|||||||
|
|
||||||
if (!findNextInset(tmpdit, codes, contents)) {
|
if (!findNextInset(tmpdit, codes, contents)) {
|
||||||
if (dit.depth() != 1 || dit.pit() != 0 || dit.pos() != 0) {
|
if (dit.depth() != 1 || dit.pit() != 0 || dit.pos() != 0) {
|
||||||
tmpdit = doc_iterator_begin(tmpdit.bottom().inset());
|
Inset * inset = &tmpdit.bottom().inset();
|
||||||
|
tmpdit = doc_iterator_begin(&inset->buffer(), inset);
|
||||||
if (!findNextInset(tmpdit, codes, contents))
|
if (!findNextInset(tmpdit, codes, contents))
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dit = tmpdit;
|
dit = tmpdit;
|
||||||
return true;
|
return true;
|
||||||
@ -272,11 +274,13 @@ struct BufferView::Private
|
|||||||
|
|
||||||
|
|
||||||
BufferView::BufferView(Buffer & buf)
|
BufferView::BufferView(Buffer & buf)
|
||||||
: width_(0), height_(0), full_screen_(false), buffer_(buf), d(new Private(*this))
|
: width_(0), height_(0), full_screen_(false), buffer_(buf),
|
||||||
|
d(new Private(*this))
|
||||||
{
|
{
|
||||||
d->xsel_cache_.set = false;
|
d->xsel_cache_.set = false;
|
||||||
d->intl_.initKeyMapper(lyxrc.use_kbmap);
|
d->intl_.initKeyMapper(lyxrc.use_kbmap);
|
||||||
|
|
||||||
|
d->cursor_.setBuffer(&buf);
|
||||||
d->cursor_.push(buffer_.inset());
|
d->cursor_.push(buffer_.inset());
|
||||||
d->cursor_.resetAnchor();
|
d->cursor_.resetAnchor();
|
||||||
d->cursor_.setCurrentFont();
|
d->cursor_.setCurrentFont();
|
||||||
@ -564,7 +568,7 @@ void BufferView::scrollDocView(int value)
|
|||||||
|
|
||||||
// cut off at the top
|
// cut off at the top
|
||||||
if (value <= d->scrollbarParameters_.min) {
|
if (value <= d->scrollbarParameters_.min) {
|
||||||
DocIterator dit = doc_iterator_begin(buffer_.inset());
|
DocIterator dit = doc_iterator_begin(&buffer_);
|
||||||
showCursor(dit);
|
showCursor(dit);
|
||||||
LYXERR(Debug::SCROLLING, "scroll to top");
|
LYXERR(Debug::SCROLLING, "scroll to top");
|
||||||
return;
|
return;
|
||||||
@ -572,7 +576,7 @@ void BufferView::scrollDocView(int value)
|
|||||||
|
|
||||||
// cut off at the bottom
|
// cut off at the bottom
|
||||||
if (value >= d->scrollbarParameters_.max) {
|
if (value >= d->scrollbarParameters_.max) {
|
||||||
DocIterator dit = doc_iterator_end(buffer_.inset());
|
DocIterator dit = doc_iterator_end(&buffer_);
|
||||||
dit.backwardPos();
|
dit.backwardPos();
|
||||||
showCursor(dit);
|
showCursor(dit);
|
||||||
LYXERR(Debug::SCROLLING, "scroll to bottom");
|
LYXERR(Debug::SCROLLING, "scroll to bottom");
|
||||||
@ -596,7 +600,7 @@ void BufferView::scrollDocView(int value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DocIterator dit = doc_iterator_begin(buffer_.inset());
|
DocIterator dit = doc_iterator_begin(&buffer_);
|
||||||
dit.pit() = i;
|
dit.pit() = i;
|
||||||
LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
|
LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
|
||||||
showCursor(dit);
|
showCursor(dit);
|
||||||
@ -724,7 +728,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, pos_type bottom_pos,
|
|||||||
// it will be restored to the left of the outmost inset that contains
|
// it will be restored to the left of the outmost inset that contains
|
||||||
// the bookmark.
|
// the bookmark.
|
||||||
if (bottom_pit < int(buffer_.paragraphs().size())) {
|
if (bottom_pit < int(buffer_.paragraphs().size())) {
|
||||||
dit = doc_iterator_begin(buffer_.inset());
|
dit = doc_iterator_begin(&buffer_);
|
||||||
|
|
||||||
dit.pit() = bottom_pit;
|
dit.pit() = bottom_pit;
|
||||||
dit.pos() = min(bottom_pos, dit.paragraph().size());
|
dit.pos() = min(bottom_pos, dit.paragraph().size());
|
||||||
@ -1308,8 +1312,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
from = cur.selectionBegin();
|
from = cur.selectionBegin();
|
||||||
to = cur.selectionEnd();
|
to = cur.selectionEnd();
|
||||||
} else {
|
} else {
|
||||||
from = doc_iterator_begin(buffer_.inset());
|
from = doc_iterator_begin(&buffer_);
|
||||||
to = doc_iterator_end(buffer_.inset());
|
to = doc_iterator_end(&buffer_);
|
||||||
}
|
}
|
||||||
int const words = countWords(from, to);
|
int const words = countWords(from, to);
|
||||||
int const chars = countChars(from, to, false);
|
int const chars = countChars(from, to, false);
|
||||||
@ -1495,7 +1499,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
FuncRequest fr(LFUN_INSET_TOGGLE, action);
|
FuncRequest fr(LFUN_INSET_TOGGLE, action);
|
||||||
|
|
||||||
Inset & inset = cur.buffer().inset();
|
Inset & inset = cur.buffer()->inset();
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetIterator it = inset_iterator_begin(inset);
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
InsetIterator const end = inset_iterator_end(inset);
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
|
@ -205,10 +205,9 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up)
|
|||||||
// << " xlow: " << xlow << " xhigh: " << xhigh
|
// << " xlow: " << xlow << " xhigh: " << xhigh
|
||||||
// << " ylow: " << ylow << " yhigh: " << yhigh
|
// << " ylow: " << ylow << " yhigh: " << yhigh
|
||||||
// << endl;
|
// << endl;
|
||||||
Inset & inset = bv.buffer().inset();
|
DocIterator it = doc_iterator_begin(cur.buffer());
|
||||||
DocIterator it = doc_iterator_begin(inset);
|
|
||||||
it.pit() = from;
|
it.pit() = from;
|
||||||
DocIterator et = doc_iterator_end(inset);
|
DocIterator et = doc_iterator_end(cur.buffer());
|
||||||
|
|
||||||
double best_dist = numeric_limits<double>::max();
|
double best_dist = numeric_limits<double>::max();
|
||||||
DocIterator best_cursor = et;
|
DocIterator best_cursor = et;
|
||||||
@ -252,8 +251,7 @@ docstring parbreak(Paragraph const & par)
|
|||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
os << '\n';
|
os << '\n';
|
||||||
// only add blank line if we're not in an ERT or Listings inset
|
// only add blank line if we're not in an ERT or Listings inset
|
||||||
if (par.ownerCode() != ERT_CODE
|
if (par.ownerCode() != ERT_CODE && par.ownerCode() != LISTINGS_CODE)
|
||||||
&& par.ownerCode() != LISTINGS_CODE)
|
|
||||||
os << '\n';
|
os << '\n';
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
@ -264,7 +262,8 @@ docstring parbreak(Paragraph const & par)
|
|||||||
// be careful: this is called from the bv's constructor, too, so
|
// be careful: this is called from the bv's constructor, too, so
|
||||||
// bv functions are not yet available!
|
// bv functions are not yet available!
|
||||||
Cursor::Cursor(BufferView & bv)
|
Cursor::Cursor(BufferView & bv)
|
||||||
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1), textTargetOffset_(0),
|
: DocIterator(&bv.buffer()), bv_(&bv), anchor_(),
|
||||||
|
x_target_(-1), textTargetOffset_(0),
|
||||||
selection_(false), mark_(false), logicalpos_(false),
|
selection_(false), mark_(false), logicalpos_(false),
|
||||||
current_font(inherit_font)
|
current_font(inherit_font)
|
||||||
{}
|
{}
|
||||||
@ -274,7 +273,7 @@ void Cursor::reset(Inset & inset)
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
push_back(CursorSlice(inset));
|
push_back(CursorSlice(inset));
|
||||||
anchor_ = doc_iterator_begin(inset);
|
anchor_ = doc_iterator_begin(&inset.buffer(), &inset);
|
||||||
anchor_.clear();
|
anchor_.clear();
|
||||||
clearTargetX();
|
clearTargetX();
|
||||||
selection_ = false;
|
selection_ = false;
|
||||||
@ -346,13 +345,6 @@ BufferView & Cursor::bv() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Buffer & Cursor::buffer() const
|
|
||||||
{
|
|
||||||
LASSERT(bv_, /**/);
|
|
||||||
return bv_->buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Cursor::pop()
|
void Cursor::pop()
|
||||||
{
|
{
|
||||||
LASSERT(depth() >= 1, /**/);
|
LASSERT(depth() >= 1, /**/);
|
||||||
@ -363,13 +355,13 @@ void Cursor::pop()
|
|||||||
void Cursor::push(Inset & p)
|
void Cursor::push(Inset & p)
|
||||||
{
|
{
|
||||||
push_back(CursorSlice(p));
|
push_back(CursorSlice(p));
|
||||||
p.setBuffer(bv_->buffer());
|
p.setBuffer(*buffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::pushBackward(Inset & p)
|
void Cursor::pushBackward(Inset & p)
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return);
|
||||||
//lyxerr << "Entering inset " << t << " front" << endl;
|
//lyxerr << "Entering inset " << t << " front" << endl;
|
||||||
push(p);
|
push(p);
|
||||||
p.idxFirst(*this);
|
p.idxFirst(*this);
|
||||||
@ -378,7 +370,7 @@ void Cursor::pushBackward(Inset & p)
|
|||||||
|
|
||||||
bool Cursor::popBackward()
|
bool Cursor::popBackward()
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return false);
|
||||||
if (depth() == 1)
|
if (depth() == 1)
|
||||||
return false;
|
return false;
|
||||||
pop();
|
pop();
|
||||||
@ -388,7 +380,7 @@ bool Cursor::popBackward()
|
|||||||
|
|
||||||
bool Cursor::popForward()
|
bool Cursor::popForward()
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return false);
|
||||||
//lyxerr << "Leaving inset from in back" << endl;
|
//lyxerr << "Leaving inset from in back" << endl;
|
||||||
const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
|
const pos_type lp = (depth() > 1) ? (*this)[depth() - 2].lastpos() : 0;
|
||||||
if (depth() == 1)
|
if (depth() == 1)
|
||||||
@ -499,7 +491,7 @@ bool Cursor::posVisRight(bool skip_inset)
|
|||||||
// currently to the left of 'right_pos'). In order to move to the
|
// currently to the left of 'right_pos'). In order to move to the
|
||||||
// right, it depends whether or not the character at 'right_pos' is RTL.
|
// right, it depends whether or not the character at 'right_pos' is RTL.
|
||||||
new_pos_is_RTL = paragraph().getFontSettings(
|
new_pos_is_RTL = paragraph().getFontSettings(
|
||||||
bv().buffer().params(), right_pos).isVisibleRightToLeft();
|
buffer()->params(), right_pos).isVisibleRightToLeft();
|
||||||
// If the character at 'right_pos' *is* LTR, then in order to move to
|
// If the character at 'right_pos' *is* LTR, then in order to move to
|
||||||
// the right of it, we need to be *after* 'right_pos', i.e., move to
|
// the right of it, we need to be *after* 'right_pos', i.e., move to
|
||||||
// position 'right_pos' + 1.
|
// position 'right_pos' + 1.
|
||||||
@ -511,10 +503,10 @@ bool Cursor::posVisRight(bool skip_inset)
|
|||||||
// (this means that we're moving right to the end of an LTR chunk
|
// (this means that we're moving right to the end of an LTR chunk
|
||||||
// which is at the end of an RTL paragraph);
|
// which is at the end of an RTL paragraph);
|
||||||
(new_cur.pos() == lastpos()
|
(new_cur.pos() == lastpos()
|
||||||
&& paragraph().isRTL(buffer().params()))
|
&& paragraph().isRTL(buffer()->params()))
|
||||||
// 2. if the position *after* right_pos is RTL (we want to be
|
// 2. if the position *after* right_pos is RTL (we want to be
|
||||||
// *after* right_pos, not before right_pos + 1!)
|
// *after* right_pos, not before right_pos + 1!)
|
||||||
|| paragraph().getFontSettings(bv().buffer().params(),
|
|| paragraph().getFontSettings(buffer()->params(),
|
||||||
new_cur.pos()).isVisibleRightToLeft()
|
new_cur.pos()).isVisibleRightToLeft()
|
||||||
)
|
)
|
||||||
new_cur.boundary(true);
|
new_cur.boundary(true);
|
||||||
@ -591,7 +583,7 @@ bool Cursor::posVisLeft(bool skip_inset)
|
|||||||
// currently to the right of 'left_pos'). In order to move to the
|
// currently to the right of 'left_pos'). In order to move to the
|
||||||
// left, it depends whether or not the character at 'left_pos' is RTL.
|
// left, it depends whether or not the character at 'left_pos' is RTL.
|
||||||
new_pos_is_RTL = paragraph().getFontSettings(
|
new_pos_is_RTL = paragraph().getFontSettings(
|
||||||
bv().buffer().params(), left_pos).isVisibleRightToLeft();
|
buffer()->params(), left_pos).isVisibleRightToLeft();
|
||||||
// If the character at 'left_pos' *is* RTL, then in order to move to
|
// If the character at 'left_pos' *is* RTL, then in order to move to
|
||||||
// the left of it, we need to be *after* 'left_pos', i.e., move to
|
// the left of it, we need to be *after* 'left_pos', i.e., move to
|
||||||
// position 'left_pos' + 1.
|
// position 'left_pos' + 1.
|
||||||
@ -603,10 +595,10 @@ bool Cursor::posVisLeft(bool skip_inset)
|
|||||||
// (this means that we're moving left to the end of an RTL chunk
|
// (this means that we're moving left to the end of an RTL chunk
|
||||||
// which is at the end of an LTR paragraph);
|
// which is at the end of an LTR paragraph);
|
||||||
(new_cur.pos() == lastpos()
|
(new_cur.pos() == lastpos()
|
||||||
&& !paragraph().isRTL(buffer().params()))
|
&& !paragraph().isRTL(buffer()->params()))
|
||||||
// 2. if the position *after* left_pos is not RTL (we want to be
|
// 2. if the position *after* left_pos is not RTL (we want to be
|
||||||
// *after* left_pos, not before left_pos + 1!)
|
// *after* left_pos, not before left_pos + 1!)
|
||||||
|| !paragraph().getFontSettings(bv().buffer().params(),
|
|| !paragraph().getFontSettings(buffer()->params(),
|
||||||
new_cur.pos()).isVisibleRightToLeft()
|
new_cur.pos()).isVisibleRightToLeft()
|
||||||
)
|
)
|
||||||
new_cur.boundary(true);
|
new_cur.boundary(true);
|
||||||
@ -641,7 +633,7 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos)
|
|||||||
{
|
{
|
||||||
// preparing bidi tables
|
// preparing bidi tables
|
||||||
Paragraph const & par = paragraph();
|
Paragraph const & par = paragraph();
|
||||||
Buffer const & buf = buffer();
|
Buffer const & buf = *buffer();
|
||||||
Row const & row = textRow();
|
Row const & row = textRow();
|
||||||
Bidi bidi;
|
Bidi bidi;
|
||||||
bidi.computeTables(par, buf, row);
|
bidi.computeTables(par, buf, row);
|
||||||
@ -748,7 +740,7 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos)
|
|||||||
bool Cursor::posVisToNewRow(bool movingLeft)
|
bool Cursor::posVisToNewRow(bool movingLeft)
|
||||||
{
|
{
|
||||||
Paragraph const & par = paragraph();
|
Paragraph const & par = paragraph();
|
||||||
Buffer const & buf = buffer();
|
Buffer const & buf = *buffer();
|
||||||
Row const & row = textRow();
|
Row const & row = textRow();
|
||||||
bool par_is_LTR = !par.isRTL(buf.params());
|
bool par_is_LTR = !par.isRTL(buf.params());
|
||||||
|
|
||||||
@ -802,7 +794,7 @@ void Cursor::posVisToRowExtremity(bool left)
|
|||||||
{
|
{
|
||||||
// prepare bidi tables
|
// prepare bidi tables
|
||||||
Paragraph const & par = paragraph();
|
Paragraph const & par = paragraph();
|
||||||
Buffer const & buf = buffer();
|
Buffer const & buf = *buffer();
|
||||||
Row const & row = textRow();
|
Row const & row = textRow();
|
||||||
Bidi bidi;
|
Bidi bidi;
|
||||||
bidi.computeTables(par, buf, row);
|
bidi.computeTables(par, buf, row);
|
||||||
@ -1445,7 +1437,7 @@ bool Cursor::macroModeClose()
|
|||||||
// macros here are still unfolded (in init mode in fact). So
|
// macros here are still unfolded (in init mode in fact). So
|
||||||
// we have to resolve the macro here manually and check its arity
|
// we have to resolve the macro here manually and check its arity
|
||||||
// to put the selection behind it if arity > 0.
|
// to put the selection behind it if arity > 0.
|
||||||
MacroData const * data = buffer().getMacro(atomAsMacro->name());
|
MacroData const * data = buffer()->getMacro(atomAsMacro->name());
|
||||||
if (selection.size() > 0 && data && data->numargs() - data->optionals() > 0) {
|
if (selection.size() > 0 && data && data->numargs() - data->optionals() > 0) {
|
||||||
macroArg = true;
|
macroArg = true;
|
||||||
atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
|
atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
|
||||||
@ -2024,7 +2016,7 @@ Font Cursor::getFont() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get font at the position
|
// get font at the position
|
||||||
Font font = par.getFont(bv().buffer().params(), pos,
|
Font font = par.getFont(buffer()->params(), pos,
|
||||||
outerFont(sl.pit(), text.paragraphs()));
|
outerFont(sl.pit(), text.paragraphs()));
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
@ -2052,7 +2044,7 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur)
|
|||||||
|
|
||||||
// update words if we just moved to another paragraph
|
// update words if we just moved to another paragraph
|
||||||
if (i == old.depth() && i == cur.depth()
|
if (i == old.depth() && i == cur.depth()
|
||||||
&& !cur.buffer().isClean()
|
&& !cur.buffer()->isClean()
|
||||||
&& cur.inTexted() && old.inTexted()
|
&& cur.inTexted() && old.inTexted()
|
||||||
&& cur.pit() != old.pit()) {
|
&& cur.pit() != old.pit()) {
|
||||||
old.paragraph().updateWords(old.top());
|
old.paragraph().updateWords(old.top());
|
||||||
@ -2107,7 +2099,7 @@ void Cursor::setCurrentFont()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get font
|
// get font
|
||||||
BufferParams const & bufparams = buffer().params();
|
BufferParams const & bufparams = buffer()->params();
|
||||||
current_font = par.getFontSettings(bufparams, cpos);
|
current_font = par.getFontSettings(bufparams, cpos);
|
||||||
real_current_font = tm.displayFont(cpit, cpos);
|
real_current_font = tm.displayFont(cpit, cpos);
|
||||||
|
|
||||||
@ -2128,7 +2120,7 @@ bool Cursor::textUndo()
|
|||||||
{
|
{
|
||||||
DocIterator dit = *this;
|
DocIterator dit = *this;
|
||||||
// Undo::textUndo() will modify dit.
|
// Undo::textUndo() will modify dit.
|
||||||
if (!bv_->buffer().undo().textUndo(dit))
|
if (!buffer()->undo().textUndo(dit))
|
||||||
return false;
|
return false;
|
||||||
// Set cursor
|
// Set cursor
|
||||||
setCursor(dit);
|
setCursor(dit);
|
||||||
@ -2142,7 +2134,7 @@ bool Cursor::textRedo()
|
|||||||
{
|
{
|
||||||
DocIterator dit = *this;
|
DocIterator dit = *this;
|
||||||
// Undo::textRedo() will modify dit.
|
// Undo::textRedo() will modify dit.
|
||||||
if (!bv_->buffer().undo().textRedo(dit))
|
if (!buffer()->undo().textRedo(dit))
|
||||||
return false;
|
return false;
|
||||||
// Set cursor
|
// Set cursor
|
||||||
setCursor(dit);
|
setCursor(dit);
|
||||||
@ -2154,49 +2146,49 @@ bool Cursor::textRedo()
|
|||||||
|
|
||||||
void Cursor::finishUndo() const
|
void Cursor::finishUndo() const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().finishUndo();
|
buffer()->undo().finishUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::beginUndoGroup() const
|
void Cursor::beginUndoGroup() const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().beginUndoGroup();
|
buffer()->undo().beginUndoGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::endUndoGroup() const
|
void Cursor::endUndoGroup() const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().endUndoGroup();
|
buffer()->undo().endUndoGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const
|
void Cursor::recordUndo(UndoKind kind, pit_type from, pit_type to) const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().recordUndo(*this, kind, from, to);
|
buffer()->undo().recordUndo(*this, kind, from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::recordUndo(UndoKind kind, pit_type from) const
|
void Cursor::recordUndo(UndoKind kind, pit_type from) const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().recordUndo(*this, kind, from);
|
buffer()->undo().recordUndo(*this, kind, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::recordUndo(UndoKind kind) const
|
void Cursor::recordUndo(UndoKind kind) const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().recordUndo(*this, kind);
|
buffer()->undo().recordUndo(*this, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::recordUndoInset(UndoKind kind) const
|
void Cursor::recordUndoInset(UndoKind kind) const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().recordUndoInset(*this, kind);
|
buffer()->undo().recordUndoInset(*this, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::recordUndoFullDocument() const
|
void Cursor::recordUndoFullDocument() const
|
||||||
{
|
{
|
||||||
bv_->buffer().undo().recordUndoFullDocument(*this);
|
buffer()->undo().recordUndoFullDocument(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2207,15 +2199,16 @@ void Cursor::recordUndoSelection() const
|
|||||||
recordUndoInset();
|
recordUndoInset();
|
||||||
else
|
else
|
||||||
recordUndo();
|
recordUndo();
|
||||||
} else
|
} else {
|
||||||
bv_->buffer().undo().recordUndo(*this, ATOMIC_UNDO,
|
buffer()->undo().recordUndo(*this, ATOMIC_UNDO,
|
||||||
selBegin().pit(), selEnd().pit());
|
selBegin().pit(), selEnd().pit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cursor::checkBufferStructure()
|
void Cursor::checkBufferStructure()
|
||||||
{
|
{
|
||||||
Buffer const * master = buffer().masterBuffer();
|
Buffer const * master = buffer()->masterBuffer();
|
||||||
master->tocBackend().updateItem(*this);
|
master->tocBackend().updateItem(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +198,6 @@ public:
|
|||||||
void resetAnchor();
|
void resetAnchor();
|
||||||
/// access to owning BufferView
|
/// access to owning BufferView
|
||||||
BufferView & bv() const;
|
BufferView & bv() const;
|
||||||
/// access to owning Buffer
|
|
||||||
Buffer & buffer() const;
|
|
||||||
/// get some interesting description of top position
|
/// get some interesting description of top position
|
||||||
void info(odocstream & os) const;
|
void info(odocstream & os) const;
|
||||||
/// are we in math mode (2), text mode (1) or unsure (0)?
|
/// are we in math mode (2), text mode (1) or unsure (0)?
|
||||||
|
@ -93,7 +93,7 @@ pair<PitPosPair, pit_type>
|
|||||||
pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
|
pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
|
||||||
DocumentClass const * const oldDocClass, ErrorList & errorlist)
|
DocumentClass const * const oldDocClass, ErrorList & errorlist)
|
||||||
{
|
{
|
||||||
Buffer const & buffer = cur.buffer();
|
Buffer const & buffer = *cur.buffer();
|
||||||
pit_type pit = cur.pit();
|
pit_type pit = cur.pit();
|
||||||
pos_type pos = cur.pos();
|
pos_type pos = cur.pos();
|
||||||
InsetText * target_inset = cur.inset().asInsetText();
|
InsetText * target_inset = cur.inset().asInsetText();
|
||||||
@ -623,9 +623,9 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut)
|
|||||||
|
|
||||||
int endpos = cur.selEnd().pos();
|
int endpos = cur.selEnd().pos();
|
||||||
|
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer()->params();
|
||||||
if (realcut) {
|
if (realcut) {
|
||||||
copySelectionHelper(cur.buffer(),
|
copySelectionHelper(*cur.buffer(),
|
||||||
text->paragraphs(),
|
text->paragraphs(),
|
||||||
begpit, endpit,
|
begpit, endpit,
|
||||||
cur.selBegin().pos(), endpos,
|
cur.selBegin().pos(), endpos,
|
||||||
@ -658,7 +658,7 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut)
|
|||||||
|
|
||||||
// need a valid cursor. (Lgb)
|
// need a valid cursor. (Lgb)
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
|
|
||||||
// tell tabular that a recent copy happened
|
// tell tabular that a recent copy happened
|
||||||
dirtyTabularStack(false);
|
dirtyTabularStack(false);
|
||||||
@ -691,7 +691,7 @@ void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
|
|||||||
{
|
{
|
||||||
ParagraphList pars;
|
ParagraphList pars;
|
||||||
Paragraph par;
|
Paragraph par;
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer()->params();
|
||||||
par.setLayout(bp.documentClass().plainLayout());
|
par.setLayout(bp.documentClass().plainLayout());
|
||||||
par.insertInset(0, inset, Change(Change::UNCHANGED));
|
par.insertInset(0, inset, Change(Change::UNCHANGED));
|
||||||
pars.push_back(par);
|
pars.push_back(par);
|
||||||
@ -728,9 +728,9 @@ void copySelectionToStack(Cursor const & cur, CutStack & cutstack)
|
|||||||
(par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
|
(par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(),
|
copySelectionHelper(*cur.buffer(), pars, par, cur.selEnd().pit(),
|
||||||
pos, cur.selEnd().pos(),
|
pos, cur.selEnd().pos(),
|
||||||
cur.buffer().params().documentClassPtr(), cutstack);
|
cur.buffer()->params().documentClassPtr(), cutstack);
|
||||||
dirtyTabularStack(false);
|
dirtyTabularStack(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ void copySelectionToStack(Cursor const & cur, CutStack & cutstack)
|
|||||||
//lyxerr << "copySelection in mathed" << endl;
|
//lyxerr << "copySelection in mathed" << endl;
|
||||||
ParagraphList pars;
|
ParagraphList pars;
|
||||||
Paragraph par;
|
Paragraph par;
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer()->params();
|
||||||
// FIXME This should be the plain layout...right?
|
// FIXME This should be the plain layout...right?
|
||||||
par.setLayout(bp.documentClass().plainLayout());
|
par.setLayout(bp.documentClass().plainLayout());
|
||||||
par.insert(0, grabSelection(cur), Font(), Change(Change::UNCHANGED));
|
par.insert(0, grabSelection(cur), Font(), Change(Change::UNCHANGED));
|
||||||
@ -766,7 +766,7 @@ void copySelection(Cursor const & cur, docstring const & plaintext)
|
|||||||
if (cur.selBegin().idx() != cur.selEnd().idx()) {
|
if (cur.selBegin().idx() != cur.selEnd().idx()) {
|
||||||
ParagraphList pars;
|
ParagraphList pars;
|
||||||
Paragraph par;
|
Paragraph par;
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer()->params();
|
||||||
par.setLayout(bp.documentClass().plainLayout());
|
par.setLayout(bp.documentClass().plainLayout());
|
||||||
par.insert(0, plaintext, Font(), Change(Change::UNCHANGED));
|
par.insert(0, plaintext, Font(), Change(Change::UNCHANGED));
|
||||||
pars.push_back(par);
|
pars.push_back(par);
|
||||||
@ -832,7 +832,7 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
|||||||
|
|
||||||
boost::tie(ppp, endpit) =
|
boost::tie(ppp, endpit) =
|
||||||
pasteSelectionHelper(cur, parlist, docclass, errorList);
|
pasteSelectionHelper(cur, parlist, docclass, errorList);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
text->setCursor(cur, ppp.first, ppp.second);
|
text->setCursor(cur, ppp.first, ppp.second);
|
||||||
}
|
}
|
||||||
@ -904,7 +904,7 @@ void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// create inset for graphic
|
// create inset for graphic
|
||||||
InsetGraphics * inset = new InsetGraphics(cur.buffer());
|
InsetGraphics * inset = new InsetGraphics(*cur.buffer());
|
||||||
InsetGraphicsParams params;
|
InsetGraphicsParams params;
|
||||||
params.filename = support::DocFileName(filename.absFilename());
|
params.filename = support::DocFileName(filename.absFilename());
|
||||||
inset->setParams(params);
|
inset->setParams(params);
|
||||||
@ -930,7 +930,7 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa
|
|||||||
|
|
||||||
// Get font setting before we cut, we need a copy here, not a bare reference.
|
// Get font setting before we cut, we need a copy here, not a bare reference.
|
||||||
Font const font =
|
Font const font =
|
||||||
selbeg.paragraph().getFontSettings(cur.buffer().params(), selbeg.pos());
|
selbeg.paragraph().getFontSettings(cur.buffer()->params(), selbeg.pos());
|
||||||
|
|
||||||
// Insert the new string
|
// Insert the new string
|
||||||
pos_type pos = cur.selEnd().pos();
|
pos_type pos = cur.selEnd().pos();
|
||||||
@ -938,7 +938,7 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa
|
|||||||
docstring::const_iterator cit = str.begin();
|
docstring::const_iterator cit = str.begin();
|
||||||
docstring::const_iterator end = str.end();
|
docstring::const_iterator end = str.end();
|
||||||
for (; cit != end; ++cit, ++pos)
|
for (; cit != end; ++cit, ++pos)
|
||||||
par.insertChar(pos, *cit, font, cur.buffer().params().trackChanges);
|
par.insertChar(pos, *cit, font, cur.buffer()->params().trackChanges);
|
||||||
|
|
||||||
// Cut the selection
|
// Cut the selection
|
||||||
cutSelection(cur, true, false);
|
cutSelection(cur, true, false);
|
||||||
@ -1075,5 +1075,4 @@ bool tabularStackDirty()
|
|||||||
|
|
||||||
|
|
||||||
} // namespace cap
|
} // namespace cap
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "DocIterator.h"
|
#include "DocIterator.h"
|
||||||
|
|
||||||
|
#include "Buffer.h"
|
||||||
#include "InsetList.h"
|
#include "InsetList.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
@ -25,7 +26,6 @@
|
|||||||
#include "insets/InsetTabular.h"
|
#include "insets/InsetTabular.h"
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -35,29 +35,37 @@ using namespace std;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
|
DocIterator::DocIterator()
|
||||||
|
: boundary_(false), inset_(0), buffer_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
// We could be able to get rid of this if only every BufferView were
|
// We could be able to get rid of this if only every BufferView were
|
||||||
// associated to a buffer on construction.
|
// associated to a buffer on construction.
|
||||||
DocIterator::DocIterator()
|
DocIterator::DocIterator(Buffer * buf)
|
||||||
: boundary_(false), inset_(0)
|
: boundary_(false), inset_(0), buffer_(buf)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
DocIterator::DocIterator(Inset & inset)
|
DocIterator::DocIterator(Buffer * buf, Inset * inset)
|
||||||
: boundary_(false), inset_(&inset)
|
: boundary_(false), inset_(inset), buffer_(buf)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
DocIterator doc_iterator_begin(Inset & inset)
|
DocIterator doc_iterator_begin(const Buffer * buf0, const Inset * inset0)
|
||||||
{
|
{
|
||||||
DocIterator dit(inset);
|
Buffer * buf = const_cast<Buffer *>(buf0);
|
||||||
|
Inset * inset = const_cast<Inset *>(inset0);
|
||||||
|
DocIterator dit(buf, inset ? inset : &buf->inset());
|
||||||
dit.forwardPos();
|
dit.forwardPos();
|
||||||
return dit;
|
return dit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DocIterator doc_iterator_end(Inset & inset)
|
DocIterator doc_iterator_end(const Buffer * buf0, const Inset * inset0)
|
||||||
{
|
{
|
||||||
return DocIterator(inset);
|
Buffer * buf = const_cast<Buffer *>(buf0);
|
||||||
|
Inset * inset = const_cast<Inset *>(inset0);
|
||||||
|
return DocIterator(buf, inset ? inset : &buf->inset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +85,7 @@ LyXErr & operator<<(LyXErr & os, DocIterator const & it)
|
|||||||
|
|
||||||
Inset * DocIterator::nextInset() const
|
Inset * DocIterator::nextInset() const
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return 0);
|
||||||
if (pos() == lastpos())
|
if (pos() == lastpos())
|
||||||
return 0;
|
return 0;
|
||||||
if (pos() > lastpos()) {
|
if (pos() > lastpos()) {
|
||||||
@ -92,7 +100,7 @@ Inset * DocIterator::nextInset() const
|
|||||||
|
|
||||||
Inset * DocIterator::prevInset() const
|
Inset * DocIterator::prevInset() const
|
||||||
{
|
{
|
||||||
LASSERT(!empty(), /**/);
|
LASSERT(!empty(), return 0);
|
||||||
if (pos() == 0)
|
if (pos() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (inMathed()) {
|
if (inMathed()) {
|
||||||
@ -556,11 +564,12 @@ StableDocIterator::StableDocIterator(DocIterator const & dit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DocIterator StableDocIterator::asDocIterator(Inset * inset) const
|
DocIterator StableDocIterator::asDocIterator(Buffer * buf) const
|
||||||
{
|
{
|
||||||
// this function re-creates the cache of inset pointers
|
// this function re-creates the cache of inset pointers
|
||||||
//lyxerr << "converting:\n" << *this << endl;
|
//lyxerr << "converting:\n" << *this << endl;
|
||||||
DocIterator dit = DocIterator(*inset);
|
Inset * inset = &buf->inset();
|
||||||
|
DocIterator dit = DocIterator(buf, inset);
|
||||||
for (size_t i = 0, n = data_.size(); i != n; ++i) {
|
for (size_t i = 0, n = data_.size(); i != n; ++i) {
|
||||||
if (inset == 0) {
|
if (inset == 0) {
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -19,16 +19,18 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
class DocIterator;
|
||||||
class LyXErr;
|
class LyXErr;
|
||||||
class MathAtom;
|
class MathAtom;
|
||||||
class Paragraph;
|
class Paragraph;
|
||||||
class Text;
|
class Text;
|
||||||
class InsetIterator;
|
class InsetIterator;
|
||||||
|
|
||||||
|
DocIterator doc_iterator_begin(Buffer const * buf, Inset const * inset = 0);
|
||||||
|
DocIterator doc_iterator_end(Buffer const * buf, Inset const * inset = 0);
|
||||||
|
|
||||||
// The public inheritance should go in favour of a suitable data member
|
|
||||||
// (or maybe private inheritance) at some point of time.
|
class DocIterator
|
||||||
class DocIterator // : public std::vector<CursorSlice>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// type for cell number in inset
|
/// type for cell number in inset
|
||||||
@ -41,6 +43,13 @@ public:
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
DocIterator();
|
DocIterator();
|
||||||
|
///
|
||||||
|
explicit DocIterator(Buffer *buf);
|
||||||
|
|
||||||
|
/// access to owning buffer
|
||||||
|
Buffer * buffer() const { return buffer_; }
|
||||||
|
/// access to owning buffer
|
||||||
|
void setBuffer(Buffer * buf) { buffer_ = buf; }
|
||||||
|
|
||||||
/// access slice at position \p i
|
/// access slice at position \p i
|
||||||
CursorSlice const & operator[](size_t i) const { return slices_[i]; }
|
CursorSlice const & operator[](size_t i) const { return slices_[i]; }
|
||||||
@ -228,10 +237,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class InsetIterator;
|
friend class InsetIterator;
|
||||||
friend DocIterator doc_iterator_begin(Inset & inset);
|
friend DocIterator doc_iterator_begin(Buffer const * buf, Inset const * inset);
|
||||||
friend DocIterator doc_iterator_end(Inset & inset);
|
friend DocIterator doc_iterator_end(Buffer const * buf, Inset const * inset);
|
||||||
///
|
///
|
||||||
explicit DocIterator(Inset & inset);
|
explicit DocIterator(Buffer * buf, Inset * inset);
|
||||||
/**
|
/**
|
||||||
* Normally, when the cursor is at position i, it is painted *before*
|
* Normally, when the cursor is at position i, it is painted *before*
|
||||||
* the character at position i. However, what if we want the cursor
|
* the character at position i. However, what if we want the cursor
|
||||||
@ -259,20 +268,16 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool boundary_;
|
bool boundary_;
|
||||||
///
|
///
|
||||||
std::vector<CursorSlice> const & internalData() const {
|
std::vector<CursorSlice> const & internalData() const { return slices_; }
|
||||||
return slices_;
|
|
||||||
}
|
|
||||||
///
|
///
|
||||||
std::vector<CursorSlice> slices_;
|
std::vector<CursorSlice> slices_;
|
||||||
///
|
///
|
||||||
Inset * inset_;
|
Inset * inset_;
|
||||||
|
///
|
||||||
|
Buffer * buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DocIterator doc_iterator_begin(Inset & inset);
|
|
||||||
DocIterator doc_iterator_end(Inset & inset);
|
|
||||||
|
|
||||||
|
|
||||||
inline bool operator==(DocIterator const & di1, DocIterator const & di2)
|
inline bool operator==(DocIterator const & di1, DocIterator const & di2)
|
||||||
{
|
{
|
||||||
return di1.slices_ == di2.slices_;
|
return di1.slices_ == di2.slices_;
|
||||||
@ -322,14 +327,15 @@ bool operator>=(DocIterator const & p, DocIterator const & q)
|
|||||||
// (overwritten by 0...) part of the CursorSlice data items. So this thing
|
// (overwritten by 0...) part of the CursorSlice data items. So this thing
|
||||||
// is suitable for external storage, but not for iteration as such.
|
// is suitable for external storage, but not for iteration as such.
|
||||||
|
|
||||||
class StableDocIterator {
|
class StableDocIterator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
StableDocIterator() {}
|
StableDocIterator() {}
|
||||||
/// non-explicit intended
|
/// non-explicit intended
|
||||||
StableDocIterator(const DocIterator & it);
|
StableDocIterator(const DocIterator & it);
|
||||||
///
|
///
|
||||||
DocIterator asDocIterator(Inset * start) const;
|
DocIterator asDocIterator(Buffer * buf) const;
|
||||||
///
|
///
|
||||||
size_t size() const { return data_.size(); }
|
size_t size() const { return data_.size(); }
|
||||||
/// return the position within the paragraph
|
/// return the position within the paragraph
|
||||||
@ -352,4 +358,4 @@ private:
|
|||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif
|
#endif // DOCITERATOR_H
|
||||||
|
@ -20,7 +20,7 @@ namespace lyx {
|
|||||||
|
|
||||||
|
|
||||||
InsetIterator::InsetIterator(Inset & inset)
|
InsetIterator::InsetIterator(Inset & inset)
|
||||||
: DocIterator(inset)
|
: DocIterator(&inset.buffer(), &inset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1806,7 +1806,7 @@ void LyXFunc::updateLayout(DocumentClass const * const oldlayout, Buffer * buf)
|
|||||||
oldlayout, buf->params().documentClassPtr(),
|
oldlayout, buf->params().documentClassPtr(),
|
||||||
static_cast<InsetText &>(buf->inset()), el);
|
static_cast<InsetText &>(buf->inset()), el);
|
||||||
|
|
||||||
view()->setCursor(backcur.asDocIterator(&(buf->inset())));
|
view()->setCursor(backcur.asDocIterator(buf));
|
||||||
|
|
||||||
buf->errors("Class Switch");
|
buf->errors("Class Switch");
|
||||||
buf->updateLabels();
|
buf->updateLabels();
|
||||||
|
@ -20,32 +20,34 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
///
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// ParIterator
|
//
|
||||||
///
|
// ParIterator
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ParIterator::ParIterator(DocIterator const & cur)
|
ParIterator::ParIterator(DocIterator const & dit)
|
||||||
: DocIterator(cur)
|
: DocIterator(dit)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
ParIterator par_iterator_begin(Inset & inset)
|
|
||||||
{
|
|
||||||
return ParIterator(doc_iterator_begin(inset));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ParIterator par_iterator_end(Inset & inset)
|
|
||||||
{
|
|
||||||
return ParIterator(doc_iterator_end(inset));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ParIterator::ParIterator(ParIterator const & pi)
|
ParIterator::ParIterator(ParIterator const & pi)
|
||||||
: DocIterator(DocIterator(pi))
|
: DocIterator(DocIterator(pi))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
ParIterator par_iterator_begin(Inset & inset)
|
||||||
|
{
|
||||||
|
return ParIterator(doc_iterator_begin(&inset.buffer(), &inset));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ParIterator par_iterator_end(Inset & inset)
|
||||||
|
{
|
||||||
|
return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ParIterator & ParIterator::operator++()
|
ParIterator & ParIterator::operator++()
|
||||||
{
|
{
|
||||||
forwardPar();
|
forwardPar();
|
||||||
@ -104,9 +106,16 @@ ParagraphList & ParIterator::plist() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// ParConstIterator
|
//
|
||||||
///
|
// ParConstIterator
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
ParConstIterator::ParConstIterator(Buffer const * buf)
|
||||||
|
: DocIterator(const_cast<Buffer *>(buf))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
ParConstIterator::ParConstIterator(DocIterator const & dit)
|
ParConstIterator::ParConstIterator(DocIterator const & dit)
|
||||||
@ -164,18 +173,4 @@ bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// FIXME: const correctness!
|
|
||||||
|
|
||||||
ParConstIterator par_const_iterator_begin(Inset const & inset)
|
|
||||||
{
|
|
||||||
return ParConstIterator(doc_iterator_begin(const_cast<Inset &>(inset)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ParConstIterator par_const_iterator_end(Inset const & inset)
|
|
||||||
{
|
|
||||||
return ParConstIterator(doc_iterator_end(const_cast<Inset &>(inset)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
class Buffer;
|
||||||
class Inset;
|
class Inset;
|
||||||
class Text;
|
class Text;
|
||||||
class ParagraphList;
|
class ParagraphList;
|
||||||
@ -38,10 +39,11 @@ public:
|
|||||||
typedef StdIt::reference reference;
|
typedef StdIt::reference reference;
|
||||||
|
|
||||||
///
|
///
|
||||||
ParIterator() : DocIterator() {}
|
///
|
||||||
|
ParIterator(Buffer * buf) : DocIterator(buf) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
ParIterator(Inset &, pit_type pit);
|
ParIterator(Buffer * buf, Inset &, pit_type pit);
|
||||||
///
|
///
|
||||||
ParIterator(ParIterator const &);
|
ParIterator(ParIterator const &);
|
||||||
///
|
///
|
||||||
@ -94,7 +96,7 @@ class ParConstIterator : public std::iterator<std::forward_iterator_tag,
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
ParConstIterator() : DocIterator() {}
|
ParConstIterator(Buffer const * buf);
|
||||||
///
|
///
|
||||||
ParConstIterator(ParConstIterator const &);
|
ParConstIterator(ParConstIterator const &);
|
||||||
///
|
///
|
||||||
@ -118,12 +120,6 @@ public:
|
|||||||
//bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
|
//bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
|
||||||
|
|
||||||
|
|
||||||
ParConstIterator par_const_iterator_begin(Inset const & inset);
|
|
||||||
|
|
||||||
ParConstIterator par_const_iterator_end(Inset const & inset);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
76
src/Text.cpp
76
src/Text.cpp
@ -293,7 +293,8 @@ class TextCompletionList : public CompletionList
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
TextCompletionList(Cursor const & cur)
|
TextCompletionList(Cursor const & cur)
|
||||||
: buf_(cur.buffer()), pos_(0) {}
|
: buffer_(cur.buffer()), pos_(0)
|
||||||
|
{}
|
||||||
///
|
///
|
||||||
virtual ~TextCompletionList() {}
|
virtual ~TextCompletionList() {}
|
||||||
|
|
||||||
@ -312,7 +313,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
Buffer const & buf_;
|
Buffer const * buffer_;
|
||||||
///
|
///
|
||||||
size_t pos_;
|
size_t pos_;
|
||||||
};
|
};
|
||||||
@ -341,7 +342,7 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
|||||||
Paragraph & cpar = cur.paragraph();
|
Paragraph & cpar = cur.paragraph();
|
||||||
pit_type cpit = cur.pit();
|
pit_type cpit = cur.pit();
|
||||||
|
|
||||||
DocumentClass const & tclass = cur.buffer().params().documentClass();
|
DocumentClass const & tclass = cur.buffer()->params().documentClass();
|
||||||
Layout const & layout = cpar.layout();
|
Layout const & layout = cpar.layout();
|
||||||
|
|
||||||
// this is only allowed, if the current paragraph is not empty
|
// this is only allowed, if the current paragraph is not empty
|
||||||
@ -356,7 +357,7 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
|||||||
// Always break behind a space
|
// Always break behind a space
|
||||||
// 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()))
|
||||||
cpar.eraseChar(cur.pos(), cur.buffer().params().trackChanges);
|
cpar.eraseChar(cur.pos(), cur.buffer()->params().trackChanges);
|
||||||
|
|
||||||
// What should the layout for the new paragraph be?
|
// What should the layout for the new paragraph be?
|
||||||
bool keep_layout = inverse_logic ?
|
bool keep_layout = inverse_logic ?
|
||||||
@ -370,7 +371,7 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
|||||||
// we need to set this before we insert the paragraph.
|
// we need to set this before we insert the paragraph.
|
||||||
bool const isempty = cpar.allowEmpty() && cpar.empty();
|
bool const isempty = cpar.allowEmpty() && cpar.empty();
|
||||||
|
|
||||||
lyx::breakParagraph(cur.buffer().params(), paragraphs(), cpit,
|
lyx::breakParagraph(cur.buffer()->params(), paragraphs(), cpit,
|
||||||
cur.pos(), keep_layout);
|
cur.pos(), keep_layout);
|
||||||
|
|
||||||
// After this, neither paragraph contains any rows!
|
// After this, neither paragraph contains any rows!
|
||||||
@ -391,11 +392,11 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0)) {
|
while (!pars_[next_par].empty() && pars_[next_par].isNewline(0)) {
|
||||||
if (!pars_[next_par].eraseChar(0, cur.buffer().params().trackChanges))
|
if (!pars_[next_par].eraseChar(0, cur.buffer()->params().trackChanges))
|
||||||
break; // the character couldn't be deleted physically due to change tracking
|
break; // the character couldn't be deleted physically due to change tracking
|
||||||
}
|
}
|
||||||
|
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
|
|
||||||
// A singlePar update is not enough in this case.
|
// A singlePar update is not enough in this case.
|
||||||
cur.updateFlags(Update::Force);
|
cur.updateFlags(Update::Force);
|
||||||
@ -418,7 +419,7 @@ void Text::insertChar(Cursor & cur, char_type c)
|
|||||||
cur.recordUndo(INSERT_UNDO);
|
cur.recordUndo(INSERT_UNDO);
|
||||||
|
|
||||||
TextMetrics const & tm = cur.bv().textMetrics(this);
|
TextMetrics const & tm = cur.bv().textMetrics(this);
|
||||||
Buffer const & buffer = cur.buffer();
|
Buffer const & buffer = *cur.buffer();
|
||||||
Paragraph & par = cur.paragraph();
|
Paragraph & par = cur.paragraph();
|
||||||
// try to remove this
|
// try to remove this
|
||||||
pit_type const pit = cur.pit();
|
pit_type const pit = cur.pit();
|
||||||
@ -538,7 +539,8 @@ void Text::insertChar(Cursor & cur, char_type c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
par.insertChar(cur.pos(), c, cur.current_font, cur.buffer().params().trackChanges);
|
par.insertChar(cur.pos(), c, cur.current_font,
|
||||||
|
cur.buffer()->params().trackChanges);
|
||||||
cur.checkBufferStructure();
|
cur.checkBufferStructure();
|
||||||
|
|
||||||
// cur.updateFlags(Update::Force);
|
// cur.updateFlags(Update::Force);
|
||||||
@ -689,11 +691,9 @@ bool Text::cursorVisLeftOneWord(Cursor & cur)
|
|||||||
// we should stop when we have an LTR word on our right or an RTL word
|
// we should stop when we have an LTR word on our right or an RTL word
|
||||||
// on our left
|
// on our left
|
||||||
if ((left_is_letter && temp_cur.paragraph().getFontSettings(
|
if ((left_is_letter && temp_cur.paragraph().getFontSettings(
|
||||||
temp_cur.bv().buffer().params(),
|
temp_cur.buffer()->params(), left_pos).isRightToLeft())
|
||||||
left_pos).isRightToLeft())
|
|
||||||
|| (right_is_letter && !temp_cur.paragraph().getFontSettings(
|
|| (right_is_letter && !temp_cur.paragraph().getFontSettings(
|
||||||
temp_cur.bv().buffer().params(),
|
temp_cur.buffer()->params(), right_pos).isRightToLeft()))
|
||||||
right_pos).isRightToLeft()))
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,10 +728,10 @@ bool Text::cursorVisRightOneWord(Cursor & cur)
|
|||||||
// we should stop when we have an LTR word on our right or an RTL word
|
// we should stop when we have an LTR word on our right or an RTL word
|
||||||
// on our left
|
// on our left
|
||||||
if ((left_is_letter && temp_cur.paragraph().getFontSettings(
|
if ((left_is_letter && temp_cur.paragraph().getFontSettings(
|
||||||
temp_cur.bv().buffer().params(),
|
temp_cur.buffer()->params(),
|
||||||
left_pos).isRightToLeft())
|
left_pos).isRightToLeft())
|
||||||
|| (right_is_letter && !temp_cur.paragraph().getFontSettings(
|
|| (right_is_letter && !temp_cur.paragraph().getFontSettings(
|
||||||
temp_cur.bv().buffer().params(),
|
temp_cur.buffer()->params(),
|
||||||
right_pos).isRightToLeft()))
|
right_pos).isRightToLeft()))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -809,9 +809,9 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
pos_type right = (pit == endPit ? endPos : parSize);
|
pos_type right = (pit == endPit ? endPos : parSize);
|
||||||
|
|
||||||
if (op == ACCEPT) {
|
if (op == ACCEPT) {
|
||||||
pars_[pit].acceptChanges(cur.buffer().params(), left, right);
|
pars_[pit].acceptChanges(cur.buffer()->params(), left, right);
|
||||||
} else {
|
} else {
|
||||||
pars_[pit].rejectChanges(cur.buffer().params(), left, right);
|
pars_[pit].rejectChanges(cur.buffer()->params(), left, right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,7 +838,7 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
// instead, we mark it unchanged
|
// instead, we mark it unchanged
|
||||||
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
||||||
} else {
|
} else {
|
||||||
mergeParagraph(cur.buffer().params(), pars_, pit);
|
mergeParagraph(cur.buffer()->params(), pars_, pit);
|
||||||
--endPit;
|
--endPit;
|
||||||
--pit;
|
--pit;
|
||||||
}
|
}
|
||||||
@ -851,7 +851,7 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
// we mark the par break at the end of the last paragraph unchanged
|
// we mark the par break at the end of the last paragraph unchanged
|
||||||
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
pars_[pit].setChange(pos, Change(Change::UNCHANGED));
|
||||||
} else {
|
} else {
|
||||||
mergeParagraph(cur.buffer().params(), pars_, pit);
|
mergeParagraph(cur.buffer()->params(), pars_, pit);
|
||||||
--endPit;
|
--endPit;
|
||||||
--pit;
|
--pit;
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
|
|
||||||
// finally, invoke the DEPM
|
// finally, invoke the DEPM
|
||||||
|
|
||||||
deleteEmptyParagraphMechanism(begPit, endPit, cur.buffer().params().trackChanges);
|
deleteEmptyParagraphMechanism(begPit, endPit, cur.buffer()->params().trackChanges);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -869,7 +869,7 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
|||||||
cur.clearSelection();
|
cur.clearSelection();
|
||||||
setCursorIntern(cur, begPit, begPos);
|
setCursorIntern(cur, begPit, begPos);
|
||||||
cur.updateFlags(Update::Force);
|
cur.updateFlags(Update::Force);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -979,7 +979,7 @@ void Text::changeCase(Cursor & cur, TextCase action)
|
|||||||
Paragraph & par = pars_[pit];
|
Paragraph & par = pars_[pit];
|
||||||
pos_type const pos = (pit == begPit ? begPos : 0);
|
pos_type const pos = (pit == begPit ? begPos : 0);
|
||||||
right = (pit == endPit ? endPos : par.size());
|
right = (pit == endPit ? endPos : par.size());
|
||||||
par.changeCase(cur.buffer().params(), pos, right, action);
|
par.changeCase(cur.buffer()->params(), pos, right, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the selection may have changed due to logically-only deleted chars
|
// the selection may have changed due to logically-only deleted chars
|
||||||
@ -1003,7 +1003,7 @@ bool Text::handleBibitems(Cursor & cur)
|
|||||||
if (cur.pos() != 0)
|
if (cur.pos() != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BufferParams const & bufparams = cur.buffer().params();
|
BufferParams const & bufparams = cur.buffer()->params();
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
Cursor prevcur = cur;
|
Cursor prevcur = cur;
|
||||||
if (cur.pit() > 0) {
|
if (cur.pit() > 0) {
|
||||||
@ -1018,7 +1018,7 @@ bool Text::handleBibitems(Cursor & cur)
|
|||||||
cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
|
cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
|
||||||
mergeParagraph(bufparams, cur.text()->paragraphs(),
|
mergeParagraph(bufparams, cur.text()->paragraphs(),
|
||||||
prevcur.pit());
|
prevcur.pit());
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
|
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
|
||||||
cur.updateFlags(Update::Force);
|
cur.updateFlags(Update::Force);
|
||||||
return true;
|
return true;
|
||||||
@ -1032,7 +1032,7 @@ bool Text::handleBibitems(Cursor & cur)
|
|||||||
|
|
||||||
bool Text::erase(Cursor & cur)
|
bool Text::erase(Cursor & cur)
|
||||||
{
|
{
|
||||||
LASSERT(this == cur.text(), /**/);
|
LASSERT(this == cur.text(), return false);
|
||||||
bool needsUpdate = false;
|
bool needsUpdate = false;
|
||||||
Paragraph & par = cur.paragraph();
|
Paragraph & par = cur.paragraph();
|
||||||
|
|
||||||
@ -1041,12 +1041,12 @@ bool Text::erase(Cursor & cur)
|
|||||||
// any paragraphs
|
// any paragraphs
|
||||||
cur.recordUndo(DELETE_UNDO);
|
cur.recordUndo(DELETE_UNDO);
|
||||||
bool const was_inset = cur.paragraph().isInset(cur.pos());
|
bool const was_inset = cur.paragraph().isInset(cur.pos());
|
||||||
if(!par.eraseChar(cur.pos(), cur.buffer().params().trackChanges))
|
if(!par.eraseChar(cur.pos(), cur.buffer()->params().trackChanges))
|
||||||
// the character has been logically deleted only => skip it
|
// the character has been logically deleted only => skip it
|
||||||
cur.top().forwardPos();
|
cur.top().forwardPos();
|
||||||
|
|
||||||
if (was_inset)
|
if (was_inset)
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
else
|
else
|
||||||
cur.checkBufferStructure();
|
cur.checkBufferStructure();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
@ -1054,7 +1054,7 @@ bool Text::erase(Cursor & cur)
|
|||||||
if (cur.pit() == cur.lastpit())
|
if (cur.pit() == cur.lastpit())
|
||||||
return dissolveInset(cur);
|
return dissolveInset(cur);
|
||||||
|
|
||||||
if (!par.isMergedOnEndOfParDeletion(cur.buffer().params().trackChanges)) {
|
if (!par.isMergedOnEndOfParDeletion(cur.buffer()->params().trackChanges)) {
|
||||||
par.setChange(cur.pos(), Change(Change::DELETED));
|
par.setChange(cur.pos(), Change(Change::DELETED));
|
||||||
cur.forwardPos();
|
cur.forwardPos();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
@ -1085,7 +1085,7 @@ bool Text::backspacePos0(Cursor & cur)
|
|||||||
|
|
||||||
bool needsUpdate = false;
|
bool needsUpdate = false;
|
||||||
|
|
||||||
BufferParams const & bufparams = cur.buffer().params();
|
BufferParams const & bufparams = cur.buffer()->params();
|
||||||
DocumentClass const & tclass = bufparams.documentClass();
|
DocumentClass const & tclass = bufparams.documentClass();
|
||||||
ParagraphList & plist = cur.text()->paragraphs();
|
ParagraphList & plist = cur.text()->paragraphs();
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
@ -1122,7 +1122,7 @@ bool Text::backspacePos0(Cursor & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
|
setCursorIntern(cur, prevcur.pit(), prevcur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,7 +1140,7 @@ bool Text::backspace(Cursor & cur)
|
|||||||
|
|
||||||
Paragraph & prev_par = pars_[cur.pit() - 1];
|
Paragraph & prev_par = pars_[cur.pit() - 1];
|
||||||
|
|
||||||
if (!prev_par.isMergedOnEndOfParDeletion(cur.buffer().params().trackChanges)) {
|
if (!prev_par.isMergedOnEndOfParDeletion(cur.buffer()->params().trackChanges)) {
|
||||||
prev_par.setChange(prev_par.size(), Change(Change::DELETED));
|
prev_par.setChange(prev_par.size(), Change(Change::DELETED));
|
||||||
setCursorIntern(cur, cur.pit() - 1, prev_par.size());
|
setCursorIntern(cur, cur.pit() - 1, prev_par.size());
|
||||||
return true;
|
return true;
|
||||||
@ -1160,9 +1160,9 @@ bool Text::backspace(Cursor & cur)
|
|||||||
setCursorIntern(cur, cur.pit(), cur.pos() - 1,
|
setCursorIntern(cur, cur.pit(), cur.pos() - 1,
|
||||||
false, cur.boundary());
|
false, cur.boundary());
|
||||||
bool const was_inset = cur.paragraph().isInset(cur.pos());
|
bool const was_inset = cur.paragraph().isInset(cur.pos());
|
||||||
cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges);
|
cur.paragraph().eraseChar(cur.pos(), cur.buffer()->params().trackChanges);
|
||||||
if (was_inset)
|
if (was_inset)
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
else
|
else
|
||||||
cur.checkBufferStructure();
|
cur.checkBufferStructure();
|
||||||
}
|
}
|
||||||
@ -1201,7 +1201,7 @@ bool Text::dissolveInset(Cursor & cur)
|
|||||||
if (spit == 0)
|
if (spit == 0)
|
||||||
spos += cur.pos();
|
spos += cur.pos();
|
||||||
spit += cur.pit();
|
spit += cur.pit();
|
||||||
Buffer & b = cur.buffer();
|
Buffer & b = *cur.buffer();
|
||||||
cur.paragraph().eraseChar(cur.pos(), b.params().trackChanges);
|
cur.paragraph().eraseChar(cur.pos(), b.params().trackChanges);
|
||||||
if (!plist.empty()) {
|
if (!plist.empty()) {
|
||||||
// ERT paragraphs have the Language latex_language.
|
// ERT paragraphs have the Language latex_language.
|
||||||
@ -1336,7 +1336,7 @@ bool Text::read(Buffer const & buf, Lexer & lex,
|
|||||||
docstring Text::currentState(Cursor const & cur) const
|
docstring Text::currentState(Cursor const & cur) const
|
||||||
{
|
{
|
||||||
LASSERT(this == cur.text(), /**/);
|
LASSERT(this == cur.text(), /**/);
|
||||||
Buffer & buf = cur.buffer();
|
Buffer & buf = *cur.buffer();
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
|
|
||||||
@ -1542,15 +1542,15 @@ void Text::charsTranspose(Cursor & cur)
|
|||||||
// Store the characters to be transposed (including font information).
|
// Store the characters to be transposed (including font information).
|
||||||
char_type const char1 = par.getChar(pos1);
|
char_type const char1 = par.getChar(pos1);
|
||||||
Font const font1 =
|
Font const font1 =
|
||||||
par.getFontSettings(cur.buffer().params(), pos1);
|
par.getFontSettings(cur.buffer()->params(), pos1);
|
||||||
|
|
||||||
char_type const char2 = par.getChar(pos2);
|
char_type const char2 = par.getChar(pos2);
|
||||||
Font const font2 =
|
Font const font2 =
|
||||||
par.getFontSettings(cur.buffer().params(), pos2);
|
par.getFontSettings(cur.buffer()->params(), pos2);
|
||||||
|
|
||||||
// And finally, we are ready to perform the transposition.
|
// And finally, we are ready to perform the transposition.
|
||||||
// Track the changes if Change Tracking is enabled.
|
// Track the changes if Change Tracking is enabled.
|
||||||
bool const trackChanges = cur.buffer().params().trackChanges;
|
bool const trackChanges = cur.buffer()->params().trackChanges;
|
||||||
|
|
||||||
cur.recordUndo();
|
cur.recordUndo();
|
||||||
|
|
||||||
|
@ -234,8 +234,8 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
|
|||||||
pit_type end = cur.selEnd().pit() + 1;
|
pit_type end = cur.selEnd().pit() + 1;
|
||||||
pit_type undopit = undoSpan(end - 1);
|
pit_type undopit = undoSpan(end - 1);
|
||||||
recUndo(cur, start, undopit - 1);
|
recUndo(cur, start, undopit - 1);
|
||||||
setLayout(cur.buffer(), start, end, layout);
|
setLayout(*cur.buffer(), start, end, layout);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
|
|||||||
}
|
}
|
||||||
// this handles the counter labels, and also fixes up
|
// this handles the counter labels, and also fixes up
|
||||||
// depth values for follow-on (child) paragraphs
|
// depth values for follow-on (child) paragraphs
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -306,13 +306,13 @@ void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
|
|||||||
FontInfo layoutfont;
|
FontInfo layoutfont;
|
||||||
pit_type pit = cur.pit();
|
pit_type pit = cur.pit();
|
||||||
if (cur.pos() < pars_[pit].beginOfBody())
|
if (cur.pos() < pars_[pit].beginOfBody())
|
||||||
layoutfont = labelFont(cur.buffer(), pars_[pit]);
|
layoutfont = labelFont(*cur.buffer(), pars_[pit]);
|
||||||
else
|
else
|
||||||
layoutfont = layoutFont(cur.buffer(), pit);
|
layoutfont = layoutFont(*cur.buffer(), pit);
|
||||||
|
|
||||||
// Update current font
|
// Update current font
|
||||||
cur.real_current_font.update(font,
|
cur.real_current_font.update(font,
|
||||||
cur.buffer().params().language,
|
cur.buffer()->params().language,
|
||||||
toggleall);
|
toggleall);
|
||||||
|
|
||||||
// Reduce to implicit settings
|
// Reduce to implicit settings
|
||||||
@ -478,7 +478,7 @@ void Text::insertInset(Cursor & cur, Inset * inset)
|
|||||||
LASSERT(this == cur.text(), /**/);
|
LASSERT(this == cur.text(), /**/);
|
||||||
LASSERT(inset, /**/);
|
LASSERT(inset, /**/);
|
||||||
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
|
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
|
||||||
Change(cur.buffer().params().trackChanges
|
Change(cur.buffer()->params().trackChanges
|
||||||
? Change::INSERTED : Change::UNCHANGED));
|
? Change::INSERTED : Change::UNCHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ void Text::insertInset(Cursor & cur, Inset * inset)
|
|||||||
// needed to insert the selection
|
// needed to insert the selection
|
||||||
void Text::insertStringAsLines(Cursor & cur, docstring const & str)
|
void Text::insertStringAsLines(Cursor & cur, docstring const & str)
|
||||||
{
|
{
|
||||||
cur.buffer().insertStringAsLines(pars_, cur.pit(), cur.pos(),
|
cur.buffer()->insertStringAsLines(pars_, cur.pit(), cur.pos(),
|
||||||
cur.current_font, str, autoBreakRows_);
|
cur.current_font, str, autoBreakRows_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +815,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
|||||||
&& oldpar.isLineSeparator(old.pos() - 1)
|
&& oldpar.isLineSeparator(old.pos() - 1)
|
||||||
&& !oldpar.isDeleted(old.pos() - 1)
|
&& !oldpar.isDeleted(old.pos() - 1)
|
||||||
&& !oldpar.isDeleted(old.pos())) {
|
&& !oldpar.isDeleted(old.pos())) {
|
||||||
oldpar.eraseChar(old.pos() - 1, cur.buffer().params().trackChanges);
|
oldpar.eraseChar(old.pos() - 1, cur.buffer()->params().trackChanges);
|
||||||
// FIXME: This will not work anymore when we have multiple views of the same buffer
|
// FIXME: 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
|
||||||
// other bufferviews. It will probably be easier to do that in a more
|
// other bufferviews. It will probably be easier to do that in a more
|
||||||
@ -870,7 +870,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldpar.stripLeadingSpaces(cur.buffer().params().trackChanges)) {
|
if (oldpar.stripLeadingSpaces(cur.buffer()->params().trackChanges)) {
|
||||||
need_anchor_change = true;
|
need_anchor_change = true;
|
||||||
// We return true here because the Paragraph contents changed and
|
// We return true here because the Paragraph contents changed and
|
||||||
// we need a redraw before further action is processed.
|
// we need a redraw before further action is processed.
|
||||||
|
@ -259,8 +259,8 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
|||||||
if (!gotsel || !pastesel)
|
if (!gotsel || !pastesel)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
pasteFromStack(cur, cur.buffer().errorList("Paste"), 0);
|
pasteFromStack(cur, cur.buffer()->errorList("Paste"), 0);
|
||||||
cur.buffer().errors("Paste");
|
cur.buffer()->errors("Paste");
|
||||||
cur.clearSelection(); // bug 393
|
cur.clearSelection(); // bug 393
|
||||||
cur.finishUndo();
|
cur.finishUndo();
|
||||||
InsetText * insetText = dynamic_cast<InsetText *>(inset);
|
InsetText * insetText = dynamic_cast<InsetText *>(inset);
|
||||||
@ -305,7 +305,7 @@ enum OutlineOp {
|
|||||||
|
|
||||||
static void outline(OutlineOp mode, Cursor & cur)
|
static void outline(OutlineOp mode, Cursor & cur)
|
||||||
{
|
{
|
||||||
Buffer & buf = cur.buffer();
|
Buffer & buf = *cur.buffer();
|
||||||
pit_type & pit = cur.pit();
|
pit_type & pit = cur.pit();
|
||||||
ParagraphList & pars = buf.text().paragraphs();
|
ParagraphList & pars = buf.text().paragraphs();
|
||||||
ParagraphList::iterator bgn = pars.begin();
|
ParagraphList::iterator bgn = pars.begin();
|
||||||
@ -473,7 +473,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
recUndo(cur, pit, pit + 1);
|
recUndo(cur, pit, pit + 1);
|
||||||
cur.finishUndo();
|
cur.finishUndo();
|
||||||
swap(pars_[pit], pars_[pit + 1]);
|
swap(pars_[pit], pars_[pit + 1]);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
++cur.pit();
|
++cur.pit();
|
||||||
break;
|
break;
|
||||||
@ -484,7 +484,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
recUndo(cur, pit - 1, pit);
|
recUndo(cur, pit - 1, pit);
|
||||||
cur.finishUndo();
|
cur.finishUndo();
|
||||||
swap(pars_[pit], pars_[pit - 1]);
|
swap(pars_[pit], pars_[pit - 1]);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
--cur.pit();
|
--cur.pit();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
break;
|
break;
|
||||||
@ -510,7 +510,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
par.params().startOfAppendix(start);
|
par.params().startOfAppendix(start);
|
||||||
|
|
||||||
// we can set the refreshing parameters now
|
// we can set the refreshing parameters now
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,17 +523,17 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_WORD_DELETE_BACKWARD:
|
case LFUN_WORD_DELETE_BACKWARD:
|
||||||
if (cur.selection()) {
|
if (cur.selection())
|
||||||
cutSelection(cur, true, false);
|
cutSelection(cur, true, false);
|
||||||
} else
|
else
|
||||||
deleteWordBackward(cur);
|
deleteWordBackward(cur);
|
||||||
finishChange(cur, false);
|
finishChange(cur, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LINE_DELETE:
|
case LFUN_LINE_DELETE:
|
||||||
if (cur.selection()) {
|
if (cur.selection())
|
||||||
cutSelection(cur, true, false);
|
cutSelection(cur, true, false);
|
||||||
} else
|
else
|
||||||
tm.deleteLineForward(cur);
|
tm.deleteLineForward(cur);
|
||||||
finishChange(cur, false);
|
finishChange(cur, false);
|
||||||
break;
|
break;
|
||||||
@ -541,22 +541,20 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_BUFFER_BEGIN:
|
case LFUN_BUFFER_BEGIN:
|
||||||
case LFUN_BUFFER_BEGIN_SELECT:
|
case LFUN_BUFFER_BEGIN_SELECT:
|
||||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
|
needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_BEGIN_SELECT);
|
||||||
if (cur.depth() == 1) {
|
if (cur.depth() == 1)
|
||||||
needsUpdate |= cursorTop(cur);
|
needsUpdate |= cursorTop(cur);
|
||||||
} else {
|
else
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
}
|
|
||||||
cur.updateFlags(Update::FitCursor);
|
cur.updateFlags(Update::FitCursor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BUFFER_END:
|
case LFUN_BUFFER_END:
|
||||||
case LFUN_BUFFER_END_SELECT:
|
case LFUN_BUFFER_END_SELECT:
|
||||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
|
needsUpdate |= cur.selHandle(cmd.action == LFUN_BUFFER_END_SELECT);
|
||||||
if (cur.depth() == 1) {
|
if (cur.depth() == 1)
|
||||||
needsUpdate |= cursorBottom(cur);
|
needsUpdate |= cursorBottom(cur);
|
||||||
} else {
|
else
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
}
|
|
||||||
cur.updateFlags(Update::FitCursor);
|
cur.updateFlags(Update::FitCursor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1841,26 +1839,26 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_OUTLINE_UP:
|
case LFUN_OUTLINE_UP:
|
||||||
outline(OutlineUp, cur);
|
outline(OutlineUp, cur);
|
||||||
setCursor(cur, cur.pit(), 0);
|
setCursor(cur, cur.pit(), 0);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_OUTLINE_DOWN:
|
case LFUN_OUTLINE_DOWN:
|
||||||
outline(OutlineDown, cur);
|
outline(OutlineDown, cur);
|
||||||
setCursor(cur, cur.pit(), 0);
|
setCursor(cur, cur.pit(), 0);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_OUTLINE_IN:
|
case LFUN_OUTLINE_IN:
|
||||||
outline(OutlineIn, cur);
|
outline(OutlineIn, cur);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_OUTLINE_OUT:
|
case LFUN_OUTLINE_OUT:
|
||||||
outline(OutlineOut, cur);
|
outline(OutlineOut, cur);
|
||||||
cur.buffer().updateLabels();
|
cur.buffer()->updateLabels();
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2028,7 +2026,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
code = FLEX_CODE;
|
code = FLEX_CODE;
|
||||||
string s = cmd.getArg(0);
|
string s = cmd.getArg(0);
|
||||||
InsetLayout il =
|
InsetLayout il =
|
||||||
cur.buffer().params().documentClass().insetLayout(from_utf8(s));
|
cur.buffer()->params().documentClass().insetLayout(from_utf8(s));
|
||||||
if (il.lyxtype() != InsetLayout::CHARSTYLE &&
|
if (il.lyxtype() != InsetLayout::CHARSTYLE &&
|
||||||
il.lyxtype() != InsetLayout::CUSTOM &&
|
il.lyxtype() != InsetLayout::CUSTOM &&
|
||||||
il.lyxtype() != InsetLayout::ELEMENT &&
|
il.lyxtype() != InsetLayout::ELEMENT &&
|
||||||
@ -2041,7 +2039,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
break;
|
break;
|
||||||
case LFUN_BRANCH_INSERT:
|
case LFUN_BRANCH_INSERT:
|
||||||
code = BRANCH_CODE;
|
code = BRANCH_CODE;
|
||||||
if (cur.buffer().masterBuffer()->params().branchlist().empty())
|
if (cur.buffer()->masterBuffer()->params().branchlist().empty())
|
||||||
enable = false;
|
enable = false;
|
||||||
break;
|
break;
|
||||||
case LFUN_LABEL_INSERT:
|
case LFUN_LABEL_INSERT:
|
||||||
@ -2182,7 +2180,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
|
|
||||||
case LFUN_INSET_DISSOLVE:
|
case LFUN_INSET_DISSOLVE:
|
||||||
if (!cmd.argument().empty()) {
|
if (!cmd.argument().empty()) {
|
||||||
InsetLayout const & il = cur.inset().getLayout(cur.buffer().params());
|
InsetLayout const & il = cur.inset().getLayout(cur.buffer()->params());
|
||||||
InsetLayout::InsetLyXType const type =
|
InsetLayout::InsetLyXType const type =
|
||||||
translateLyXType(to_utf8(cmd.argument()));
|
translateLyXType(to_utf8(cmd.argument()));
|
||||||
enable = cur.inset().lyxCode() == FLEX_CODE
|
enable = cur.inset().lyxCode() == FLEX_CODE
|
||||||
|
@ -38,7 +38,7 @@ class TocItem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// Default constructor for STL containers.
|
/// Default constructor for STL containers.
|
||||||
TocItem() {}
|
TocItem() : dit_(0) {}
|
||||||
///
|
///
|
||||||
TocItem(DocIterator const & dit,
|
TocItem(DocIterator const & dit,
|
||||||
int depth,
|
int depth,
|
||||||
|
@ -346,7 +346,7 @@ void Undo::Private::doTextUndoOrRedo(DocIterator & cur, UndoElementStack & stack
|
|||||||
// try to return early.
|
// try to return early.
|
||||||
|
|
||||||
// We will store in otherstack the part of the document under 'undo'
|
// We will store in otherstack the part of the document under 'undo'
|
||||||
DocIterator cell_dit = undo.cell.asDocIterator(&buffer_.inset());
|
DocIterator cell_dit = undo.cell.asDocIterator(&buffer_);
|
||||||
|
|
||||||
doRecordUndo(ATOMIC_UNDO, cell_dit,
|
doRecordUndo(ATOMIC_UNDO, cell_dit,
|
||||||
undo.from, cell_dit.lastpit() - undo.end, cur,
|
undo.from, cell_dit.lastpit() - undo.end, cur,
|
||||||
@ -354,7 +354,7 @@ void Undo::Private::doTextUndoOrRedo(DocIterator & cur, UndoElementStack & stack
|
|||||||
|
|
||||||
// This does the actual undo/redo.
|
// This does the actual undo/redo.
|
||||||
//LYXERR0("undo, performing: " << undo);
|
//LYXERR0("undo, performing: " << undo);
|
||||||
DocIterator dit = undo.cell.asDocIterator(&buffer_.inset());
|
DocIterator dit = undo.cell.asDocIterator(&buffer_);
|
||||||
if (undo.isFullBuffer) {
|
if (undo.isFullBuffer) {
|
||||||
LASSERT(undo.pars, /**/);
|
LASSERT(undo.pars, /**/);
|
||||||
// This is a full document
|
// This is a full document
|
||||||
@ -404,7 +404,7 @@ void Undo::Private::doTextUndoOrRedo(DocIterator & cur, UndoElementStack & stack
|
|||||||
LASSERT(undo.pars == 0, /**/);
|
LASSERT(undo.pars == 0, /**/);
|
||||||
LASSERT(undo.array == 0, /**/);
|
LASSERT(undo.array == 0, /**/);
|
||||||
|
|
||||||
cur = undo.cursor.asDocIterator(&buffer_.inset());
|
cur = undo.cursor.asDocIterator(&buffer_);
|
||||||
// Now that we're done with undo, we pop it off the stack.
|
// Now that we're done with undo, we pop it off the stack.
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
@ -509,7 +509,7 @@ void Undo::recordUndoFullDocument(DocIterator const & cur)
|
|||||||
beginUndoGroup();
|
beginUndoGroup();
|
||||||
d->doRecordUndo(
|
d->doRecordUndo(
|
||||||
ATOMIC_UNDO,
|
ATOMIC_UNDO,
|
||||||
doc_iterator_begin(d->buffer_.inset()),
|
doc_iterator_begin(&d->buffer_),
|
||||||
0, d->buffer_.paragraphs().size() - 1,
|
0, d->buffer_.paragraphs().size() - 1,
|
||||||
cur,
|
cur,
|
||||||
true,
|
true,
|
||||||
|
@ -138,7 +138,7 @@ FileName GuiClipboard::getPastedGraphicsFileName(Cursor const & cur,
|
|||||||
typeNames[Clipboard::JpegGraphicsType] = _("JPEG");
|
typeNames[Clipboard::JpegGraphicsType] = _("JPEG");
|
||||||
|
|
||||||
// find unused filename with primary extension
|
// find unused filename with primary extension
|
||||||
string document_path = cur.buffer().fileName().onlyPath().absFilename();
|
string document_path = cur.buffer()->fileName().onlyPath().absFilename();
|
||||||
unsigned newfile_number = 0;
|
unsigned newfile_number = 0;
|
||||||
FileName filename;
|
FileName filename;
|
||||||
do {
|
do {
|
||||||
|
@ -157,7 +157,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
||||||
: QCompleter(parent), gui_(gui), updateLock_(0),
|
: QCompleter(parent), gui_(gui), old_cursor_(0), updateLock_(0),
|
||||||
inlineVisible_(false), popupVisible_(false),
|
inlineVisible_(false), popupVisible_(false),
|
||||||
modelActive_(false)
|
modelActive_(false)
|
||||||
{
|
{
|
||||||
@ -564,7 +564,7 @@ void GuiCompleter::showInline(Cursor & cur)
|
|||||||
|
|
||||||
void GuiCompleter::hideInline(Cursor & cur)
|
void GuiCompleter::hideInline(Cursor & cur)
|
||||||
{
|
{
|
||||||
gui_->bufferView().setInlineCompletion(cur, DocIterator(), docstring());
|
gui_->bufferView().setInlineCompletion(cur, DocIterator(cur.buffer()), docstring());
|
||||||
inlineVisible_ = false;
|
inlineVisible_ = false;
|
||||||
|
|
||||||
if (inline_timer_.isActive())
|
if (inline_timer_.isActive())
|
||||||
|
@ -107,7 +107,7 @@ bool GuiErrorList::goTo(int item)
|
|||||||
Buffer const & buf = buffer();
|
Buffer const & buf = buffer();
|
||||||
DocIterator dit = buf.getParFromID(err.par_id);
|
DocIterator dit = buf.getParFromID(err.par_id);
|
||||||
|
|
||||||
if (dit == doc_iterator_end(buf.inset())) {
|
if (dit == doc_iterator_end(&buf)) {
|
||||||
// FIXME: Happens when loading a read-only doc with
|
// FIXME: Happens when loading a read-only doc with
|
||||||
// unknown layout. Should this be the case?
|
// unknown layout. Should this be the case?
|
||||||
LYXERR0("par id " << err.par_id << " not found");
|
LYXERR0("par id " << err.par_id << " not found");
|
||||||
|
@ -308,7 +308,7 @@ void GuiSpellchecker::check()
|
|||||||
|
|
||||||
ptrdiff_t start = 0;
|
ptrdiff_t start = 0;
|
||||||
ptrdiff_t total = 0;
|
ptrdiff_t total = 0;
|
||||||
DocIterator it = doc_iterator_begin(buffer().inset());
|
DocIterator it = doc_iterator_begin(&buffer());
|
||||||
for (start = 1; it != cur; it.forwardPos())
|
for (start = 1; it != cur; it.forwardPos())
|
||||||
++start;
|
++start;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
params_.type = cmd.getArg(1);
|
params_.type = cmd.getArg(1);
|
||||||
else
|
else
|
||||||
string2params(to_utf8(cmd.argument()), params_);
|
string2params(to_utf8(cmd.argument()), params_);
|
||||||
setLayout(cur.buffer().params());
|
setLayout(cur.buffer()->params());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
InsetBranchParams params;
|
InsetBranchParams params;
|
||||||
InsetBranch::string2params(to_utf8(cmd.argument()), params);
|
InsetBranch::string2params(to_utf8(cmd.argument()), params);
|
||||||
params_.branch = params.branch;
|
params_.branch = params.branch;
|
||||||
setLayout(cur.buffer().params());
|
setLayout(cur.buffer()->params());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ int InsetERT::docbook(odocstream & os, OutputParams const &) const
|
|||||||
|
|
||||||
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer()->params();
|
||||||
Layout const layout = bp.documentClass().plainLayout();
|
Layout const layout = bp.documentClass().plainLayout();
|
||||||
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
@ -156,11 +156,11 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
params_.placement = params.placement;
|
params_.placement = params.placement;
|
||||||
params_.wide = params.wide;
|
params_.wide = params.wide;
|
||||||
params_.sideways = params.sideways;
|
params_.sideways = params.sideways;
|
||||||
setWide(params_.wide, cur.buffer().params(), false);
|
setWide(params_.wide, cur.buffer()->params(), false);
|
||||||
setSideways(params_.sideways, cur.buffer().params(), false);
|
setSideways(params_.sideways, cur.buffer()->params(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewLabel(cur.buffer().params());
|
setNewLabel(cur.buffer()->params());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,20 +206,18 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
// if the inset is part of a graphics group, all the
|
// if the inset is part of a graphics group, all the
|
||||||
// other members should be updated too.
|
// other members should be updated too.
|
||||||
if (!params_.groupId.empty())
|
if (!params_.groupId.empty())
|
||||||
graphics::unifyGraphicsGroups(cur.buffer(),
|
graphics::unifyGraphicsGroups(buffer(),
|
||||||
to_utf8(cmd.argument()));
|
to_utf8(cmd.argument()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
cur.bv().updateDialog("graphics", params2string(params(),
|
cur.bv().updateDialog("graphics", params2string(params(), buffer()));
|
||||||
cur.bv().buffer()));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
if (!cur.selection() && cmd.button() == mouse_button::button1)
|
||||||
cur.bv().showDialog("graphics", params2string(params(),
|
cur.bv().showDialog("graphics", params2string(params(), buffer()), this);
|
||||||
cur.bv().buffer()), this);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -218,7 +218,7 @@ bool InsetInclude::isCompatibleCommand(string const & s)
|
|||||||
|
|
||||||
void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
LASSERT(&cur.buffer() == &buffer(), /**/);
|
LASSERT(cur.buffer() == &buffer(), return);
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_EDIT: {
|
case LFUN_INSET_EDIT: {
|
||||||
|
@ -173,7 +173,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
InsetCommandParams p(REF_CODE, "ref");
|
InsetCommandParams p(REF_CODE, "ref");
|
||||||
p["reference"] = getParam("name");
|
p["reference"] = getParam("name");
|
||||||
cap::clearSelection();
|
cap::clearSelection();
|
||||||
cap::copyInset(cur, new InsetRef(cur.buffer(), p), getParam("name"));
|
cap::copyInset(cur, new InsetRef(*cur.buffer(), p), getParam("name"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +181,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case LFUN_INSET_MODIFY:
|
case LFUN_INSET_MODIFY:
|
||||||
string2params(to_utf8(cmd.argument()), params_);
|
string2params(to_utf8(cmd.argument()), params_);
|
||||||
// get a bp from cur:
|
setLayout(buffer().params());
|
||||||
setLayout(cur.buffer().params());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
case LFUN_INSET_DIALOG_UPDATE:
|
||||||
@ -370,28 +369,29 @@ void InsetNote::string2params(string const & in, InsetNoteParams & params)
|
|||||||
params.read(lex);
|
params.read(lex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mutateNotes(Cursor & cur, string const & source, string const &target)
|
|
||||||
|
bool mutateNotes(Cursor & cur, string const & source, string const & target)
|
||||||
{
|
{
|
||||||
InsetNoteParams::Type typeSrc = notetranslator().find(source);
|
InsetNoteParams::Type typeSrc = notetranslator().find(source);
|
||||||
InsetNoteParams::Type typeTrt = notetranslator().find(target);
|
InsetNoteParams::Type typeTrt = notetranslator().find(target);
|
||||||
// syntax check of arguments
|
// syntax check of arguments
|
||||||
string sSrc = notetranslator().find(typeSrc);
|
string src = notetranslator().find(typeSrc);
|
||||||
string sTrt = notetranslator().find(typeTrt);
|
string trt = notetranslator().find(typeTrt);
|
||||||
if ((sSrc != source) || (sTrt != target))
|
if (src != source || trt != target)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// did we found some conforming inset?
|
// did we found some conforming inset?
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
cur.beginUndoGroup();
|
cur.beginUndoGroup();
|
||||||
Inset & inset = cur.buffer().inset();
|
Inset & inset = cur.buffer()->inset();
|
||||||
InsetIterator it = inset_iterator_begin(inset);
|
InsetIterator it = inset_iterator_begin(inset);
|
||||||
InsetIterator const end = inset_iterator_end(inset);
|
InsetIterator const end = inset_iterator_end(inset);
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (it->lyxCode() == NOTE_CODE) {
|
if (it->lyxCode() == NOTE_CODE) {
|
||||||
InsetNote & ins = static_cast<InsetNote &>(*it);
|
InsetNote & ins = static_cast<InsetNote &>(*it);
|
||||||
if (ins.params().type == typeSrc) {
|
if (ins.params().type == typeSrc) {
|
||||||
cur.buffer().undo().recordUndo(it);
|
cur.buffer()->undo().recordUndo(it);
|
||||||
FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
|
FuncRequest fr(LFUN_INSET_MODIFY, "note Note " + target);
|
||||||
ins.dispatch(cur, fr);
|
ins.dispatch(cur, fr);
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -4783,7 +4783,7 @@ bool InsetTabular::pasteClipboard(Cursor & cur)
|
|||||||
new InsetTableCell(*paste_tabular->cellInset(r1, c1)));
|
new InsetTableCell(*paste_tabular->cellInset(r1, c1)));
|
||||||
tabular.setCellInset(r2, c2, inset);
|
tabular.setCellInset(r2, c2, inset);
|
||||||
// FIXME: change tracking (MG)
|
// FIXME: change tracking (MG)
|
||||||
inset->setChange(Change(cur.buffer().params().trackChanges ?
|
inset->setChange(Change(buffer().params().trackChanges ?
|
||||||
Change::INSERTED : Change::UNCHANGED));
|
Change::INSERTED : Change::UNCHANGED));
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
}
|
}
|
||||||
@ -4804,7 +4804,7 @@ void InsetTabular::cutSelection(Cursor & cur)
|
|||||||
for (col_type j = cs; j <= ce; ++j) {
|
for (col_type j = cs; j <= ce; ++j) {
|
||||||
shared_ptr<InsetTableCell> t
|
shared_ptr<InsetTableCell> t
|
||||||
= cell(tabular.cellIndex(i, j));
|
= cell(tabular.cellIndex(i, j));
|
||||||
if (cur.buffer().params().trackChanges)
|
if (buffer().params().trackChanges)
|
||||||
// FIXME: Change tracking (MG)
|
// FIXME: Change tracking (MG)
|
||||||
t->setChange(Change(Change::DELETED));
|
t->setChange(Change(Change::DELETED));
|
||||||
else
|
else
|
||||||
@ -4826,7 +4826,7 @@ bool InsetTabular::isRightToLeft(Cursor & cur) const
|
|||||||
LASSERT(cur.depth() > 1, /**/);
|
LASSERT(cur.depth() > 1, /**/);
|
||||||
Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
|
Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
|
||||||
pos_type const parentpos = cur[cur.depth() - 2].pos();
|
pos_type const parentpos = cur[cur.depth() - 2].pos();
|
||||||
return parentpar.getFontSettings(cur.bv().buffer().params(),
|
return parentpar.getFontSettings(buffer().params(),
|
||||||
parentpos).language()->rightToLeft();
|
parentpos).language()->rightToLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ void InsetText::addToToc(DocIterator const & cdit)
|
|||||||
|
|
||||||
bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
||||||
{
|
{
|
||||||
if (cur.buffer().isClean())
|
if (buffer().isClean())
|
||||||
return Inset::notifyCursorLeaves(old, cur);
|
return Inset::notifyCursorLeaves(old, cur);
|
||||||
|
|
||||||
// find text inset in old cursor
|
// find text inset in old cursor
|
||||||
@ -548,9 +548,7 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
|||||||
|
|
||||||
bool InsetText::completionSupported(Cursor const & cur) const
|
bool InsetText::completionSupported(Cursor const & cur) const
|
||||||
{
|
{
|
||||||
Cursor const & bvCur = cur.bv().cursor();
|
//LASSERT(&cur.bv().cursor().inset() != this, return false);
|
||||||
if (&bvCur.inset() != this)
|
|
||||||
return false;
|
|
||||||
return text_.completionSupported(cur);
|
return text_.completionSupported(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ int replaceAll(BufferView * bv,
|
|||||||
int const ssize = searchstr.size();
|
int const ssize = searchstr.size();
|
||||||
|
|
||||||
Cursor cur(*bv);
|
Cursor cur(*bv);
|
||||||
cur.setCursor(doc_iterator_begin(buf.inset()));
|
cur.setCursor(doc_iterator_begin(&buf));
|
||||||
while (findForward(cur, match, false)) {
|
while (findForward(cur, match, false)) {
|
||||||
// Backup current cursor position and font.
|
// Backup current cursor position and font.
|
||||||
pos_type const pos = cur.pos();
|
pos_type const pos = cur.pos();
|
||||||
@ -183,7 +183,7 @@ int replaceAll(BufferView * bv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf.updateLabels();
|
buf.updateLabels();
|
||||||
bv->putSelectionAt(doc_iterator_begin(buf.inset()), 0, false);
|
bv->putSelectionAt(doc_iterator_begin(&buf), 0, false);
|
||||||
if (num)
|
if (num)
|
||||||
buf.markDirty();
|
buf.markDirty();
|
||||||
return num;
|
return num;
|
||||||
@ -707,9 +707,11 @@ docstring stringifyFromCursor(DocIterator const & cur, int len)
|
|||||||
return docstring();
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the LaTeX export of buf starting from cur and ending len positions after cur,
|
/** Computes the LaTeX export of buf starting from cur and ending len positions
|
||||||
** if len is positive, or at the paragraph or innermost inset end if len is -1.
|
* after cur, if len is positive, or at the paragraph or innermost inset end
|
||||||
**/
|
* if len is -1.
|
||||||
|
*/
|
||||||
|
|
||||||
docstring latexifyFromCursor(Buffer const & buf, DocIterator const & cur, int len)
|
docstring latexifyFromCursor(Buffer const & buf, DocIterator const & cur, int len)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::DEBUG, "Latexifying with len=" << len << " from cursor at pos: " << cur);
|
LYXERR(Debug::DEBUG, "Latexifying with len=" << len << " from cursor at pos: " << cur);
|
||||||
@ -757,19 +759,21 @@ docstring latexifyFromCursor(Buffer const & buf, DocIterator const & cur, int le
|
|||||||
for (MathData::const_iterator it = md.begin() + cs.pos(); it != it_end; ++it)
|
for (MathData::const_iterator it = md.begin() + cs.pos(); it != it_end; ++it)
|
||||||
ods << *it;
|
ods << *it;
|
||||||
|
|
||||||
// MathData md = cur.cell();
|
// MathData md = cur.cell();
|
||||||
// MathData::const_iterator it_end = ( ( len == -1 || cur.pos() + len > int(md.size()) ) ? md.end() : md.begin() + cur.pos() + len );
|
// MathData::const_iterator it_end = ( ( len == -1 || cur.pos() + len > int(md.size()) ) ? md.end() : md.begin() + cur.pos() + len );
|
||||||
// for (MathData::const_iterator it = md.begin() + cur.pos(); it != it_end; ++it) {
|
// for (MathData::const_iterator it = md.begin() + cur.pos(); it != it_end; ++it) {
|
||||||
// MathAtom const & ma = *it;
|
// MathAtom const & ma = *it;
|
||||||
// ma.nucleus()->latex(buf, ods, runparams);
|
// ma.nucleus()->latex(buf, ods, runparams);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Retrieve the math environment type, and add '$' or '$]' or others (\end{equation}) accordingly
|
// Retrieve the math environment type, and add '$' or '$]'
|
||||||
|
// or others (\end{equation}) accordingly
|
||||||
for (int s = cur.depth() - 1; s >= 0; --s) {
|
for (int s = cur.depth() - 1; s >= 0; --s) {
|
||||||
CursorSlice const & cs = cur[s];
|
CursorSlice const & cs = cur[s];
|
||||||
if (cs.asInsetMath() && cs.asInsetMath() && cs.asInsetMath()->asHullInset()) {
|
InsetMath * inset = cs.asInsetMath();
|
||||||
|
if (inset && inset->asHullInset()) {
|
||||||
WriteStream ws(ods);
|
WriteStream ws(ods);
|
||||||
cs.asInsetMath()->asHullInset()->footer_write(ws);
|
inset->asHullInset()->footer_write(ws);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -786,9 +790,10 @@ docstring latexifyFromCursor(Buffer const & buf, DocIterator const & cur, int le
|
|||||||
**/
|
**/
|
||||||
int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
||||||
{
|
{
|
||||||
// Search the foremost position that matches (avoids find of entire math inset when match at start of it)
|
// Search the foremost position that matches (avoids find of entire math
|
||||||
|
// inset when match at start of it)
|
||||||
size_t d;
|
size_t d;
|
||||||
DocIterator old_cur;
|
DocIterator old_cur(cur.buffer());
|
||||||
do {
|
do {
|
||||||
LYXERR(Debug::DEBUG, "Forwarding one step (searching for innermost match)");
|
LYXERR(Debug::DEBUG, "Forwarding one step (searching for innermost match)");
|
||||||
d = cur.depth();
|
d = cur.depth();
|
||||||
@ -806,7 +811,8 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
|||||||
++len;
|
++len;
|
||||||
LYXERR(Debug::DEBUG, "verifying unmatch with len = " << len);
|
LYXERR(Debug::DEBUG, "verifying unmatch with len = " << len);
|
||||||
}
|
}
|
||||||
int old_len = match(cur, len); // Length of matched text (different from len param)
|
// Length of matched text (different from len param)
|
||||||
|
int old_len = match(cur, len);
|
||||||
int new_len;
|
int new_len;
|
||||||
// Greedy behaviour while matching regexps
|
// Greedy behaviour while matching regexps
|
||||||
while ((new_len = match(cur, len + 1)) > old_len) {
|
while ((new_len = match(cur, len + 1)) > old_len) {
|
||||||
@ -820,12 +826,13 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
|||||||
/// Finds forward
|
/// Finds forward
|
||||||
int findForwardAdv(DocIterator & cur, MatchStringAdv const & match)
|
int findForwardAdv(DocIterator & cur, MatchStringAdv const & match)
|
||||||
{
|
{
|
||||||
if (! cur)
|
if (!cur)
|
||||||
return 0;
|
return 0;
|
||||||
for (; cur; cur.forwardPos()) {
|
for (; cur; cur.forwardPos()) {
|
||||||
// odocstringstream ods;
|
// odocstringstream ods;
|
||||||
// ods << _("Searching ... ") << (cur.bottom().lastpit() - cur.bottom().pit()) * 100 / total;
|
// ods << _("Searching ... ")
|
||||||
// cur.message(ods.str());
|
// << (cur.bottom().lastpit() - cur.bottom().pit()) * 100 / total;
|
||||||
|
// cur.message(ods.str());
|
||||||
if (match(cur))
|
if (match(cur))
|
||||||
return findAdvFinalize(cur, match);
|
return findAdvFinalize(cur, match);
|
||||||
}
|
}
|
||||||
@ -833,19 +840,21 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv const & match)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Finds backwards
|
/// Finds backwards
|
||||||
int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
|
int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match)
|
||||||
// if (cur.pos() > 0 || cur.depth() > 0)
|
{
|
||||||
// cur.backwardPos();
|
// if (cur.pos() > 0 || cur.depth() > 0)
|
||||||
|
// cur.backwardPos();
|
||||||
DocIterator cur_orig(cur);
|
DocIterator cur_orig(cur);
|
||||||
if (match(cur_orig))
|
if (match(cur_orig))
|
||||||
findAdvFinalize(cur_orig, match);
|
findAdvFinalize(cur_orig, match);
|
||||||
// int total = cur.bottom().pit() + 1;
|
// int total = cur.bottom().pit() + 1;
|
||||||
for (; cur; cur.backwardPos()) {
|
for (; cur; cur.backwardPos()) {
|
||||||
// odocstringstream ods;
|
// odocstringstream ods;
|
||||||
// ods << _("Searching ... ") << (total - cur.bottom().pit()) * 100 / total;
|
// ods << _("Searching ... ") << (total - cur.bottom().pit()) * 100 / total;
|
||||||
// cur.message(ods.str());
|
// cur.message(ods.str());
|
||||||
if (match(cur)) {
|
if (match(cur)) {
|
||||||
// Find the most backward consecutive match within same paragraph while searching backwards.
|
// Find the most backward consecutive match within same
|
||||||
|
// paragraph while searching backwards.
|
||||||
int pit = cur.pit();
|
int pit = cur.pit();
|
||||||
int old_len;
|
int old_len;
|
||||||
DocIterator old_cur;
|
DocIterator old_cur;
|
||||||
@ -854,7 +863,8 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
|
|||||||
old_cur = cur;
|
old_cur = cur;
|
||||||
old_len = len;
|
old_len = len;
|
||||||
cur.backwardPos();
|
cur.backwardPos();
|
||||||
LYXERR(Debug::DEBUG, "old_cur: " << old_cur << ", old_len=" << len << ", cur: " << cur);
|
LYXERR(Debug::DEBUG, "old_cur: " << old_cur
|
||||||
|
<< ", old_len: " << len << ", cur: " << cur);
|
||||||
} while (cur && cur.pit() == pit && match(cur)
|
} while (cur && cur.pit() == pit && match(cur)
|
||||||
&& (len = findAdvFinalize(cur, match)) > old_len);
|
&& (len = findAdvFinalize(cur, match)) > old_len);
|
||||||
cur = old_cur;
|
cur = old_cur;
|
||||||
@ -874,7 +884,7 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv const & match) {
|
|||||||
docstring stringifyFromForSearch(FindAdvOptions const & opt, Buffer const & buf,
|
docstring stringifyFromForSearch(FindAdvOptions const & opt, Buffer const & buf,
|
||||||
DocIterator const & cur, int len)
|
DocIterator const & cur, int len)
|
||||||
{
|
{
|
||||||
if (! opt.ignoreformat)
|
if (!opt.ignoreformat)
|
||||||
return latexifyFromCursor(buf, cur, len);
|
return latexifyFromCursor(buf, cur, len);
|
||||||
else
|
else
|
||||||
return stringifyFromCursor(cur, len);
|
return stringifyFromCursor(cur, len);
|
||||||
|
@ -483,10 +483,10 @@ void InsetMathHull::addPreview(graphics::PreviewLoader & ploader) const
|
|||||||
bool InsetMathHull::notifyCursorLeaves(Cursor const & /*old*/, Cursor & cur)
|
bool InsetMathHull::notifyCursorLeaves(Cursor const & /*old*/, Cursor & cur)
|
||||||
{
|
{
|
||||||
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||||
Buffer const & buffer = cur.buffer();
|
Buffer const * buffer = cur.buffer();
|
||||||
docstring const snippet = latexString(*this);
|
docstring const snippet = latexString(*this);
|
||||||
preview_->addPreview(snippet, buffer);
|
preview_->addPreview(snippet, *buffer);
|
||||||
preview_->startLoading(buffer);
|
preview_->startLoading(*buffer);
|
||||||
cur.updateFlags(Update::Force);
|
cur.updateFlags(Update::Force);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1437,7 +1437,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
|
|||||||
MathWordList const & mwl = mathedWordList();
|
MathWordList const & mwl = mathedWordList();
|
||||||
bool star_macro = c == '*'
|
bool star_macro = c == '*'
|
||||||
&& (mwl.find(name.substr(1) + "*") != mwl.end()
|
&& (mwl.find(name.substr(1) + "*") != mwl.end()
|
||||||
|| cur.buffer().getMacro(name.substr(1) + "*", cur, true));
|
|| cur.buffer()->getMacro(name.substr(1) + "*", cur, true));
|
||||||
if (isAlphaASCII(c) || star_macro) {
|
if (isAlphaASCII(c) || star_macro) {
|
||||||
cur.activeMacro()->setName(name + docstring(1, c));
|
cur.activeMacro()->setName(name + docstring(1, c));
|
||||||
return true;
|
return true;
|
||||||
@ -1844,10 +1844,10 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
|
|||||||
{
|
{
|
||||||
// fill it with macros from the buffer
|
// fill it with macros from the buffer
|
||||||
MacroNameSet macros;
|
MacroNameSet macros;
|
||||||
cur.buffer().listMacroNames(macros);
|
cur.buffer()->listMacroNames(macros);
|
||||||
MacroNameSet::const_iterator it;
|
MacroNameSet::const_iterator it;
|
||||||
for (it = macros.begin(); it != macros.end(); ++it) {
|
for (it = macros.begin(); it != macros.end(); ++it) {
|
||||||
if (cur.buffer().getMacro(*it, cur, false))
|
if (cur.buffer()->getMacro(*it, cur, false))
|
||||||
locals.push_back("\\" + *it);
|
locals.push_back("\\" + *it);
|
||||||
}
|
}
|
||||||
sort(locals.begin(), locals.end());
|
sort(locals.begin(), locals.end());
|
||||||
|
@ -67,12 +67,15 @@ void MacroData::expand(vector<MathData> const & args, MathData & to) const
|
|||||||
{
|
{
|
||||||
updateData();
|
updateData();
|
||||||
|
|
||||||
InsetMathSqrt inset; // Hack. Any inset with a cell would do.
|
// Hack. Any inset with a cell would do.
|
||||||
|
static Buffer buffer("");
|
||||||
|
static InsetMathSqrt inset;
|
||||||
|
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
asArray(display_.empty() ? definition_ : display_, inset.cell(0));
|
asArray(display_.empty() ? definition_ : display_, inset.cell(0));
|
||||||
//lyxerr << "MathData::expand: args: " << args << endl;
|
//lyxerr << "MathData::expand: args: " << args << endl;
|
||||||
//lyxerr << "MathData::expand: ar: " << inset.cell(0) << endl;
|
//lyxerr << "MathData::expand: ar: " << inset.cell(0) << endl;
|
||||||
for (DocIterator it = doc_iterator_begin(inset); it; it.forwardChar()) {
|
for (DocIterator it = doc_iterator_begin(&buffer, &inset); it; it.forwardChar()) {
|
||||||
if (!it.nextInset())
|
if (!it.nextInset())
|
||||||
continue;
|
continue;
|
||||||
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
||||||
|
@ -630,8 +630,9 @@ bool MathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroTemplate::removeArguments(Cursor & cur, int from, int to) {
|
void MathMacroTemplate::removeArguments(Cursor & cur, int from, int to)
|
||||||
for (DocIterator it = doc_iterator_begin(*this); it; it.forwardChar()) {
|
{
|
||||||
|
for (DocIterator it = doc_iterator_begin(&buffer(), this); it; it.forwardChar()) {
|
||||||
if (!it.nextInset())
|
if (!it.nextInset())
|
||||||
continue;
|
continue;
|
||||||
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
||||||
@ -651,8 +652,9 @@ void MathMacroTemplate::removeArguments(Cursor & cur, int from, int to) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMacroTemplate::shiftArguments(size_t from, int by) {
|
void MathMacroTemplate::shiftArguments(size_t from, int by)
|
||||||
for (DocIterator it = doc_iterator_begin(*this); it; it.forwardChar()) {
|
{
|
||||||
|
for (DocIterator it = doc_iterator_begin(&buffer(), this); it; it.forwardChar()) {
|
||||||
if (!it.nextInset())
|
if (!it.nextInset())
|
||||||
continue;
|
continue;
|
||||||
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
if (it.nextInset()->lyxCode() != MATHMACROARG_CODE)
|
||||||
@ -669,8 +671,7 @@ void MathMacroTemplate::shiftArguments(size_t from, int by) {
|
|||||||
int MathMacroTemplate::maxArgumentInDefinition() const
|
int MathMacroTemplate::maxArgumentInDefinition() const
|
||||||
{
|
{
|
||||||
int maxArg = 0;
|
int maxArg = 0;
|
||||||
MathMacroTemplate * nonConst = const_cast<MathMacroTemplate *>(this);
|
DocIterator it = doc_iterator_begin(&buffer(), this);
|
||||||
DocIterator it = doc_iterator_begin(*nonConst);
|
|
||||||
it.idx() = defIdx();
|
it.idx() = defIdx();
|
||||||
for (; it; it.forwardChar()) {
|
for (; it; it.forwardChar()) {
|
||||||
if (!it.nextInset())
|
if (!it.nextInset())
|
||||||
@ -690,7 +691,7 @@ void MathMacroTemplate::insertMissingArguments(int maxArg)
|
|||||||
idx_type idx = cell(displayIdx()).empty() ? defIdx() : displayIdx();
|
idx_type idx = cell(displayIdx()).empty() ? defIdx() : displayIdx();
|
||||||
|
|
||||||
// search for #n macros arguments
|
// search for #n macros arguments
|
||||||
DocIterator it = doc_iterator_begin(*this);
|
DocIterator it = doc_iterator_begin(&buffer(), this);
|
||||||
it.idx() = idx;
|
it.idx() = idx;
|
||||||
for (; it && it[0].idx() == idx; it.forwardChar()) {
|
for (; it && it[0].idx() == idx; it.forwardChar()) {
|
||||||
if (!it.nextInset())
|
if (!it.nextInset())
|
||||||
|
Loading…
Reference in New Issue
Block a user