mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-12 22:14:35 +00:00
Move one Text::setCursor instance to CursorSlice
This method did access more CursorSlice than Text. It is only a setter for CursorSlice with some bound checking. The new signature is setPitPos(pit_type, pos_type).
This commit is contained in:
parent
0437d8dc1a
commit
a8cfeb1538
@ -92,6 +92,28 @@ CursorSlice::col_type CursorSlice::col() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CursorSlice::setPitPos(pit_type pit, pos_type pos)
|
||||||
|
{
|
||||||
|
LASSERT(pit != int(text()->paragraphs().size()), return);
|
||||||
|
pit_ = pit;
|
||||||
|
pos_ = pos;
|
||||||
|
|
||||||
|
// Now some strict checking. None of these should happen, but
|
||||||
|
// we're scaredy-cats
|
||||||
|
if (pos < 0) {
|
||||||
|
LYXERR0("Don't like -1!");
|
||||||
|
LATTEST(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos > paragraph().size()) {
|
||||||
|
LYXERR0("Don't like 1, pos: " << pos
|
||||||
|
<< " size: " << paragraph().size()
|
||||||
|
<< " par: " << pit);
|
||||||
|
LATTEST(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CursorSlice::forwardPos()
|
void CursorSlice::forwardPos()
|
||||||
{
|
{
|
||||||
// move on one position if possible
|
// move on one position if possible
|
||||||
|
@ -119,6 +119,8 @@ public:
|
|||||||
Text * text() const { return inset_->getText(idx_); }
|
Text * text() const { return inset_->getText(idx_); }
|
||||||
/// paragraph in this cell
|
/// paragraph in this cell
|
||||||
Paragraph & paragraph() const;
|
Paragraph & paragraph() const;
|
||||||
|
///
|
||||||
|
void setPitPos(pit_type pit, pos_type pos);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// mathed specific stuff
|
/// mathed specific stuff
|
||||||
|
@ -1601,7 +1601,7 @@ bool Text::erase(Cursor & cur)
|
|||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
// Make sure the cursor is correct. Is this really needed?
|
// Make sure the cursor is correct. Is this really needed?
|
||||||
// No, not really... at least not here!
|
// No, not really... at least not here!
|
||||||
cur.text()->setCursor(cur.top(), cur.pit(), cur.pos());
|
cur.top().setPitPos(cur.pit(), cur.pos());
|
||||||
cur.checkBufferStructure();
|
cur.checkBufferStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1708,7 +1708,7 @@ bool Text::backspace(Cursor & cur)
|
|||||||
|
|
||||||
// A singlePar update is not enough in this case.
|
// A singlePar update is not enough in this case.
|
||||||
// cur.screenUpdateFlags(Update::Force);
|
// cur.screenUpdateFlags(Update::Force);
|
||||||
setCursor(cur.top(), cur.pit(), cur.pos());
|
cur.top().setPitPos(cur.pit(), cur.pos());
|
||||||
|
|
||||||
return needsUpdate;
|
return needsUpdate;
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,6 @@ public:
|
|||||||
bool setCursor(Cursor & cur, pit_type pit, pos_type pos,
|
bool setCursor(Cursor & cur, pit_type pit, pos_type pos,
|
||||||
bool setfont = true, bool boundary = false);
|
bool setfont = true, bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCursor(CursorSlice &, pit_type pit, pos_type pos);
|
|
||||||
///
|
|
||||||
void setCursorIntern(Cursor & cur, pit_type pit,
|
void setCursorIntern(Cursor & cur, pit_type pit,
|
||||||
pos_type pos, bool setfont = true, bool boundary = false);
|
pos_type pos, bool setfont = true, bool boundary = false);
|
||||||
|
|
||||||
|
@ -558,36 +558,12 @@ bool Text::setCursor(Cursor & cur, pit_type pit, pos_type pos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Text::setCursor(CursorSlice & cur, pit_type pit, pos_type pos)
|
|
||||||
{
|
|
||||||
LASSERT(pit != int(paragraphs().size()), return);
|
|
||||||
cur.pit() = pit;
|
|
||||||
cur.pos() = pos;
|
|
||||||
|
|
||||||
// now some strict checking
|
|
||||||
Paragraph const & par = getPar(pit);
|
|
||||||
|
|
||||||
// None of these should happen, but we're scaredy-cats
|
|
||||||
if (pos < 0) {
|
|
||||||
LYXERR0("Don't like -1!");
|
|
||||||
LATTEST(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos > par.size()) {
|
|
||||||
LYXERR0("Don't like 1, pos: " << pos
|
|
||||||
<< " size: " << par.size()
|
|
||||||
<< " par: " << pit);
|
|
||||||
LATTEST(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Text::setCursorIntern(Cursor & cur, pit_type pit, pos_type pos,
|
void Text::setCursorIntern(Cursor & cur, pit_type pit, pos_type pos,
|
||||||
bool setfont, bool boundary)
|
bool setfont, bool boundary)
|
||||||
{
|
{
|
||||||
LBUFERR(this == cur.text());
|
LBUFERR(this == cur.text());
|
||||||
cur.boundary(boundary);
|
cur.boundary(boundary);
|
||||||
setCursor(cur.top(), pit, pos);
|
cur.top().setPitPos(pit, pos);
|
||||||
if (setfont)
|
if (setfont)
|
||||||
cur.setCurrentFont();
|
cur.setCurrentFont();
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ void InsetText::edit(Cursor & cur, bool front, EntryDirection entry_from)
|
|||||||
pos = temp_cur.pos();
|
pos = temp_cur.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
text_.setCursor(cur.top(), pit, pos);
|
cur.top().setPitPos(pit, pos);
|
||||||
cur.finishUndo();
|
cur.finishUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user