mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
replace ParagraphList::iterator by lyx::paroffset_type to prevent cursor
invalidation if the paragraphlist is changed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7883 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fc1437e74e
commit
dcd8fb0428
@ -270,7 +270,7 @@ bool BufferView::insertLyXFile(string const & filen)
|
|||||||
|
|
||||||
text->breakParagraph(buffer()->paragraphs());
|
text->breakParagraph(buffer()->paragraphs());
|
||||||
|
|
||||||
bool res = buffer()->readFile(fname, text->cursor.par());
|
bool res = buffer()->readFile(fname, text->cursorPar());
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
return res;
|
return res;
|
||||||
@ -301,15 +301,10 @@ void BufferView::setCursorFromRow(int row)
|
|||||||
|
|
||||||
buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
|
buffer()->texrow().getIdFromRow(row, tmpid, tmppos);
|
||||||
|
|
||||||
ParagraphList::iterator texrowpar;
|
if (tmpid == -1)
|
||||||
|
text->setCursor(0, 0);
|
||||||
if (tmpid == -1) {
|
else
|
||||||
texrowpar = text->ownerParagraphs().begin();
|
text->setCursor(buffer()->getParFromID(tmpid).pit(), tmppos);
|
||||||
tmppos = 0;
|
|
||||||
} else {
|
|
||||||
texrowpar = buffer()->getParFromID(tmpid).pit();
|
|
||||||
}
|
|
||||||
text->setCursor(texrowpar, tmppos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,7 +322,9 @@ void BufferView::gotoLabel(string const & label)
|
|||||||
it->getLabelList(*buffer(), labels);
|
it->getLabelList(*buffer(), labels);
|
||||||
if (find(labels.begin(),labels.end(),label) != labels.end()) {
|
if (find(labels.begin(),labels.end(),label) != labels.end()) {
|
||||||
beforeChange(text);
|
beforeChange(text);
|
||||||
text->setCursor(it.getPar(), it.getPos());
|
text->setCursor(
|
||||||
|
std::distance(text->ownerParagraphs().begin(), it.getPar()),
|
||||||
|
it.getPos());
|
||||||
text->selection.cursor = text->cursor;
|
text->selection.cursor = text->cursor;
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
@ -424,31 +421,34 @@ bool BufferView::lockInset(UpdatableInset * inset)
|
|||||||
{
|
{
|
||||||
if (!inset)
|
if (!inset)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// don't relock if we're already locked
|
// don't relock if we're already locked
|
||||||
if (theLockingInset() == inset)
|
if (theLockingInset() == inset)
|
||||||
return true;
|
return true;
|
||||||
if (!theLockingInset()) {
|
|
||||||
|
if (theLockingInset())
|
||||||
|
return theLockingInset()->lockInsetInInset(this, inset);
|
||||||
|
|
||||||
// first check if it's the inset under the cursor we want lock
|
// first check if it's the inset under the cursor we want lock
|
||||||
// should be most of the time
|
// should be most of the time
|
||||||
if (text->cursor.pos() < text->cursor.par()->size()
|
if (text->cursor.pos() < text->cursorPar()->size()
|
||||||
&& text->cursor.par()->getChar(text->cursor.pos()) ==
|
&& text->cursorPar()->getChar(text->cursor.pos()) ==
|
||||||
Paragraph::META_INSET) {
|
Paragraph::META_INSET) {
|
||||||
InsetOld * in = text->cursor.par()->getInset(text->cursor.pos());
|
if (inset == text->cursorPar()->getInset(text->cursor.pos())) {
|
||||||
if (inset == in) {
|
|
||||||
theLockingInset(inset);
|
theLockingInset(inset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Then do a deep look of the inset and lock the right one
|
|
||||||
int const id = inset->id();
|
// then do a deep look at the inset and lock the right one
|
||||||
ParagraphList::iterator pit = buffer()->paragraphs().begin();
|
ParagraphList::iterator pit = buffer()->paragraphs().begin();
|
||||||
ParagraphList::iterator pend = buffer()->paragraphs().end();
|
ParagraphList::iterator pend = buffer()->paragraphs().end();
|
||||||
for (; pit != pend; ++pit) {
|
for (int par = 0; pit != pend; ++pit, ++par) {
|
||||||
InsetList::iterator it = pit->insetlist.begin();
|
InsetList::iterator it = pit->insetlist.begin();
|
||||||
InsetList::iterator end = pit->insetlist.end();
|
InsetList::iterator end = pit->insetlist.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (it->inset == inset) {
|
if (it->inset == inset) {
|
||||||
text->setCursorIntern(pit, it->pos);
|
text->setCursorIntern(par, it->pos);
|
||||||
theLockingInset(inset);
|
theLockingInset(inset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -456,8 +456,6 @@ bool BufferView::lockInset(UpdatableInset * inset)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return theLockingInset()->lockInsetInInset(this, inset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
|
bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
|
||||||
@ -487,7 +485,7 @@ int BufferView::unlockInset(UpdatableInset * inset)
|
|||||||
inset->insetUnlock(this);
|
inset->insetUnlock(this);
|
||||||
theLockingInset(0);
|
theLockingInset(0);
|
||||||
// make sure we update the combo !
|
// make sure we update the combo !
|
||||||
owner()->setLayout(getLyXText()->cursor.par()->layout()->name());
|
owner()->setLayout(getLyXText()->cursorPar()->layout()->name());
|
||||||
// Tell the paragraph dialog that we changed paragraph
|
// Tell the paragraph dialog that we changed paragraph
|
||||||
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||||
finishUndo();
|
finishUndo();
|
||||||
@ -560,14 +558,15 @@ Language const * BufferView::getParentLanguage(InsetOld * inset) const
|
|||||||
|
|
||||||
Encoding const * BufferView::getEncoding() const
|
Encoding const * BufferView::getEncoding() const
|
||||||
{
|
{
|
||||||
LyXText * t = getLyXText();
|
LyXText * text = getLyXText();
|
||||||
if (!t)
|
if (!text)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LyXCursor const & c = t->cursor;
|
return text->cursorPar()->getFont(
|
||||||
LyXFont const font = c.par()->getFont(buffer()->params(), c.pos(),
|
buffer()->params(),
|
||||||
outerFont(c.par(), t->ownerParagraphs()));
|
text->cursor.pos(),
|
||||||
return font.language()->encoding();
|
outerFont(text->cursorPar(), text->ownerParagraphs())
|
||||||
|
).language()->encoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
|||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
// Don't forget to update the Layout
|
// Don't forget to update the Layout
|
||||||
string const layoutname =
|
string const layoutname =
|
||||||
bv_->text->cursor.par()->layout()->name();
|
bv_->text->cursorPar()->layout()->name();
|
||||||
owner_->setLayout(layoutname);
|
owner_->setLayout(layoutname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,9 +404,9 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
{
|
{
|
||||||
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
|
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
|
||||||
|
|
||||||
ParagraphList::iterator par;
|
int par = -1;
|
||||||
ParagraphList::iterator selstartpar;
|
int selstartpar = -1;
|
||||||
ParagraphList::iterator selendpar;
|
int selendpar = -1;
|
||||||
UpdatableInset * the_locking_inset = 0;
|
UpdatableInset * the_locking_inset = 0;
|
||||||
|
|
||||||
pos_type pos = 0;
|
pos_type pos = 0;
|
||||||
@ -451,17 +451,13 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
|
bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs());
|
||||||
bv_->text->init(bv_);
|
bv_->text->init(bv_);
|
||||||
}
|
}
|
||||||
|
|
||||||
par = bv_->text->ownerParagraphs().end();
|
|
||||||
selstartpar = bv_->text->ownerParagraphs().end();
|
|
||||||
selendpar = bv_->text->ownerParagraphs().end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning does not help much
|
#warning does not help much
|
||||||
//bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
|
//bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
|
||||||
// bv_->text->ownerParagraphs().end());
|
// bv_->text->ownerParagraphs().end());
|
||||||
|
|
||||||
if (par != bv_->text->ownerParagraphs().end()) {
|
if (par != -1) {
|
||||||
bv_->text->selection.set(true);
|
bv_->text->selection.set(true);
|
||||||
// At this point just to avoid the Delete-Empty-Paragraph-
|
// At this point just to avoid the Delete-Empty-Paragraph-
|
||||||
// Mechanism when setting the cursor.
|
// Mechanism when setting the cursor.
|
||||||
@ -699,8 +695,8 @@ Change const BufferView::Pimpl::getCurrentChange()
|
|||||||
if (!text->selection.set())
|
if (!text->selection.set())
|
||||||
return Change(Change::UNCHANGED);
|
return Change(Change::UNCHANGED);
|
||||||
|
|
||||||
LyXCursor const & cur = text->selection.start;
|
return text->getPar(text->selection.start)
|
||||||
return cur.par()->lookupChangeFull(cur.pos());
|
->lookupChangeFull(text->selection.start.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -715,7 +711,7 @@ void BufferView::Pimpl::savePosition(unsigned int i)
|
|||||||
if (i >= saved_positions_num)
|
if (i >= saved_positions_num)
|
||||||
return;
|
return;
|
||||||
saved_positions[i] = Position(buffer_->fileName(),
|
saved_positions[i] = Position(buffer_->fileName(),
|
||||||
bv_->text->cursor.par()->id(),
|
bv_->text->cursorPar()->id(),
|
||||||
bv_->text->cursor.pos());
|
bv_->text->cursor.pos());
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
|
owner_->message(bformat(_("Saved bookmark %1$s"), tostr(i)));
|
||||||
@ -732,14 +728,14 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
|
|||||||
beforeChange(bv_->text);
|
beforeChange(bv_->text);
|
||||||
|
|
||||||
if (fname != buffer_->fileName()) {
|
if (fname != buffer_->fileName()) {
|
||||||
Buffer * b;
|
Buffer * b = 0;
|
||||||
if (bufferlist.exists(fname))
|
if (bufferlist.exists(fname))
|
||||||
b = bufferlist.getBuffer(fname);
|
b = bufferlist.getBuffer(fname);
|
||||||
else {
|
else {
|
||||||
b = bufferlist.newBuffer(fname);
|
b = bufferlist.newBuffer(fname);
|
||||||
::loadLyXFile(b, fname); // don't ask, just load it
|
::loadLyXFile(b, fname); // don't ask, just load it
|
||||||
}
|
}
|
||||||
if (b != 0)
|
if (b)
|
||||||
buffer(b);
|
buffer(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,7 +833,7 @@ InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
|
|||||||
LyXCursor cursor = bv_->getLyXText()->cursor;
|
LyXCursor cursor = bv_->getLyXText()->cursor;
|
||||||
Buffer::inset_iterator it =
|
Buffer::inset_iterator it =
|
||||||
find_if(Buffer::inset_iterator(
|
find_if(Buffer::inset_iterator(
|
||||||
cursor.par(), cursor.pos()),
|
cursorPar(), cursor.pos()),
|
||||||
buffer_->inset_iterator_end(),
|
buffer_->inset_iterator_end(),
|
||||||
lyx::compare_memfun(&Inset::lyxCode, code));
|
lyx::compare_memfun(&Inset::lyxCode, code));
|
||||||
return it != buffer_->inset_iterator_end() ? (*it) : 0;
|
return it != buffer_->inset_iterator_end() ? (*it) : 0;
|
||||||
@ -846,22 +842,22 @@ InsetOld * BufferView::Pimpl::getInsetByCode(InsetOld::Code code)
|
|||||||
// should work for now. Better infrastructure is coming. (Lgb)
|
// should work for now. Better infrastructure is coming. (Lgb)
|
||||||
|
|
||||||
Buffer * b = bv_->buffer();
|
Buffer * b = bv_->buffer();
|
||||||
LyXCursor cursor = bv_->getLyXText()->cursor;
|
LyXText * text = bv_->getLyXText();
|
||||||
|
|
||||||
Buffer::inset_iterator beg = b->inset_iterator_begin();
|
Buffer::inset_iterator beg = b->inset_iterator_begin();
|
||||||
Buffer::inset_iterator end = b->inset_iterator_end();
|
Buffer::inset_iterator end = b->inset_iterator_end();
|
||||||
|
|
||||||
bool cursor_par_seen = false;
|
bool cursorPar_seen = false;
|
||||||
|
|
||||||
for (; beg != end; ++beg) {
|
for (; beg != end; ++beg) {
|
||||||
if (beg.getPar() == cursor.par()) {
|
if (beg.getPar() == text->cursorPar()) {
|
||||||
cursor_par_seen = true;
|
cursorPar_seen = true;
|
||||||
}
|
}
|
||||||
if (cursor_par_seen) {
|
if (cursorPar_seen) {
|
||||||
if (beg.getPar() == cursor.par()
|
if (beg.getPar() == text->cursorPar()
|
||||||
&& beg.getPos() >= cursor.pos()) {
|
&& beg.getPos() >= text->cursor.pos()) {
|
||||||
break;
|
break;
|
||||||
} else if (beg.getPar() != cursor.par()) {
|
} else if (beg.getPar() != text->cursorPar()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -948,7 +944,7 @@ void BufferView::Pimpl::trackChanges()
|
|||||||
buf->undostack().clear();
|
buf->undostack().clear();
|
||||||
} else {
|
} else {
|
||||||
update();
|
update();
|
||||||
bv_->text->setCursor(buf->paragraphs().begin(), 0);
|
bv_->text->setCursor(0, 0);
|
||||||
#warning changes FIXME
|
#warning changes FIXME
|
||||||
//moveCursorUpdate(false);
|
//moveCursorUpdate(false);
|
||||||
|
|
||||||
@ -1227,7 +1223,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
|||||||
|
|
||||||
case LFUN_LAYOUT_PARAGRAPH: {
|
case LFUN_LAYOUT_PARAGRAPH: {
|
||||||
string data;
|
string data;
|
||||||
params2string(*bv_->getLyXText()->cursor.par(), data);
|
params2string(*bv_->getLyXText()->cursorPar(), data);
|
||||||
|
|
||||||
data = "show\n" + data;
|
data = "show\n" + data;
|
||||||
bv_->owner()->getDialogs().show("paragraph", data);
|
bv_->owner()->getDialogs().show("paragraph", data);
|
||||||
@ -1237,7 +1233,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
|||||||
case LFUN_PARAGRAPH_UPDATE: {
|
case LFUN_PARAGRAPH_UPDATE: {
|
||||||
if (!bv_->owner()->getDialogs().visible("paragraph"))
|
if (!bv_->owner()->getDialogs().visible("paragraph"))
|
||||||
break;
|
break;
|
||||||
Paragraph const & par = *bv_->getLyXText()->cursor.par();
|
Paragraph const & par = *bv_->getLyXText()->cursorPar();
|
||||||
|
|
||||||
string data;
|
string data;
|
||||||
params2string(par, data);
|
params2string(par, data);
|
||||||
@ -1286,7 +1282,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_ACCEPT_ALL_CHANGES: {
|
case LFUN_ACCEPT_ALL_CHANGES: {
|
||||||
bv_->text->setCursor(bv_->buffer()->paragraphs().begin(), 0);
|
bv_->text->setCursor(0, 0);
|
||||||
#warning FIXME changes
|
#warning FIXME changes
|
||||||
//moveCursorUpdate(false);
|
//moveCursorUpdate(false);
|
||||||
|
|
||||||
@ -1298,7 +1294,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_REJECT_ALL_CHANGES: {
|
case LFUN_REJECT_ALL_CHANGES: {
|
||||||
bv_->text->setCursor(bv_->buffer()->paragraphs().begin(), 0);
|
bv_->text->setCursor(0, 0);
|
||||||
#warning FIXME changes
|
#warning FIXME changes
|
||||||
//moveCursorUpdate(false);
|
//moveCursorUpdate(false);
|
||||||
|
|
||||||
@ -1351,7 +1347,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
|
|||||||
if (!lout.empty()) {
|
if (!lout.empty()) {
|
||||||
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
||||||
|
|
||||||
if (!bv_->text->cursor.par()->empty()) {
|
if (!bv_->text->cursorPar()->empty()) {
|
||||||
bv_->text->cursorLeft(bv_);
|
bv_->text->cursorLeft(bv_);
|
||||||
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
bv_->text->breakParagraph(bv_->buffer()->paragraphs());
|
||||||
}
|
}
|
||||||
@ -1396,7 +1392,7 @@ void BufferView::Pimpl::updateInset(InsetOld const * inset)
|
|||||||
bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
|
bv_->text->redoParagraph(outerPar(*bv_->buffer(), inset));
|
||||||
|
|
||||||
// this should not be needed, but it is...
|
// this should not be needed, but it is...
|
||||||
// bv_->text->redoParagraph(bv_->text->cursor.par());
|
// bv_->text->redoParagraph(bv_->text->cursorPar());
|
||||||
// bv_->text->fullRebreak();
|
// bv_->text->fullRebreak();
|
||||||
|
|
||||||
update();
|
update();
|
||||||
@ -1433,10 +1429,10 @@ bool BufferView::Pimpl::ChangeInsets(InsetOld::Code code,
|
|||||||
// FIXME
|
// FIXME
|
||||||
|
|
||||||
// The test it.size()==1 was needed to prevent crashes.
|
// The test it.size()==1 was needed to prevent crashes.
|
||||||
// How to set the cursor corretly when it.size()>1 ??
|
// How to set the cursor correctly when it.size()>1 ??
|
||||||
if (it.size() == 1) {
|
if (it.size() == 1) {
|
||||||
bv_->text->setCursorIntern(it.pit(), 0);
|
bv_->text->setCursorIntern(bv_->text->parOffset(it.pit()), 0);
|
||||||
bv_->text->redoParagraph(bv_->text->cursor.par());
|
bv_->text->redoParagraph(bv_->text->cursorPar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
|
||||||
|
2003-10-09 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* lyxcursor.h: use paroffset_type instead of ParagraphList::iterator
|
||||||
|
|
||||||
|
* BufferView.C:
|
||||||
|
* BufferView_pimpl.C:
|
||||||
|
* bufferview_funcs.C:
|
||||||
|
* lyx_cb.C:
|
||||||
|
* lyxcursor.C:
|
||||||
|
* lyxfind.C:
|
||||||
|
* lyxfunc.C:
|
||||||
|
* lyxtext.h:
|
||||||
|
* text.C:
|
||||||
|
* text2.C:
|
||||||
|
* text3.C:
|
||||||
|
* text_funcs.[Ch]:
|
||||||
|
* textcursor.[Ch]:
|
||||||
|
* undo_funcs.C: adjust
|
||||||
|
|
||||||
2003-10-08 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-10-08 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* text2.C (incrementItemDepth): new function, use a backtracking
|
* text2.C (incrementItemDepth): new function, use a backtracking
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class InsetOld;
|
class InsetOld;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
|
|
||||||
|
@ -301,19 +301,18 @@ string const currentState(BufferView * bv)
|
|||||||
|
|
||||||
LyXText * text = bv->getLyXText();
|
LyXText * text = bv->getLyXText();
|
||||||
Buffer * buffer = bv->buffer();
|
Buffer * buffer = bv->buffer();
|
||||||
LyXCursor const & c(text->cursor);
|
LyXCursor const & c = text->cursor;
|
||||||
|
|
||||||
bool const show_change = buffer->params().tracking_changes
|
bool const show_change = buffer->params().tracking_changes
|
||||||
&& c.pos() != c.par()->size()
|
&& text->cursor.pos() != text->cursorPar()->size()
|
||||||
&& c.par()->lookupChange(c.pos()) != Change::UNCHANGED;
|
&& text->cursorPar()->lookupChange(c.pos()) != Change::UNCHANGED;
|
||||||
|
|
||||||
if (show_change) {
|
if (show_change) {
|
||||||
Change change(c.par()->lookupChangeFull(c.pos()));
|
Change change = text->cursorPar()->lookupChangeFull(c.pos());
|
||||||
Author const & a(bv->buffer()->params().authors().get(change.author));
|
Author const & a = bv->buffer()->params().authors().get(change.author);
|
||||||
state << _("Change: ") << a.name();
|
state << _("Change: ") << a.name();
|
||||||
if (!a.email().empty()) {
|
if (!a.email().empty())
|
||||||
state << " (" << a.email() << ")";
|
state << " (" << a.email() << ")";
|
||||||
}
|
|
||||||
if (change.changetime)
|
if (change.changetime)
|
||||||
state << _(" at ") << ctime(&change.changetime);
|
state << _(" at ") << ctime(&change.changetime);
|
||||||
state << " : ";
|
state << " : ";
|
||||||
@ -322,9 +321,7 @@ string const currentState(BufferView * bv)
|
|||||||
// I think we should only show changes from the default
|
// I think we should only show changes from the default
|
||||||
// font. (Asger)
|
// font. (Asger)
|
||||||
LyXFont font = text->real_current_font;
|
LyXFont font = text->real_current_font;
|
||||||
LyXFont const & defaultfont =
|
font.reduce(buffer->params().getLyXTextClass().defaultfont());
|
||||||
buffer->params().getLyXTextClass().defaultfont();
|
|
||||||
font.reduce(defaultfont);
|
|
||||||
|
|
||||||
// avoid _(...) re-entrance problem
|
// avoid _(...) re-entrance problem
|
||||||
string const s = font.stateText(&buffer->params());
|
string const s = font.stateText(&buffer->params());
|
||||||
@ -339,9 +336,9 @@ string const currentState(BufferView * bv)
|
|||||||
|
|
||||||
// The paragraph spacing, but only if different from
|
// The paragraph spacing, but only if different from
|
||||||
// buffer spacing.
|
// buffer spacing.
|
||||||
if (!text->cursor.par()->params().spacing().isDefault()) {
|
if (!text->cursorPar()->params().spacing().isDefault()) {
|
||||||
Spacing::Space cur_space =
|
Spacing::Space cur_space =
|
||||||
text->cursor.par()->params().spacing().getSpace();
|
text->cursorPar()->params().spacing().getSpace();
|
||||||
state << _(", Spacing: ");
|
state << _(", Spacing: ");
|
||||||
|
|
||||||
switch (cur_space) {
|
switch (cur_space) {
|
||||||
@ -356,7 +353,7 @@ string const currentState(BufferView * bv)
|
|||||||
break;
|
break;
|
||||||
case Spacing::Other:
|
case Spacing::Other:
|
||||||
state << _("Other (")
|
state << _("Other (")
|
||||||
<< text->cursor.par()->params().spacing().getValue()
|
<< text->cursorPar()->params().spacing().getValue()
|
||||||
<< ')';
|
<< ')';
|
||||||
break;
|
break;
|
||||||
case Spacing::Default:
|
case Spacing::Default:
|
||||||
@ -365,12 +362,12 @@ string const currentState(BufferView * bv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEVEL_VERSION
|
#ifdef DEVEL_VERSION
|
||||||
state << _(", Paragraph: ") << text->cursor.par()->id();
|
state << _(", Paragraph: ") << text->cursorPar()->id();
|
||||||
state << _(", Position: ") << text->cursor.pos();
|
state << _(", Position: ") << text->cursor.pos();
|
||||||
RowList::iterator rit = text->cursorRow();
|
RowList::iterator rit = text->cursorRow();
|
||||||
state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end());
|
state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end());
|
||||||
state << _(", Inset: ");
|
state << _(", Inset: ");
|
||||||
InsetOld * inset = text->cursor.par()->inInset();
|
InsetOld * inset = text->cursorPar()->inInset();
|
||||||
if (inset)
|
if (inset)
|
||||||
state << inset << " id: " << inset->id()
|
state << inset << " id: " << inset->id()
|
||||||
<< " text: " << inset->getLyXText(bv, true)
|
<< " text: " << inset->getLyXText(bv, true)
|
||||||
@ -402,10 +399,10 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
|||||||
if (font.language() != ignore_language ||
|
if (font.language() != ignore_language ||
|
||||||
font.number() != LyXFont::IGNORE) {
|
font.number() != LyXFont::IGNORE) {
|
||||||
LyXCursor & cursor = text->cursor;
|
LyXCursor & cursor = text->cursor;
|
||||||
text->computeBidiTables(text->cursor.par(), *bv->buffer(),
|
text->computeBidiTables(text->cursorPar(), *bv->buffer(),
|
||||||
text->cursorRow());
|
text->cursorRow());
|
||||||
if (cursor.boundary() !=
|
if (cursor.boundary() !=
|
||||||
text->isBoundary(*bv->buffer(), *cursor.par(), cursor.pos(),
|
text->isBoundary(*bv->buffer(), *text->cursorPar(), cursor.pos(),
|
||||||
text->real_current_font))
|
text->real_current_font))
|
||||||
text->setCursor(cursor.par(), cursor.pos(),
|
text->setCursor(cursor.par(), cursor.pos(),
|
||||||
false, !cursor.boundary());
|
false, !cursor.boundary());
|
||||||
|
@ -149,7 +149,7 @@ void LyXView::updateLayoutChoice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
string const & layout =
|
string const & layout =
|
||||||
bufferview_->getLyXText()->cursor.par()->layout()->name();
|
bufferview_->getLyXText()->cursorPar()->layout()->name();
|
||||||
|
|
||||||
if (layout != current_layout) {
|
if (layout != current_layout) {
|
||||||
toolbar_->setLayout(layout);
|
toolbar_->setLayout(layout);
|
||||||
|
@ -32,8 +32,7 @@ void ControlErrorList::clearParams()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
ErrorList const &
|
ErrorList const & ControlErrorList::errorList() const
|
||||||
ControlErrorList::errorList() const
|
|
||||||
{
|
{
|
||||||
return errorlist_;
|
return errorlist_;
|
||||||
}
|
}
|
||||||
|
@ -334,20 +334,18 @@ void InsetText::insetUnlock(BufferView * bv)
|
|||||||
no_selection = true;
|
no_selection = true;
|
||||||
locked = false;
|
locked = false;
|
||||||
|
|
||||||
if (text_.selection.set()) {
|
if (text_.selection.set())
|
||||||
text_.clearSelection();
|
text_.clearSelection();
|
||||||
} else if (owner()) {
|
else if (owner())
|
||||||
bv->owner()->setLayout(owner()->getLyXText(bv)
|
bv->owner()->setLayout(owner()->getLyXText(bv)
|
||||||
->cursor.par()->layout()->name());
|
->cursorPar()->layout()->name());
|
||||||
} else
|
else
|
||||||
bv->owner()->setLayout(bv->text->cursor.par()->layout()->name());
|
bv->owner()->setLayout(bv->text->cursorPar()->layout()->name());
|
||||||
// hack for deleteEmptyParMech
|
// hack for deleteEmptyParMech
|
||||||
ParagraphList::iterator first_par = paragraphs.begin();
|
if (!paragraphs.begin()->empty())
|
||||||
if (!first_par->empty()) {
|
text_.setCursor(0, 0);
|
||||||
text_.setCursor(first_par, 0);
|
else if (paragraphs.size() > 1)
|
||||||
} else if (paragraphs.size() > 1) {
|
text_.setCursor(1, 0);
|
||||||
text_.setCursor(boost::next(first_par), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -359,7 +357,7 @@ void InsetText::lockInset(BufferView * bv)
|
|||||||
inset_boundary = false;
|
inset_boundary = false;
|
||||||
inset_par = paragraphs.end();
|
inset_par = paragraphs.end();
|
||||||
old_par = paragraphs.end();
|
old_par = paragraphs.end();
|
||||||
text_.setCursorIntern(paragraphs.begin(), 0);
|
text_.setCursorIntern(0, 0);
|
||||||
text_.clearSelection();
|
text_.clearSelection();
|
||||||
finishUndo();
|
finishUndo();
|
||||||
// If the inset is empty set the language of the current font to the
|
// If the inset is empty set the language of the current font to the
|
||||||
@ -400,7 +398,8 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
|
|||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (it->inset == inset) {
|
if (it->inset == inset) {
|
||||||
lyxerr << "InsetText::lockInsetInInset: 1 a" << endl;
|
lyxerr << "InsetText::lockInsetInInset: 1 a" << endl;
|
||||||
text_.setCursorIntern(pit, it->pos);
|
text_.setCursorIntern(
|
||||||
|
std::distance(paragraphs.begin(), pit), it->pos);
|
||||||
lyxerr << "InsetText::lockInsetInInset: 1 b" << endl;
|
lyxerr << "InsetText::lockInsetInInset: 1 b" << endl;
|
||||||
lyxerr << "bv: " << bv << " inset: " << inset << endl;
|
lyxerr << "bv: " << bv << " inset: " << inset << endl;
|
||||||
lockInset(bv, inset);
|
lockInset(bv, inset);
|
||||||
@ -630,11 +629,9 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
if (cmd.argument.size()) {
|
if (cmd.argument.size()) {
|
||||||
if (cmd.argument == "left")
|
if (cmd.argument == "left")
|
||||||
text_.setCursorIntern(paragraphs.begin(), 0);
|
text_.setCursorIntern(0, 0);
|
||||||
else {
|
else
|
||||||
ParagraphList::iterator it = boost::prior(paragraphs.end());
|
text_.setCursor(paragraphs.size() - 1, paragraphs.back().size());
|
||||||
text_.setCursor(it, it->size());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int tmp_y = (cmd.y < 0) ? 0 : cmd.y;
|
int tmp_y = (cmd.y < 0) ? 0 : cmd.y;
|
||||||
// we put here -1 and not button as now the button in the
|
// we put here -1 and not button as now the button in the
|
||||||
@ -751,7 +748,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
|||||||
* true (on). */
|
* true (on). */
|
||||||
#if 0
|
#if 0
|
||||||
// This should not be needed here and is also WRONG!
|
// This should not be needed here and is also WRONG!
|
||||||
recordUndo(bv, Undo::INSERT, text_.cursor.par());
|
recordUndo(bv, Undo::INSERT, text_.cursorPar());
|
||||||
#endif
|
#endif
|
||||||
bv->switchKeyMap();
|
bv->switchKeyMap();
|
||||||
|
|
||||||
@ -1201,7 +1198,7 @@ void InsetText::fitInsetCursor(BufferView * bv) const
|
|||||||
|
|
||||||
InsetOld::RESULT InsetText::moveRight(BufferView * bv)
|
InsetOld::RESULT InsetText::moveRight(BufferView * bv)
|
||||||
{
|
{
|
||||||
if (text_.cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (text_.cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
return moveLeftIntern(bv, false, true, false);
|
return moveLeftIntern(bv, false, true, false);
|
||||||
else
|
else
|
||||||
return moveRightIntern(bv, true, true, false);
|
return moveRightIntern(bv, true, true, false);
|
||||||
@ -1210,7 +1207,7 @@ InsetOld::RESULT InsetText::moveRight(BufferView * bv)
|
|||||||
|
|
||||||
InsetOld::RESULT InsetText::moveLeft(BufferView * bv)
|
InsetOld::RESULT InsetText::moveLeft(BufferView * bv)
|
||||||
{
|
{
|
||||||
if (text_.cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (text_.cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
return moveRightIntern(bv, true, true, false);
|
return moveRightIntern(bv, true, true, false);
|
||||||
else
|
else
|
||||||
return moveLeftIntern(bv, false, true, false);
|
return moveLeftIntern(bv, false, true, false);
|
||||||
@ -1358,7 +1355,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
|||||||
|
|
||||||
|
|
||||||
if (text_.selection.set())
|
if (text_.selection.set())
|
||||||
recordUndo(bv, Undo::ATOMIC, text_.cursor.par());
|
recordUndo(bv, Undo::ATOMIC, text_.cursorPar());
|
||||||
|
|
||||||
if (selectall) {
|
if (selectall) {
|
||||||
text_.cursorTop();
|
text_.cursorTop();
|
||||||
@ -1479,7 +1476,7 @@ int InsetText::cx() const
|
|||||||
{
|
{
|
||||||
int x = text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
|
int x = text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
|
||||||
if (the_locking_inset) {
|
if (the_locking_inset) {
|
||||||
LyXFont font = text_.getFont(text_.cursor.par(), text_.cursor.pos());
|
LyXFont font = text_.getFont(text_.cursorPar(), text_.cursor.pos());
|
||||||
if (font.isVisibleRightToLeft())
|
if (font.isVisibleRightToLeft())
|
||||||
x -= the_locking_inset->width();
|
x -= the_locking_inset->width();
|
||||||
}
|
}
|
||||||
@ -1501,7 +1498,7 @@ pos_type InsetText::cpos() const
|
|||||||
|
|
||||||
ParagraphList::iterator InsetText::cpar() const
|
ParagraphList::iterator InsetText::cpar() const
|
||||||
{
|
{
|
||||||
return text_.cursor.par();
|
return text_.cursorPar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1722,8 +1719,7 @@ bool InsetText::searchBackward(BufferView * bv, string const & str,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
ParagraphList::iterator pit = boost::prior(paragraphs.end());
|
text_.setCursor(paragraphs.size() - 1, paragraphs.back().size());
|
||||||
text_.setCursor(pit, pit->size());
|
|
||||||
}
|
}
|
||||||
lyx::find::SearchResult result =
|
lyx::find::SearchResult result =
|
||||||
lyx::find::find(bv, &text_, str, false, cs, mw);
|
lyx::find::find(bv, &text_, str, false, cs, mw);
|
||||||
@ -1750,30 +1746,30 @@ bool InsetText::checkInsertChar(LyXFont & font)
|
|||||||
void InsetText::collapseParagraphs(BufferView * bv)
|
void InsetText::collapseParagraphs(BufferView * bv)
|
||||||
{
|
{
|
||||||
while (paragraphs.size() > 1) {
|
while (paragraphs.size() > 1) {
|
||||||
ParagraphList::iterator first_par = paragraphs.begin();
|
ParagraphList::iterator const first = paragraphs.begin();
|
||||||
ParagraphList::iterator next_par = boost::next(first_par);
|
ParagraphList::iterator second = first;
|
||||||
size_t const first_par_size = first_par->size();
|
advance(second, 1);
|
||||||
|
size_t const first_par_size = first->size();
|
||||||
|
|
||||||
if (!first_par->empty() &&
|
if (!first->empty() &&
|
||||||
!next_par->empty() &&
|
!second->empty() &&
|
||||||
!first_par->isSeparator(first_par_size - 1)) {
|
!first->isSeparator(first_par_size - 1)) {
|
||||||
first_par->insertChar(first_par_size, ' ');
|
first->insertChar(first_par_size, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning probably broken
|
||||||
if (text_.selection.set()) {
|
if (text_.selection.set()) {
|
||||||
if (text_.selection.start.par() == next_par) {
|
if (text_.selection.start.par() == 1) {
|
||||||
text_.selection.start.par(first_par);
|
text_.selection.start.par(1);
|
||||||
text_.selection.start.pos(
|
text_.selection.start.pos(text_.selection.start.pos() + first_par_size);
|
||||||
text_.selection.start.pos() + first_par_size);
|
|
||||||
}
|
}
|
||||||
if (text_.selection.end.par() == next_par) {
|
if (text_.selection.end.par() == 2) {
|
||||||
text_.selection.end.par(first_par);
|
text_.selection.end.par(1);
|
||||||
text_.selection.end.pos(
|
text_.selection.end.pos(text_.selection.end.pos() + first_par_size);
|
||||||
text_.selection.end.pos() + first_par_size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeParagraph(bv->buffer()->params(), paragraphs, first_par);
|
mergeParagraph(bv->buffer()->params(), paragraphs, first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
|
|||||||
|
|
||||||
string const getPossibleLabel(BufferView const & bv)
|
string const getPossibleLabel(BufferView const & bv)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = bv.getLyXText()->cursor.par();
|
ParagraphList::iterator pit = bv.getLyXText()->cursorPar();
|
||||||
ParagraphList & plist = bv.getLyXText()->ownerParagraphs();
|
ParagraphList & plist = bv.getLyXText()->ownerParagraphs();
|
||||||
|
|
||||||
LyXLayout_ptr layout = pit->layout();
|
LyXLayout_ptr layout = pit->layout();
|
||||||
|
@ -17,18 +17,17 @@
|
|||||||
|
|
||||||
|
|
||||||
LyXCursor::LyXCursor()
|
LyXCursor::LyXCursor()
|
||||||
: par_(), pos_(0), boundary_(false),
|
: par_(-1), pos_(0), boundary_(false), x_(0), x_fix_(0), y_(0)
|
||||||
x_(0), x_fix_(0), y_(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void LyXCursor::par(ParagraphList::iterator pit)
|
void LyXCursor::par(lyx::paroffset_type par)
|
||||||
{
|
{
|
||||||
par_ = pit;
|
par_ = par;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ParagraphList::iterator LyXCursor::par() const
|
lyx::paroffset_type LyXCursor::par() const
|
||||||
{
|
{
|
||||||
return par_;
|
return par_;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#ifndef LYXCURSOR_H
|
#ifndef LYXCURSOR_H
|
||||||
#define LYXCURSOR_H
|
#define LYXCURSOR_H
|
||||||
|
|
||||||
#include "ParagraphList_fwd.h"
|
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,9 +30,9 @@ class LyXCursor {
|
|||||||
public:
|
public:
|
||||||
LyXCursor();
|
LyXCursor();
|
||||||
/// set the paragraph that contains this cursor
|
/// set the paragraph that contains this cursor
|
||||||
void par(ParagraphList::iterator pit);
|
void par(lyx::paroffset_type pit);
|
||||||
/// return the paragraph this cursor is in
|
/// return the paragraph this cursor is in
|
||||||
ParagraphList::iterator par() const;
|
lyx::paroffset_type par() const;
|
||||||
/// set the position within the paragraph
|
/// set the position within the paragraph
|
||||||
void pos(lyx::pos_type p);
|
void pos(lyx::pos_type p);
|
||||||
/// return the position within the paragraph
|
/// return the position within the paragraph
|
||||||
@ -68,7 +67,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// The paragraph the cursor is in.
|
/// The paragraph the cursor is in.
|
||||||
ParagraphList::iterator par_;
|
lyx::paroffset_type par_;
|
||||||
/// The position inside the paragraph
|
/// The position inside the paragraph
|
||||||
lyx::pos_type pos_;
|
lyx::pos_type pos_;
|
||||||
/**
|
/**
|
||||||
|
@ -31,10 +31,10 @@ using lyx::support::uppercase;
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace find {
|
namespace find {
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// returns true if the specified string is at the specified position
|
// returns true if the specified string is at the specified position
|
||||||
@ -45,7 +45,7 @@ bool isStringInText(Paragraph const & par, pos_type pos,
|
|||||||
string::size_type size = str.length();
|
string::size_type size = str.length();
|
||||||
pos_type i = 0;
|
pos_type i = 0;
|
||||||
pos_type parsize = par.size();
|
pos_type parsize = par.size();
|
||||||
while (((pos + i) < parsize)
|
while ((pos + i < parsize)
|
||||||
&& (string::size_type(i) < size)
|
&& (string::size_type(i) < size)
|
||||||
&& (cs ? (str[i] == par.getChar(pos + i))
|
&& (cs ? (str[i] == par.getChar(pos + i))
|
||||||
: (uppercase(str[i]) == uppercase(par.getChar(pos + i))))) {
|
: (uppercase(str[i]) == uppercase(par.getChar(pos + i))))) {
|
||||||
@ -71,7 +71,7 @@ bool isStringInText(Paragraph const & par, pos_type pos,
|
|||||||
SearchResult searchForward(BufferView * bv, LyXText * text, string const & str,
|
SearchResult searchForward(BufferView * bv, LyXText * text, string const & str,
|
||||||
bool const & cs, bool const & mw)
|
bool const & cs, bool const & mw)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = text->cursor.par();
|
ParagraphList::iterator pit = text->cursorPar();
|
||||||
ParagraphList::iterator pend = text->ownerParagraphs().end();
|
ParagraphList::iterator pend = text->ownerParagraphs().end();
|
||||||
pos_type pos = text->cursor.pos();
|
pos_type pos = text->cursor.pos();
|
||||||
UpdatableInset * inset;
|
UpdatableInset * inset;
|
||||||
@ -93,7 +93,7 @@ SearchResult searchForward(BufferView * bv, LyXText * text, string const & str,
|
|||||||
if (pit != pend) {
|
if (pit != pend) {
|
||||||
text->setCursor(pit, pos);
|
text->setCursor(pit, pos);
|
||||||
return SR_FOUND;
|
return SR_FOUND;
|
||||||
} else
|
}
|
||||||
return SR_NOT_FOUND;
|
return SR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ SearchResult searchBackward(BufferView * bv, LyXText * text,
|
|||||||
string const & str,
|
string const & str,
|
||||||
bool const & cs, bool const & mw)
|
bool const & cs, bool const & mw)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = text->cursor.par();
|
ParagraphList::iterator pit = text->cursorPar();
|
||||||
ParagraphList::iterator pbegin = text->ownerParagraphs().begin();
|
ParagraphList::iterator pbegin = text->ownerParagraphs().begin();
|
||||||
pos_type pos = text->cursor.pos();
|
pos_type pos = text->cursor.pos();
|
||||||
|
|
||||||
@ -150,6 +150,7 @@ SearchResult searchBackward(BufferView * bv, LyXText * text,
|
|||||||
} // anon namespace
|
} // anon namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int replace(BufferView * bv,
|
int replace(BufferView * bv,
|
||||||
string const & searchstr, string const & replacestr,
|
string const & searchstr, string const & replacestr,
|
||||||
bool forward, bool casesens, bool matchwrd, bool replaceall,
|
bool forward, bool casesens, bool matchwrd, bool replaceall,
|
||||||
@ -303,7 +304,7 @@ SearchResult find(BufferView * bv, LyXText * text,
|
|||||||
|
|
||||||
SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
|
SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = text->cursor.par();
|
ParagraphList::iterator pit = text->cursorPar();
|
||||||
ParagraphList::iterator pend = text->ownerParagraphs().end();
|
ParagraphList::iterator pend = text->ownerParagraphs().end();
|
||||||
pos_type pos = text->cursor.pos();
|
pos_type pos = text->cursor.pos();
|
||||||
|
|
||||||
|
@ -372,13 +372,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
|||||||
|
|
||||||
case LFUN_LAYOUT:
|
case LFUN_LAYOUT:
|
||||||
case LFUN_LAYOUT_PARAGRAPH: {
|
case LFUN_LAYOUT_PARAGRAPH: {
|
||||||
InsetOld * inset = view()->getLyXText()->cursor.par()->inInset();
|
InsetOld * inset = view()->getLyXText()->cursorPar()->inInset();
|
||||||
disable = inset && inset->forceDefaultParagraphs(inset);
|
disable = inset && inset->forceDefaultParagraphs(inset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_OPTARG:
|
case LFUN_INSET_OPTARG:
|
||||||
disable = (view()->getLyXText()->cursor.par()->layout()->optionalargs == 0);
|
disable = (view()->getLyXText()->cursorPar()->layout()->optionalargs == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_TABULAR_FEATURE:
|
case LFUN_TABULAR_FEATURE:
|
||||||
@ -736,7 +736,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
|||||||
flag.setOnOff(buf->isReadonly());
|
flag.setOnOff(buf->isReadonly());
|
||||||
break;
|
break;
|
||||||
case LFUN_APPENDIX:
|
case LFUN_APPENDIX:
|
||||||
flag.setOnOff(view()->getLyXText()->cursor.par()->params().startOfAppendix());
|
flag.setOnOff(view()->getLyXText()->cursorPar()->params().startOfAppendix());
|
||||||
break;
|
break;
|
||||||
case LFUN_SWITCHBUFFER:
|
case LFUN_SWITCHBUFFER:
|
||||||
// toggle on the current buffer, but do not toggle off
|
// toggle on the current buffer, but do not toggle off
|
||||||
@ -911,7 +911,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
|||||||
int dummy_y;
|
int dummy_y;
|
||||||
inset->getCursorPos(view(), inset_x, dummy_y);
|
inset->getCursorPos(view(), inset_x, dummy_y);
|
||||||
#endif
|
#endif
|
||||||
if ((action == LFUN_UNKNOWN_ACTION)
|
if (action == LFUN_UNKNOWN_ACTION
|
||||||
&& argument.empty()) {
|
&& argument.empty()) {
|
||||||
argument = encoded_last_key;
|
argument = encoded_last_key;
|
||||||
}
|
}
|
||||||
@ -1003,14 +1003,14 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
|
|||||||
owner->view_state_changed();
|
owner->view_state_changed();
|
||||||
break;
|
break;
|
||||||
case LFUN_RIGHT:
|
case LFUN_RIGHT:
|
||||||
if (!view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params())) {
|
if (!view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
|
||||||
view()->text->cursorRight(view());
|
view()->text->cursorRight(view());
|
||||||
moveCursorUpdate();
|
moveCursorUpdate();
|
||||||
owner->view_state_changed();
|
owner->view_state_changed();
|
||||||
}
|
}
|
||||||
goto exit_with_message;
|
goto exit_with_message;
|
||||||
case LFUN_LEFT:
|
case LFUN_LEFT:
|
||||||
if (view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params())) {
|
if (view()->text->cursorPar()->isRightToLeftPar(owner->buffer()->params())) {
|
||||||
view()->text->cursorRight(view());
|
view()->text->cursorRight(view());
|
||||||
moveCursorUpdate();
|
moveCursorUpdate();
|
||||||
owner->view_state_changed();
|
owner->view_state_changed();
|
||||||
|
@ -170,10 +170,18 @@ private:
|
|||||||
RowList::iterator
|
RowList::iterator
|
||||||
getRow(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
getRow(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
||||||
public:
|
public:
|
||||||
/// returns a pointer cursor row
|
/// returns an iterator pointing to a cursor row
|
||||||
RowList::iterator getRow(LyXCursor const & cursor) const;
|
RowList::iterator getRow(LyXCursor const & cursor) const;
|
||||||
/// convenience
|
/// convenience
|
||||||
RowList::iterator cursorRow() const;
|
RowList::iterator cursorRow() const;
|
||||||
|
/// returns an iterator pointing to a cursor paragraph
|
||||||
|
ParagraphList::iterator getPar(LyXCursor const & cursor) const;
|
||||||
|
///
|
||||||
|
ParagraphList::iterator getPar(lyx::paroffset_type par) const;
|
||||||
|
///
|
||||||
|
int parOffset(ParagraphList::iterator pit) const;
|
||||||
|
/// convenience
|
||||||
|
ParagraphList::iterator cursorPar() const;
|
||||||
/**
|
/**
|
||||||
* Return the next row, when cursor is at the end of the
|
* Return the next row, when cursor is at the end of the
|
||||||
* previous row, for insets that take a full row.
|
* previous row, for insets that take a full row.
|
||||||
@ -223,17 +231,19 @@ public:
|
|||||||
void selectSelectedWord();
|
void selectSelectedWord();
|
||||||
/// re-computes the cached coordinates in the cursor
|
/// re-computes the cached coordinates in the cursor
|
||||||
void redoCursor();
|
void redoCursor();
|
||||||
|
///
|
||||||
|
void setCursor(ParagraphList::iterator pit, lyx::pos_type pos);
|
||||||
/// returns true if par was empty and was removed
|
/// returns true if par was empty and was removed
|
||||||
bool setCursor(ParagraphList::iterator pit,
|
bool setCursor(lyx::paroffset_type par,
|
||||||
lyx::pos_type pos,
|
lyx::pos_type pos,
|
||||||
bool setfont = true,
|
bool setfont = true,
|
||||||
bool boundary = false);
|
bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCursor(LyXCursor &, ParagraphList::iterator pit,
|
void setCursor(LyXCursor &, lyx::paroffset_type par,
|
||||||
lyx::pos_type pos,
|
lyx::pos_type pos,
|
||||||
bool boundary = false);
|
bool boundary = false);
|
||||||
///
|
///
|
||||||
void setCursorIntern(ParagraphList::iterator pit,
|
void setCursorIntern(lyx::paroffset_type par,
|
||||||
lyx::pos_type pos,
|
lyx::pos_type pos,
|
||||||
bool setfont = true,
|
bool setfont = true,
|
||||||
bool boundary = false);
|
bool boundary = false);
|
||||||
@ -494,6 +504,9 @@ public:
|
|||||||
void previousRow(ParagraphList::iterator & pit,
|
void previousRow(ParagraphList::iterator & pit,
|
||||||
RowList::iterator & rit) const;
|
RowList::iterator & rit) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
std::string selectionAsString(Buffer const & buffer, bool label) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Cursor related data.
|
/** Cursor related data.
|
||||||
Later this variable has to be removed. There should be now internal
|
Later this variable has to be removed. There should be now internal
|
||||||
|
@ -16,28 +16,29 @@
|
|||||||
#ifndef LYX_TYPES_H
|
#ifndef LYX_TYPES_H
|
||||||
#define LYX_TYPES_H
|
#define LYX_TYPES_H
|
||||||
|
|
||||||
// this probably could be improved by using <cstddef>...
|
#include <cstddef>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace lyx
|
namespace lyx
|
||||||
{
|
{
|
||||||
/// a type for positions used in paragraphs
|
/// a type for positions used in paragraphs
|
||||||
// needs to be signed for a while to hold the special value -1 that is
|
// needs to be signed for a while to hold the special value -1 that is
|
||||||
// used there...
|
// used there...
|
||||||
typedef std::vector<char>::difference_type pos_type;
|
typedef ptrdiff_t pos_type;
|
||||||
|
|
||||||
|
/// a type for paragraph offsets
|
||||||
|
typedef ptrdiff_t paroffset_type;
|
||||||
|
|
||||||
/// a type for the nesting depth of a paragraph
|
/// a type for the nesting depth of a paragraph
|
||||||
typedef unsigned int depth_type;
|
typedef size_t depth_type;
|
||||||
|
|
||||||
// set this to '0' if you want to have really safe types
|
// set this to '0' if you want to have really safe types
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
/// a type for sizes
|
/// a type for sizes
|
||||||
typedef std::vector<char>::size_type size_type;
|
typedef size_t size_type;
|
||||||
|
|
||||||
/// a type used for numbering text classes
|
/// a type used for numbering text classes
|
||||||
// used to be LyXTextClassList::size_type
|
typedef size_t textclass_type;
|
||||||
typedef std::vector<char>::size_type textclass_type;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ namespace lyx
|
|||||||
|
|
||||||
struct size_type {
|
struct size_type {
|
||||||
///
|
///
|
||||||
typedef std::vector<char>::size_type base_type;
|
typedef size_t base_type;
|
||||||
///
|
///
|
||||||
size_type(base_type t) { data_ = t; }
|
size_type(base_type t) { data_ = t; }
|
||||||
///
|
///
|
||||||
@ -59,7 +60,7 @@ namespace lyx
|
|||||||
|
|
||||||
struct textclass_type {
|
struct textclass_type {
|
||||||
///
|
///
|
||||||
typedef std::vector<char>::size_type base_type;
|
typedef size_t base_type;
|
||||||
///
|
///
|
||||||
textclass_type(base_type t) { data_ = t; }
|
textclass_type(base_type t) { data_ = t; }
|
||||||
///
|
///
|
||||||
|
@ -383,9 +383,6 @@ void LyXTabular::init(BufferParams const & bp, int rows_arg, int columns_arg)
|
|||||||
|
|
||||||
void LyXTabular::fixCellNums()
|
void LyXTabular::fixCellNums()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(rows_ == row_info.size());
|
|
||||||
BOOST_ASSERT(columns_ == column_info.size());
|
|
||||||
BOOST_ASSERT(rows_ == cell_info.size());
|
|
||||||
int cellno = 0;
|
int cellno = 0;
|
||||||
for (int i = 0; i < rows_; ++i) {
|
for (int i = 0; i < rows_; ++i) {
|
||||||
for (int j = 0; j < columns_; ++j) {
|
for (int j = 0; j < columns_; ++j) {
|
||||||
@ -396,20 +393,18 @@ void LyXTabular::fixCellNums()
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_row_column_number_info();
|
set_row_column_number_info();
|
||||||
BOOST_ASSERT(rows_ == row_info.size());
|
|
||||||
BOOST_ASSERT(columns_ == column_info.size());
|
|
||||||
BOOST_ASSERT(rows_ == cell_info.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXTabular::setOwner(InsetTabular * inset)
|
void LyXTabular::setOwner(InsetTabular * inset)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rows_; ++i)
|
for (int i = 0; i < rows_; ++i) {
|
||||||
for (int j = 0; j < columns_; ++j) {
|
for (int j = 0; j < columns_; ++j) {
|
||||||
cell_info[i][j].inset.setOwner(inset);
|
cell_info[i][j].inset.setOwner(inset);
|
||||||
cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
|
cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#warning for some strange reason, cellstruct does not seem to have copy-semantics
|
#warning for some strange reason, cellstruct does not seem to have copy-semantics
|
||||||
|
293
src/text.C
293
src/text.C
@ -1192,28 +1192,28 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, RowList::iterator rit)
|
|||||||
void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
||||||
{
|
{
|
||||||
// allow only if at start or end, or all previous is new text
|
// allow only if at start or end, or all previous is new text
|
||||||
if (cursor.pos() && cursor.pos() != cursor.par()->size()
|
if (cursor.pos() && cursor.pos() != cursorPar()->size()
|
||||||
&& cursor.par()->isChangeEdited(0, cursor.pos()))
|
&& cursorPar()->isChangeEdited(0, cursor.pos()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LyXTextClass const & tclass =
|
LyXTextClass const & tclass =
|
||||||
bv()->buffer()->params().getLyXTextClass();
|
bv()->buffer()->params().getLyXTextClass();
|
||||||
LyXLayout_ptr const & layout = cursor.par()->layout();
|
LyXLayout_ptr const & layout = cursorPar()->layout();
|
||||||
|
|
||||||
// this is only allowed, if the current paragraph is not empty or caption
|
// this is only allowed, if the current paragraph is not empty or caption
|
||||||
// and if it has not the keepempty flag active
|
// and if it has not the keepempty flag active
|
||||||
if (cursor.par()->empty() && !cursor.par()->allowEmpty()
|
if (cursorPar()->empty() && !cursorPar()->allowEmpty()
|
||||||
&& layout->labeltype != LABEL_SENSITIVE)
|
&& layout->labeltype != LABEL_SENSITIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, cursor.par());
|
recordUndo(bv(), Undo::ATOMIC, cursorPar());
|
||||||
|
|
||||||
// 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 (cursor.pos() < cursor.par()->size()
|
if (cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isLineSeparator(cursor.pos()))
|
&& cursorPar()->isLineSeparator(cursor.pos()))
|
||||||
cursor.par()->erase(cursor.pos());
|
cursorPar()->erase(cursor.pos());
|
||||||
|
|
||||||
// break the paragraph
|
// break the paragraph
|
||||||
if (keep_layout)
|
if (keep_layout)
|
||||||
@ -1225,21 +1225,21 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
// breakParagraph call should return a bool if it inserts the
|
// breakParagraph call should return a bool if it inserts the
|
||||||
// paragraph before or behind and we should react on that one
|
// paragraph before or behind and we should react on that one
|
||||||
// but we can fix this in 1.3.0 (Jug 20020509)
|
// but we can fix this in 1.3.0 (Jug 20020509)
|
||||||
bool const isempty = (cursor.par()->allowEmpty() && cursor.par()->empty());
|
bool const isempty = (cursorPar()->allowEmpty() && cursorPar()->empty());
|
||||||
::breakParagraph(bv()->buffer()->params(), paragraphs, cursor.par(),
|
::breakParagraph(bv()->buffer()->params(), paragraphs, cursorPar(),
|
||||||
cursor.pos(), keep_layout);
|
cursor.pos(), keep_layout);
|
||||||
|
|
||||||
#warning Trouble Point! (Lgb)
|
#warning Trouble Point! (Lgb)
|
||||||
// When ::breakParagraph is called from within an inset we must
|
// When ::breakParagraph is called from within an inset we must
|
||||||
// ensure that the correct ParagraphList is used. Today that is not
|
// ensure that the correct ParagraphList is used. Today that is not
|
||||||
// the case and the Buffer::paragraphs is used. Not good. (Lgb)
|
// the case and the Buffer::paragraphs is used. Not good. (Lgb)
|
||||||
ParagraphList::iterator next_par = boost::next(cursor.par());
|
ParagraphList::iterator next_par = boost::next(cursorPar());
|
||||||
|
|
||||||
// well this is the caption hack since one caption is really enough
|
// well this is the caption hack since one caption is really enough
|
||||||
if (layout->labeltype == LABEL_SENSITIVE) {
|
if (layout->labeltype == LABEL_SENSITIVE) {
|
||||||
if (!cursor.pos())
|
if (!cursor.pos())
|
||||||
// set to standard-layout
|
// set to standard-layout
|
||||||
cursor.par()->applyLayout(tclass.defaultLayout());
|
cursorPar()->applyLayout(tclass.defaultLayout());
|
||||||
else
|
else
|
||||||
// set to standard-layout
|
// set to standard-layout
|
||||||
next_par->applyLayout(tclass.defaultLayout());
|
next_par->applyLayout(tclass.defaultLayout());
|
||||||
@ -1250,7 +1250,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
// This touches only the screen-update. Otherwise we would may have
|
// This touches only the screen-update. Otherwise we would may have
|
||||||
// an empty row on the screen
|
// an empty row on the screen
|
||||||
if (cursor.pos() && cursorRow()->pos() == cursor.pos()
|
if (cursor.pos() && cursorRow()->pos() == cursor.pos()
|
||||||
&& !cursor.par()->isNewline(cursor.pos() - 1))
|
&& !cursorPar()->isNewline(cursor.pos() - 1))
|
||||||
{
|
{
|
||||||
cursorLeft(bv());
|
cursorLeft(bv());
|
||||||
}
|
}
|
||||||
@ -1259,7 +1259,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
next_par->erase(0);
|
next_par->erase(0);
|
||||||
|
|
||||||
updateCounters();
|
updateCounters();
|
||||||
redoParagraph(cursor.par());
|
redoParagraph(cursorPar());
|
||||||
redoParagraph(next_par);
|
redoParagraph(next_par);
|
||||||
|
|
||||||
// This check is necessary. Otherwise the new empty paragraph will
|
// This check is necessary. Otherwise the new empty paragraph will
|
||||||
@ -1267,7 +1267,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
if (cursor.pos() || isempty)
|
if (cursor.pos() || isempty)
|
||||||
setCursor(next_par, 0);
|
setCursor(next_par, 0);
|
||||||
else
|
else
|
||||||
setCursor(cursor.par(), 0);
|
setCursor(cursorPar(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1275,7 +1275,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
|
|||||||
void LyXText::redoParagraph()
|
void LyXText::redoParagraph()
|
||||||
{
|
{
|
||||||
clearSelection();
|
clearSelection();
|
||||||
redoParagraph(cursor.par());
|
redoParagraph(cursorPar());
|
||||||
setCursorIntern(cursor.par(), cursor.pos());
|
setCursorIntern(cursor.par(), cursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,13 +1284,13 @@ void LyXText::redoParagraph()
|
|||||||
// same Paragraph one to the right and make a rebreak
|
// same Paragraph one to the right and make a rebreak
|
||||||
void LyXText::insertChar(char c)
|
void LyXText::insertChar(char c)
|
||||||
{
|
{
|
||||||
recordUndo(bv(), Undo::INSERT, cursor.par());
|
recordUndo(bv(), Undo::INSERT, cursorPar());
|
||||||
|
|
||||||
// When the free-spacing option is set for the current layout,
|
// When the free-spacing option is set for the current layout,
|
||||||
// disable the double-space checking
|
// disable the double-space checking
|
||||||
|
|
||||||
bool const freeSpacing = cursor.par()->layout()->free_spacing ||
|
bool const freeSpacing = cursorPar()->layout()->free_spacing ||
|
||||||
cursor.par()->isFreeSpacing();
|
cursorPar()->isFreeSpacing();
|
||||||
|
|
||||||
if (lyxrc.auto_number) {
|
if (lyxrc.auto_number) {
|
||||||
static string const number_operators = "+-/*";
|
static string const number_operators = "+-/*";
|
||||||
@ -1301,9 +1301,9 @@ void LyXText::insertChar(char c)
|
|||||||
if (!IsDigit(c) && !contains(number_operators, c) &&
|
if (!IsDigit(c) && !contains(number_operators, c) &&
|
||||||
!(contains(number_seperators, c) &&
|
!(contains(number_seperators, c) &&
|
||||||
cursor.pos() >= 1 &&
|
cursor.pos() >= 1 &&
|
||||||
cursor.pos() < cursor.par()->size() &&
|
cursor.pos() < cursorPar()->size() &&
|
||||||
getFont(cursor.par(), cursor.pos()).number() == LyXFont::ON &&
|
getFont(cursorPar(), cursor.pos()).number() == LyXFont::ON &&
|
||||||
getFont(cursor.par(), cursor.pos() - 1).number() == LyXFont::ON)
|
getFont(cursorPar(), cursor.pos() - 1).number() == LyXFont::ON)
|
||||||
)
|
)
|
||||||
number(bv()); // Set current_font.number to OFF
|
number(bv()); // Set current_font.number to OFF
|
||||||
} else if (IsDigit(c) &&
|
} else if (IsDigit(c) &&
|
||||||
@ -1311,23 +1311,23 @@ void LyXText::insertChar(char c)
|
|||||||
number(bv()); // Set current_font.number to ON
|
number(bv()); // Set current_font.number to ON
|
||||||
|
|
||||||
if (cursor.pos() > 0) {
|
if (cursor.pos() > 0) {
|
||||||
char const c = cursor.par()->getChar(cursor.pos() - 1);
|
char const c = cursorPar()->getChar(cursor.pos() - 1);
|
||||||
if (contains(number_unary_operators, c) &&
|
if (contains(number_unary_operators, c) &&
|
||||||
(cursor.pos() == 1 ||
|
(cursor.pos() == 1 ||
|
||||||
cursor.par()->isSeparator(cursor.pos() - 2) ||
|
cursorPar()->isSeparator(cursor.pos() - 2) ||
|
||||||
cursor.par()->isNewline(cursor.pos() - 2))
|
cursorPar()->isNewline(cursor.pos() - 2))
|
||||||
) {
|
) {
|
||||||
setCharFont(
|
setCharFont(
|
||||||
cursor.par(),
|
cursorPar(),
|
||||||
cursor.pos() - 1,
|
cursor.pos() - 1,
|
||||||
current_font);
|
current_font);
|
||||||
} else if (contains(number_seperators, c) &&
|
} else if (contains(number_seperators, c) &&
|
||||||
cursor.pos() >= 2 &&
|
cursor.pos() >= 2 &&
|
||||||
getFont(
|
getFont(
|
||||||
cursor.par(),
|
cursorPar(),
|
||||||
cursor.pos() - 2).number() == LyXFont::ON) {
|
cursor.pos() - 2).number() == LyXFont::ON) {
|
||||||
setCharFont(
|
setCharFont(
|
||||||
cursor.par(),
|
cursorPar(),
|
||||||
cursor.pos() - 1,
|
cursor.pos() - 1,
|
||||||
current_font);
|
current_font);
|
||||||
}
|
}
|
||||||
@ -1354,9 +1354,9 @@ void LyXText::insertChar(char c)
|
|||||||
|
|
||||||
if (!freeSpacing && IsLineSeparatorChar(c)) {
|
if (!freeSpacing && IsLineSeparatorChar(c)) {
|
||||||
if ((cursor.pos() > 0
|
if ((cursor.pos() > 0
|
||||||
&& cursor.par()->isLineSeparator(cursor.pos() - 1))
|
&& cursorPar()->isLineSeparator(cursor.pos() - 1))
|
||||||
|| (cursor.pos() > 0
|
|| (cursor.pos() > 0
|
||||||
&& cursor.par()->isNewline(cursor.pos() - 1))
|
&& cursorPar()->isNewline(cursor.pos() - 1))
|
||||||
|| (cursor.pos() == 0)) {
|
|| (cursor.pos() == 0)) {
|
||||||
static bool sent_space_message = false;
|
static bool sent_space_message = false;
|
||||||
if (!sent_space_message) {
|
if (!sent_space_message) {
|
||||||
@ -1373,13 +1373,13 @@ void LyXText::insertChar(char c)
|
|||||||
|
|
||||||
// Here case LyXText::InsertInset already inserted the character
|
// Here case LyXText::InsertInset already inserted the character
|
||||||
if (c != Paragraph::META_INSET)
|
if (c != Paragraph::META_INSET)
|
||||||
cursor.par()->insertChar(cursor.pos(), c);
|
cursorPar()->insertChar(cursor.pos(), c);
|
||||||
|
|
||||||
setCharFont(cursor.par(), cursor.pos(), rawtmpfont);
|
setCharFont(cursorPar(), cursor.pos(), rawtmpfont);
|
||||||
|
|
||||||
current_font = rawtmpfont;
|
current_font = rawtmpfont;
|
||||||
real_current_font = realtmpfont;
|
real_current_font = realtmpfont;
|
||||||
redoParagraph(cursor.par());
|
redoParagraph(cursorPar());
|
||||||
setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary());
|
setCursor(cursor.par(), cursor.pos() + 1, false, cursor.boundary());
|
||||||
|
|
||||||
charInserted();
|
charInserted();
|
||||||
@ -1518,8 +1518,8 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
|
|||||||
|
|
||||||
void LyXText::cursorRightOneWord()
|
void LyXText::cursorRightOneWord()
|
||||||
{
|
{
|
||||||
::cursorRightOneWord(cursor, ownerParagraphs());
|
::cursorRightOneWord(*this, cursor, ownerParagraphs());
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1528,8 +1528,8 @@ void LyXText::cursorRightOneWord()
|
|||||||
void LyXText::cursorLeftOneWord()
|
void LyXText::cursorLeftOneWord()
|
||||||
{
|
{
|
||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor tmpcursor = cursor;
|
||||||
::cursorLeftOneWord(tmpcursor, ownerParagraphs());
|
::cursorLeftOneWord(*this, tmpcursor, ownerParagraphs());
|
||||||
setCursor(tmpcursor.par(), tmpcursor.pos());
|
setCursor(getPar(tmpcursor), tmpcursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1537,7 +1537,7 @@ void LyXText::selectWord(word_location loc)
|
|||||||
{
|
{
|
||||||
LyXCursor from = cursor;
|
LyXCursor from = cursor;
|
||||||
LyXCursor to;
|
LyXCursor to;
|
||||||
::getWord(from, to, loc, ownerParagraphs());
|
::getWord(*this, from, to, loc, ownerParagraphs());
|
||||||
if (cursor != from)
|
if (cursor != from)
|
||||||
setCursor(from.par(), from.pos());
|
setCursor(from.par(), from.pos());
|
||||||
if (to == from)
|
if (to == from)
|
||||||
@ -1562,17 +1562,17 @@ bool LyXText::selectWordWhenUnderCursor(word_location loc)
|
|||||||
|
|
||||||
void LyXText::acceptChange()
|
void LyXText::acceptChange()
|
||||||
{
|
{
|
||||||
if (!selection.set() && cursor.par()->size())
|
if (!selection.set() && cursorPar()->size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (selection.start.par() == selection.end.par()) {
|
if (selection.start.par() == selection.end.par()) {
|
||||||
LyXCursor & startc = selection.start;
|
LyXCursor & startc = selection.start;
|
||||||
LyXCursor & endc = selection.end;
|
LyXCursor & endc = selection.end;
|
||||||
recordUndo(bv(), Undo::INSERT, startc.par());
|
recordUndo(bv(), Undo::INSERT, getPar(startc));
|
||||||
startc.par()->acceptChange(startc.pos(), endc.pos());
|
getPar(startc)->acceptChange(startc.pos(), endc.pos());
|
||||||
finishUndo();
|
finishUndo();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
redoParagraph(startc.par());
|
redoParagraph(getPar(startc));
|
||||||
setCursorIntern(startc.par(), 0);
|
setCursorIntern(startc.par(), 0);
|
||||||
}
|
}
|
||||||
#warning handle multi par selection
|
#warning handle multi par selection
|
||||||
@ -1581,17 +1581,17 @@ void LyXText::acceptChange()
|
|||||||
|
|
||||||
void LyXText::rejectChange()
|
void LyXText::rejectChange()
|
||||||
{
|
{
|
||||||
if (!selection.set() && cursor.par()->size())
|
if (!selection.set() && cursorPar()->size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (selection.start.par() == selection.end.par()) {
|
if (selection.start.par() == selection.end.par()) {
|
||||||
LyXCursor & startc = selection.start;
|
LyXCursor & startc = selection.start;
|
||||||
LyXCursor & endc = selection.end;
|
LyXCursor & endc = selection.end;
|
||||||
recordUndo(bv(), Undo::INSERT, startc.par());
|
recordUndo(bv(), Undo::INSERT, getPar(startc));
|
||||||
startc.par()->rejectChange(startc.pos(), endc.pos());
|
getPar(startc)->rejectChange(startc.pos(), endc.pos());
|
||||||
finishUndo();
|
finishUndo();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
redoParagraph(startc.par());
|
redoParagraph(getPar(startc));
|
||||||
setCursorIntern(startc.par(), 0);
|
setCursorIntern(startc.par(), 0);
|
||||||
}
|
}
|
||||||
#warning handle multi par selection
|
#warning handle multi par selection
|
||||||
@ -1600,8 +1600,7 @@ void LyXText::rejectChange()
|
|||||||
|
|
||||||
// This function is only used by the spellchecker for NextWord().
|
// This function is only used by the spellchecker for NextWord().
|
||||||
// It doesn't handle LYX_ACCENTs and probably never will.
|
// It doesn't handle LYX_ACCENTs and probably never will.
|
||||||
WordLangTuple const
|
WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value)
|
||||||
LyXText::selectNextWordToSpellcheck(float & value)
|
|
||||||
{
|
{
|
||||||
if (the_locking_inset) {
|
if (the_locking_inset) {
|
||||||
WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);
|
WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);
|
||||||
@ -1611,33 +1610,33 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
|||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
// we have to go on checking so move cursor to the next char
|
// we have to go on checking so move cursor to the next char
|
||||||
if (cursor.pos() == cursor.par()->size()) {
|
if (cursor.pos() == cursorPar()->size()) {
|
||||||
if (boost::next(cursor.par()) == ownerParagraphs().end())
|
if (cursor.par() + 1 == int(ownerParagraphs().size()))
|
||||||
return word;
|
return word;
|
||||||
cursor.par(boost::next(cursor.par()));
|
cursor.par(cursor.par() + 1);
|
||||||
cursor.pos(0);
|
cursor.pos(0);
|
||||||
} else
|
} else
|
||||||
cursor.pos(cursor.pos() + 1);
|
cursor.pos(cursor.pos() + 1);
|
||||||
}
|
}
|
||||||
ParagraphList::iterator tmppit = cursor.par();
|
int const tmppar = cursor.par();
|
||||||
|
|
||||||
// If this is not the very first word, skip rest of
|
// If this is not the very first word, skip rest of
|
||||||
// current word because we are probably in the middle
|
// current word because we are probably in the middle
|
||||||
// of a word if there is text here.
|
// of a word if there is text here.
|
||||||
if (cursor.pos() || cursor.par() != ownerParagraphs().begin()) {
|
if (cursor.pos() || cursor.par() != 0) {
|
||||||
while (cursor.pos() < cursor.par()->size()
|
while (cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isLetter(cursor.pos()))
|
&& cursorPar()->isLetter(cursor.pos()))
|
||||||
cursor.pos(cursor.pos() + 1);
|
cursor.pos(cursor.pos() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, skip until we have real text (will jump paragraphs)
|
// Now, skip until we have real text (will jump paragraphs)
|
||||||
while (true) {
|
while (true) {
|
||||||
ParagraphList::iterator cpit = cursor.par();
|
ParagraphList::iterator cpit = cursorPar();
|
||||||
pos_type const cpos(cursor.pos());
|
pos_type const cpos = cursor.pos();
|
||||||
|
|
||||||
if (cpos == cpit->size()) {
|
if (cpos == cpit->size()) {
|
||||||
if (boost::next(cpit) != ownerParagraphs().end()) {
|
if (cursor.par() + 1 != int(ownerParagraphs().size())) {
|
||||||
cursor.par(boost::next(cpit));
|
cursor.par(cursor.par() + 1);
|
||||||
cursor.pos(0);
|
cursor.pos(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1655,18 +1654,18 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now check if we hit an inset so it has to be a inset containing text!
|
// now check if we hit an inset so it has to be a inset containing text!
|
||||||
if (cursor.pos() < cursor.par()->size() &&
|
if (cursor.pos() < cursorPar()->size() &&
|
||||||
cursor.par()->isInset(cursor.pos())) {
|
cursorPar()->isInset(cursor.pos())) {
|
||||||
// lock the inset!
|
// lock the inset!
|
||||||
FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
|
FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left");
|
||||||
cursor.par()->getInset(cursor.pos())->localDispatch(cmd);
|
cursorPar()->getInset(cursor.pos())->localDispatch(cmd);
|
||||||
// now call us again to do the above trick
|
// now call us again to do the above trick
|
||||||
// but obviously we have to start from down below ;)
|
// but obviously we have to start from down below ;)
|
||||||
return bv()->text->selectNextWordToSpellcheck(value);
|
return bv()->text->selectNextWordToSpellcheck(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the value if we changed paragraphs
|
// Update the value if we changed paragraphs
|
||||||
if (cursor.par() != tmppit) {
|
if (cursor.par() != tmppar) {
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursor.par(), cursor.pos());
|
||||||
value = float(cursor.y())/float(height);
|
value = float(cursor.y())/float(height);
|
||||||
}
|
}
|
||||||
@ -1674,12 +1673,12 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
|||||||
// Start the selection from here
|
// Start the selection from here
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
|
|
||||||
string lang_code = getFont(cursor.par(), cursor.pos()).language()->code();
|
string lang_code = getFont(cursorPar(), cursor.pos()).language()->code();
|
||||||
// and find the end of the word (insets like optional hyphens
|
// and find the end of the word (insets like optional hyphens
|
||||||
// and ligature break are part of a word)
|
// and ligature break are part of a word)
|
||||||
while (cursor.pos() < cursor.par()->size()
|
while (cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isLetter(cursor.pos())
|
&& cursorPar()->isLetter(cursor.pos())
|
||||||
&& !isDeletedText(*cursor.par(), cursor.pos()))
|
&& !isDeletedText(*cursorPar(), cursor.pos()))
|
||||||
cursor.pos(cursor.pos() + 1);
|
cursor.pos(cursor.pos() + 1);
|
||||||
|
|
||||||
// Finally, we copy the word to a string and return it
|
// Finally, we copy the word to a string and return it
|
||||||
@ -1687,8 +1686,8 @@ LyXText::selectNextWordToSpellcheck(float & value)
|
|||||||
if (selection.cursor.pos() < cursor.pos()) {
|
if (selection.cursor.pos() < cursor.pos()) {
|
||||||
pos_type i;
|
pos_type i;
|
||||||
for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
|
for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
|
||||||
if (!cursor.par()->isInset(i))
|
if (!cursorPar()->isInset(i))
|
||||||
str += cursor.par()->getChar(i);
|
str += cursorPar()->getChar(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WordLangTuple(str, lang_code);
|
return WordLangTuple(str, lang_code);
|
||||||
@ -1709,11 +1708,11 @@ void LyXText::selectSelectedWord()
|
|||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
|
|
||||||
// now find the end of the word
|
// now find the end of the word
|
||||||
while (cursor.pos() < cursor.par()->size()
|
while (cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isLetter(cursor.pos()))
|
&& cursorPar()->isLetter(cursor.pos()))
|
||||||
cursor.pos(cursor.pos() + 1);
|
cursor.pos(cursor.pos() + 1);
|
||||||
|
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
|
|
||||||
// finally set the selection
|
// finally set the selection
|
||||||
setSelection();
|
setSelection();
|
||||||
@ -1723,7 +1722,7 @@ void LyXText::selectSelectedWord()
|
|||||||
// Delete from cursor up to the end of the current or next word.
|
// Delete from cursor up to the end of the current or next word.
|
||||||
void LyXText::deleteWordForward()
|
void LyXText::deleteWordForward()
|
||||||
{
|
{
|
||||||
if (cursor.par()->empty())
|
if (cursorPar()->empty())
|
||||||
cursorRight(bv());
|
cursorRight(bv());
|
||||||
else {
|
else {
|
||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor tmpcursor = cursor;
|
||||||
@ -1743,7 +1742,7 @@ void LyXText::deleteWordForward()
|
|||||||
// Delete from cursor to start of current or prior word.
|
// Delete from cursor to start of current or prior word.
|
||||||
void LyXText::deleteWordBackward()
|
void LyXText::deleteWordBackward()
|
||||||
{
|
{
|
||||||
if (cursor.par()->empty())
|
if (cursorPar()->empty())
|
||||||
cursorLeft(bv());
|
cursorLeft(bv());
|
||||||
else {
|
else {
|
||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor tmpcursor = cursor;
|
||||||
@ -1761,7 +1760,7 @@ void LyXText::deleteWordBackward()
|
|||||||
// Kill to end of line.
|
// Kill to end of line.
|
||||||
void LyXText::deleteLineForward()
|
void LyXText::deleteLineForward()
|
||||||
{
|
{
|
||||||
if (cursor.par()->empty())
|
if (cursorPar()->empty())
|
||||||
// Paragraph is empty, so we just go to the right
|
// Paragraph is empty, so we just go to the right
|
||||||
cursorRight(bv());
|
cursorRight(bv());
|
||||||
else {
|
else {
|
||||||
@ -1794,19 +1793,20 @@ void LyXText::changeCase(LyXText::TextCase action)
|
|||||||
to = selection.end;
|
to = selection.end;
|
||||||
} else {
|
} else {
|
||||||
from = cursor;
|
from = cursor;
|
||||||
::getWord(from, to, lyx::PARTIAL_WORD, ownerParagraphs());
|
::getWord(*this, from, to, lyx::PARTIAL_WORD, ownerParagraphs());
|
||||||
setCursor(to.par(), to.pos() + 1);
|
setCursor(to.par(), to.pos() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, from.par(), to.par());
|
recordUndo(bv(), Undo::ATOMIC, getPar(from), getPar(to));
|
||||||
|
|
||||||
pos_type pos = from.pos();
|
pos_type pos = from.pos();
|
||||||
ParagraphList::iterator pit = from.par();
|
int par = from.par();
|
||||||
|
|
||||||
while (pit != ownerParagraphs().end() &&
|
while (par != int(ownerParagraphs().size()) &&
|
||||||
(pos != to.pos() || pit != to.par())) {
|
(pos != to.pos() || par != to.par())) {
|
||||||
|
ParagraphList::iterator pit = getPar(par);
|
||||||
if (pos == pit->size()) {
|
if (pos == pit->size()) {
|
||||||
++pit;
|
++par;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1837,23 +1837,21 @@ void LyXText::Delete()
|
|||||||
// this is a very easy implementation
|
// this is a very easy implementation
|
||||||
|
|
||||||
LyXCursor old_cursor = cursor;
|
LyXCursor old_cursor = cursor;
|
||||||
int const old_cur_par_id = old_cursor.par()->id();
|
int const old_cur_par_id = cursorPar()->id();
|
||||||
int const old_cur_par_prev_id =
|
int const old_cur_par_prev_id =
|
||||||
(old_cursor.par() != ownerParagraphs().begin() ?
|
old_cursor.par() ? getPar(old_cursor.par() - 1)->id() : -1;
|
||||||
boost::prior(old_cursor.par())->id() : -1);
|
|
||||||
|
|
||||||
// just move to the right
|
// just move to the right
|
||||||
cursorRight(bv());
|
cursorRight(bv());
|
||||||
|
|
||||||
// CHECK Look at the comment here.
|
// CHECK Look at the comment here.
|
||||||
// This check is not very good...
|
// This check is not very good...
|
||||||
// The cursorRightIntern calls DeleteEmptyParagrapgMechanism
|
// The cursorRightIntern calls DeleteEmptyParagraphMechanism
|
||||||
// and that can very well delete the par or par->previous in
|
// and that can very well delete the par or par->previous in
|
||||||
// old_cursor. Will a solution where we compare paragraph id's
|
// old_cursor. Will a solution where we compare paragraph id's
|
||||||
//work better?
|
//work better?
|
||||||
if ((cursor.par() != ownerParagraphs().begin() ? boost::prior(cursor.par())->id() : -1)
|
int iid = cursor.par() ? getPar(cursor.par() - 1)->id() : -1;
|
||||||
== old_cur_par_prev_id
|
if (iid == old_cur_par_prev_id && cursorPar()->id() != old_cur_par_id) {
|
||||||
&& cursor.par()->id() != old_cur_par_id) {
|
|
||||||
// delete-empty-paragraph-mechanism has done it
|
// delete-empty-paragraph-mechanism has done it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1863,7 +1861,7 @@ void LyXText::Delete()
|
|||||||
LyXCursor tmpcursor = cursor;
|
LyXCursor tmpcursor = cursor;
|
||||||
// to make sure undo gets the right cursor position
|
// to make sure undo gets the right cursor position
|
||||||
cursor = old_cursor;
|
cursor = old_cursor;
|
||||||
recordUndo(bv(), Undo::DELETE, cursor.par());
|
recordUndo(bv(), Undo::DELETE, cursorPar());
|
||||||
cursor = tmpcursor;
|
cursor = tmpcursor;
|
||||||
backspace();
|
backspace();
|
||||||
}
|
}
|
||||||
@ -1873,36 +1871,36 @@ void LyXText::Delete()
|
|||||||
void LyXText::backspace()
|
void LyXText::backspace()
|
||||||
{
|
{
|
||||||
// Get the font that is used to calculate the baselineskip
|
// Get the font that is used to calculate the baselineskip
|
||||||
pos_type lastpos = cursor.par()->size();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
|
pos_type lastpos = pit->size();
|
||||||
|
|
||||||
if (cursor.pos() == 0) {
|
if (cursor.pos() == 0) {
|
||||||
// The cursor is at the beginning of a paragraph,
|
// The cursor is at the beginning of a paragraph,
|
||||||
// so the the backspace will collapse two paragraphs into one.
|
// so the the backspace will collapse two paragraphs into one.
|
||||||
|
|
||||||
// but it's not allowed unless it's new
|
// but it's not allowed unless it's new
|
||||||
if (cursor.par()->isChangeEdited(0, cursor.par()->size()))
|
if (pit->isChangeEdited(0, pit->size()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we may paste some paragraphs
|
// we may paste some paragraphs
|
||||||
|
|
||||||
// is it an empty paragraph?
|
// is it an empty paragraph?
|
||||||
|
|
||||||
if (lastpos == 0
|
if (lastpos == 0 || (lastpos == 1 && pit->isSeparator(0))) {
|
||||||
|| (lastpos == 1 && cursor.par()->isSeparator(0))) {
|
|
||||||
// This is an empty paragraph and we delete it just
|
// This is an empty paragraph and we delete it just
|
||||||
// by moving the cursor one step
|
// by moving the cursor one step
|
||||||
// left and let the DeleteEmptyParagraphMechanism
|
// left and let the DeleteEmptyParagraphMechanism
|
||||||
// handle the actual deletion of the paragraph.
|
// handle the actual deletion of the paragraph.
|
||||||
|
|
||||||
if (cursor.par() != ownerParagraphs().begin()) {
|
if (cursor.par()) {
|
||||||
ParagraphList::iterator tmppit = boost::prior(cursor.par());
|
ParagraphList::iterator tmppit = getPar(cursor.par() - 1);
|
||||||
if (cursor.par()->layout() == tmppit->layout()
|
if (cursorPar()->layout() == tmppit->layout()
|
||||||
&& cursor.par()->getAlign() == tmppit->getAlign()) {
|
&& cursorPar()->getAlign() == tmppit->getAlign()) {
|
||||||
// Inherit bottom DTD from the paragraph below.
|
// Inherit bottom DTD from the paragraph below.
|
||||||
// (the one we are deleting)
|
// (the one we are deleting)
|
||||||
tmppit->params().lineBottom(cursor.par()->params().lineBottom());
|
tmppit->params().lineBottom(cursorPar()->params().lineBottom());
|
||||||
tmppit->params().spaceBottom(cursor.par()->params().spaceBottom());
|
tmppit->params().spaceBottom(cursorPar()->params().spaceBottom());
|
||||||
tmppit->params().pagebreakBottom(cursor.par()->params().pagebreakBottom());
|
tmppit->params().pagebreakBottom(cursorPar()->params().pagebreakBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorLeft(bv());
|
cursorLeft(bv());
|
||||||
@ -1913,21 +1911,21 @@ void LyXText::backspace()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor.par() != ownerParagraphs().begin()) {
|
if (cursorPar() != ownerParagraphs().begin()) {
|
||||||
recordUndo(bv(), Undo::DELETE,
|
recordUndo(bv(), Undo::DELETE,
|
||||||
boost::prior(cursor.par()),
|
boost::prior(cursorPar()),
|
||||||
cursor.par());
|
cursorPar());
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphList::iterator tmppit = cursor.par();
|
ParagraphList::iterator tmppit = cursorPar();
|
||||||
// We used to do cursorLeftIntern() here, but it is
|
// We used to do cursorLeftIntern() here, but it is
|
||||||
// not a good idea since it triggers the auto-delete
|
// not a good idea since it triggers the auto-delete
|
||||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||||
// without the dreaded mechanism. (JMarc)
|
// without the dreaded mechanism. (JMarc)
|
||||||
if (cursor.par() != ownerParagraphs().begin()) {
|
if (cursor.par() != 0) {
|
||||||
// steps into the above paragraph.
|
// steps into the above paragraph.
|
||||||
setCursorIntern(boost::prior(cursor.par()),
|
setCursorIntern(cursor.par() - 1,
|
||||||
boost::prior(cursor.par())->size(),
|
getPar(cursor.par() - 1)->size(),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,14 +1937,14 @@ void LyXText::backspace()
|
|||||||
BufferParams const & bufparams = buf.params();
|
BufferParams const & bufparams = buf.params();
|
||||||
LyXTextClass const & tclass = bufparams.getLyXTextClass();
|
LyXTextClass const & tclass = bufparams.getLyXTextClass();
|
||||||
|
|
||||||
if (cursor.par() != tmppit
|
if (cursorPar() != tmppit
|
||||||
&& (cursor.par()->layout() == tmppit->layout()
|
&& (cursorPar()->layout() == tmppit->layout()
|
||||||
|| tmppit->layout() == tclass.defaultLayout())
|
|| tmppit->layout() == tclass.defaultLayout())
|
||||||
&& cursor.par()->getAlign() == tmppit->getAlign()) {
|
&& cursorPar()->getAlign() == tmppit->getAlign()) {
|
||||||
mergeParagraph(bufparams,
|
mergeParagraph(bufparams,
|
||||||
buf.paragraphs(), cursor.par());
|
buf.paragraphs(), cursorPar());
|
||||||
|
|
||||||
if (cursor.pos() && cursor.par()->isSeparator(cursor.pos() - 1))
|
if (cursor.pos() && cursorPar()->isSeparator(cursor.pos() - 1))
|
||||||
cursor.pos(cursor.pos() - 1);
|
cursor.pos(cursor.pos() - 1);
|
||||||
|
|
||||||
// the row may have changed, block, hfills etc.
|
// the row may have changed, block, hfills etc.
|
||||||
@ -1956,17 +1954,17 @@ void LyXText::backspace()
|
|||||||
} else {
|
} else {
|
||||||
// this is the code for a normal backspace, not pasting
|
// this is the code for a normal backspace, not pasting
|
||||||
// any paragraphs
|
// any paragraphs
|
||||||
recordUndo(bv(), Undo::DELETE, cursor.par());
|
recordUndo(bv(), Undo::DELETE, cursorPar());
|
||||||
// We used to do cursorLeftIntern() here, but it is
|
// We used to do cursorLeftIntern() here, but it is
|
||||||
// not a good idea since it triggers the auto-delete
|
// not a good idea since it triggers the auto-delete
|
||||||
// mechanism. So we do a cursorLeftIntern()-lite,
|
// mechanism. So we do a cursorLeftIntern()-lite,
|
||||||
// without the dreaded mechanism. (JMarc)
|
// without the dreaded mechanism. (JMarc)
|
||||||
setCursorIntern(cursor.par(), cursor.pos() - 1,
|
setCursorIntern(cursor.par(), cursor.pos() - 1,
|
||||||
false, cursor.boundary());
|
false, cursor.boundary());
|
||||||
cursor.par()->erase(cursor.pos());
|
cursorPar()->erase(cursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
lastpos = cursor.par()->size();
|
lastpos = cursorPar()->size();
|
||||||
if (cursor.pos() == lastpos)
|
if (cursor.pos() == lastpos)
|
||||||
setCurrentFont();
|
setCurrentFont();
|
||||||
|
|
||||||
@ -1975,15 +1973,36 @@ void LyXText::backspace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ParagraphList::iterator LyXText::cursorPar() const
|
||||||
|
{
|
||||||
|
return getPar(cursor.par());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ParagraphList::iterator LyXText::getPar(LyXCursor const & cur) const
|
||||||
|
{
|
||||||
|
return getPar(cur.par());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ParagraphList::iterator LyXText::getPar(int par) const
|
||||||
|
{
|
||||||
|
ParagraphList::iterator pit = ownerParagraphs().begin();
|
||||||
|
std::advance(pit, par);
|
||||||
|
return pit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RowList::iterator LyXText::cursorRow() const
|
RowList::iterator LyXText::cursorRow() const
|
||||||
{
|
{
|
||||||
return getRow(cursor.par(), cursor.pos());
|
return getRow(cursorPar(), cursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RowList::iterator LyXText::getRow(LyXCursor const & cur) const
|
RowList::iterator LyXText::getRow(LyXCursor const & cur) const
|
||||||
{
|
{
|
||||||
return getRow(cur.par(), cur.pos());
|
return getRow(getPar(cur), cur.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2003,7 +2022,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
|
|||||||
// returns pointer to some fancy row 'below' specified row
|
// returns pointer to some fancy row 'below' specified row
|
||||||
RowList::iterator LyXText::cursorIRow() const
|
RowList::iterator LyXText::cursorIRow() const
|
||||||
{
|
{
|
||||||
return getRow(cursor.par(), cursor.pos());
|
return getRow(cursorPar(), cursor.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2026,7 +2045,7 @@ RowList::iterator LyXText::getRowNearY(int y,
|
|||||||
|
|
||||||
int LyXText::getDepth() const
|
int LyXText::getDepth() const
|
||||||
{
|
{
|
||||||
return cursor.par()->getDepth();
|
return cursorPar()->getDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2073,3 +2092,39 @@ void LyXText::previousRow(ParagraphList::iterator & pit,
|
|||||||
rit = boost::prior(pit->rows.end());
|
rit = boost::prior(pit->rows.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string LyXText::selectionAsString(Buffer const & buffer, bool label) const
|
||||||
|
{
|
||||||
|
if (!selection.set())
|
||||||
|
return string();
|
||||||
|
|
||||||
|
// should be const ...
|
||||||
|
ParagraphList::iterator startpit = getPar(selection.start);
|
||||||
|
ParagraphList::iterator endpit = getPar(selection.end);
|
||||||
|
size_t const startpos = selection.start.pos();
|
||||||
|
size_t const endpos = selection.end.pos();
|
||||||
|
|
||||||
|
if (startpit == endpit)
|
||||||
|
return startpit->asString(buffer, startpos, endpos, label);
|
||||||
|
|
||||||
|
// First paragraph in selection
|
||||||
|
string result =
|
||||||
|
startpit->asString(buffer, startpos, startpit->size(), label) + "\n\n";
|
||||||
|
|
||||||
|
// The paragraphs in between (if any)
|
||||||
|
ParagraphList::iterator pit = startpit;
|
||||||
|
for (++pit; pit != endpit; ++pit)
|
||||||
|
result += pit->asString(buffer, 0, pit->size(), label) + "\n\n";
|
||||||
|
|
||||||
|
// Last paragraph in selection
|
||||||
|
result += endpit->asString(buffer, 0, endpos, label);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int LyXText::parOffset(ParagraphList::iterator pit) const
|
||||||
|
{
|
||||||
|
return std::distance(ownerParagraphs().begin(), pit);
|
||||||
|
}
|
||||||
|
204
src/text2.C
204
src/text2.C
@ -61,6 +61,7 @@
|
|||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
using lyx::pos_type;
|
using lyx::pos_type;
|
||||||
|
using lyx::paroffset_type;
|
||||||
using lyx::support::bformat;
|
using lyx::support::bformat;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -94,7 +95,7 @@ void LyXText::init(BufferView * bview)
|
|||||||
current_font = getFont(beg, 0);
|
current_font = getFont(beg, 0);
|
||||||
|
|
||||||
redoParagraphs(beg, end);
|
redoParagraphs(beg, end);
|
||||||
setCursorIntern(beg, 0);
|
setCursorIntern(0, 0);
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
|
|
||||||
updateCounters();
|
updateCounters();
|
||||||
@ -247,7 +248,7 @@ void LyXText::setCharFont(
|
|||||||
|
|
||||||
InsetOld * LyXText::getInset() const
|
InsetOld * LyXText::getInset() const
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
pos_type const pos = cursor.pos();
|
pos_type const pos = cursor.pos();
|
||||||
|
|
||||||
if (pos < pit->size() && pit->isInset(pos)) {
|
if (pos < pit->size() && pit->isInset(pos)) {
|
||||||
@ -313,7 +314,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
LyXCursor & send_cur,
|
LyXCursor & send_cur,
|
||||||
string const & layout)
|
string const & layout)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator endpit = boost::next(send_cur.par());
|
ParagraphList::iterator endpit = boost::next(getPar(send_cur));
|
||||||
ParagraphList::iterator undoendpit = endpit;
|
ParagraphList::iterator undoendpit = endpit;
|
||||||
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
||||||
|
|
||||||
@ -327,13 +328,13 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, sstart_cur.par(), boost::prior(undoendpit));
|
recordUndo(bv(), Undo::ATOMIC, getPar(sstart_cur), boost::prior(undoendpit));
|
||||||
|
|
||||||
// ok we have a selection. This is always between sstart_cur
|
// ok we have a selection. This is always between sstart_cur
|
||||||
// and sel_end cursor
|
// and sel_end cursor
|
||||||
cur = sstart_cur;
|
cur = sstart_cur;
|
||||||
ParagraphList::iterator pit = sstart_cur.par();
|
ParagraphList::iterator pit = getPar(sstart_cur);
|
||||||
ParagraphList::iterator epit = boost::next(send_cur.par());
|
ParagraphList::iterator epit = boost::next(getPar(send_cur));
|
||||||
|
|
||||||
BufferParams const & bufparams = bv()->buffer()->params();
|
BufferParams const & bufparams = bv()->buffer()->params();
|
||||||
LyXLayout_ptr const & lyxlayout =
|
LyXLayout_ptr const & lyxlayout =
|
||||||
@ -350,7 +351,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
: VSpace(VSpace::NONE));
|
: VSpace(VSpace::NONE));
|
||||||
if (lyxlayout->margintype == MARGIN_MANUAL)
|
if (lyxlayout->margintype == MARGIN_MANUAL)
|
||||||
pit->setLabelWidthString(lyxlayout->labelstring());
|
pit->setLabelWidthString(lyxlayout->labelstring());
|
||||||
cur.par(pit);
|
cur.par(std::distance(ownerParagraphs().begin(), pit));
|
||||||
++pit;
|
++pit;
|
||||||
} while (pit != epit);
|
} while (pit != epit);
|
||||||
|
|
||||||
@ -391,7 +392,7 @@ void LyXText::setLayout(string const & layout)
|
|||||||
|
|
||||||
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
||||||
selection.end, layout);
|
selection.end, layout);
|
||||||
redoParagraphs(selection.start.par(), endpit);
|
redoParagraphs(getPar(selection.start), endpit);
|
||||||
|
|
||||||
// we have to reset the selection, because the
|
// we have to reset the selection, because the
|
||||||
// geometry could have changed
|
// geometry could have changed
|
||||||
@ -407,13 +408,13 @@ void LyXText::setLayout(string const & layout)
|
|||||||
|
|
||||||
bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
bool LyXText::changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
ParagraphList::iterator end = cursor.par();
|
ParagraphList::iterator end = cursorPar();
|
||||||
ParagraphList::iterator start = pit;
|
ParagraphList::iterator start = pit;
|
||||||
|
|
||||||
if (selection.set()) {
|
if (selection.set()) {
|
||||||
pit = selection.start.par();
|
pit = getPar(selection.start);
|
||||||
end = selection.end.par();
|
end = getPar(selection.end);
|
||||||
start = pit;
|
start = pit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,10 +490,10 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
|||||||
if (!selection.set()) {
|
if (!selection.set()) {
|
||||||
// Determine basis font
|
// Determine basis font
|
||||||
LyXFont layoutfont;
|
LyXFont layoutfont;
|
||||||
if (cursor.pos() < cursor.par()->beginningOfBody()) {
|
if (cursor.pos() < cursorPar()->beginningOfBody()) {
|
||||||
layoutfont = getLabelFont(cursor.par());
|
layoutfont = getLabelFont(cursorPar());
|
||||||
} else {
|
} else {
|
||||||
layoutfont = getLayoutFont(cursor.par());
|
layoutfont = getLayoutFont(cursorPar());
|
||||||
}
|
}
|
||||||
// Update current font
|
// Update current font
|
||||||
real_current_font.update(font,
|
real_current_font.update(font,
|
||||||
@ -513,25 +514,24 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
|||||||
// ok we have a selection. This is always between sel_start_cursor
|
// ok we have a selection. This is always between sel_start_cursor
|
||||||
// and sel_end cursor
|
// and sel_end cursor
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, selection.start.par(), selection.end.par());
|
recordUndo(bv(), Undo::ATOMIC, getPar(selection.start), getPar(selection.end));
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cursor = selection.start;
|
cursor = selection.start;
|
||||||
while (cursor.par() != selection.end.par() ||
|
while (cursor.par() != selection.end.par() ||
|
||||||
cursor.pos() < selection.end.pos())
|
cursor.pos() < selection.end.pos())
|
||||||
{
|
{
|
||||||
if (cursor.pos() < cursor.par()->size()) {
|
if (cursor.pos() < cursorPar()->size()) {
|
||||||
// an open footnote should behave like a closed one
|
// an open footnote should behave like a closed one
|
||||||
setCharFont(cursor.par(), cursor.pos(),
|
setCharFont(cursorPar(), cursor.pos(), font, toggleall);
|
||||||
font, toggleall);
|
|
||||||
cursor.pos(cursor.pos() + 1);
|
cursor.pos(cursor.pos() + 1);
|
||||||
} else {
|
} else {
|
||||||
cursor.pos(0);
|
cursor.pos(0);
|
||||||
cursor.par(boost::next(cursor.par()));
|
cursor.par(cursor.par() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unFreezeUndo();
|
unFreezeUndo();
|
||||||
|
|
||||||
redoParagraph(selection.start.par());
|
redoParagraph(getPar(selection.start));
|
||||||
|
|
||||||
// we have to reset the selection, because the
|
// we have to reset the selection, because the
|
||||||
// geometry could have changed, but we keep
|
// geometry could have changed, but we keep
|
||||||
@ -666,13 +666,13 @@ void LyXText::clearSelection()
|
|||||||
|
|
||||||
void LyXText::cursorHome()
|
void LyXText::cursorHome()
|
||||||
{
|
{
|
||||||
setCursor(cursor.par(), cursorRow()->pos());
|
setCursor(cursorPar(), cursorRow()->pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorEnd()
|
void LyXText::cursorEnd()
|
||||||
{
|
{
|
||||||
setCursor(cursor.par(), cursorRow()->end() - 1);
|
setCursor(cursorPar(), cursorRow()->end() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -715,7 +715,7 @@ void LyXText::toggleFree(LyXFont const & font, bool toggleall)
|
|||||||
if (implicitSelection) {
|
if (implicitSelection) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
cursor = resetCursor;
|
cursor = resetCursor;
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -740,7 +740,7 @@ string LyXText::getStringToIndex()
|
|||||||
|
|
||||||
// Reset cursors to their original position.
|
// Reset cursors to their original position.
|
||||||
cursor = reset_cursor;
|
cursor = reset_cursor;
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
|
|
||||||
// Clear the implicit selection.
|
// Clear the implicit selection.
|
||||||
@ -773,7 +773,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator endpit = boost::next(selection.end.par());
|
ParagraphList::iterator endpit = boost::next(getPar(selection.end));
|
||||||
ParagraphList::iterator undoendpit = endpit;
|
ParagraphList::iterator undoendpit = endpit;
|
||||||
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
||||||
|
|
||||||
@ -787,16 +787,16 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC, selection.start.par(),
|
recordUndo(bv(), Undo::ATOMIC, getPar(selection.start),
|
||||||
boost::prior(undoendpit));
|
boost::prior(undoendpit));
|
||||||
|
|
||||||
|
|
||||||
ParagraphList::iterator tmppit = selection.end.par();
|
int tmppit = selection.end.par();
|
||||||
|
|
||||||
while (tmppit != boost::prior(selection.start.par())) {
|
while (tmppit != selection.start.par() - 1) {
|
||||||
setCursor(tmppit, 0);
|
setCursor(tmppit, 0);
|
||||||
|
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator const pit = cursorPar();
|
||||||
ParagraphParameters & params = pit->params();
|
ParagraphParameters & params = pit->params();
|
||||||
|
|
||||||
params.lineTop(line_top);
|
params.lineTop(line_top);
|
||||||
@ -819,10 +819,10 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
|
|||||||
}
|
}
|
||||||
pit->setLabelWidthString(labelwidthstring);
|
pit->setLabelWidthString(labelwidthstring);
|
||||||
params.noindent(noindent);
|
params.noindent(noindent);
|
||||||
tmppit = boost::prior(pit);
|
--tmppit;
|
||||||
}
|
}
|
||||||
|
|
||||||
redoParagraphs(selection.start.par(), endpit);
|
redoParagraphs(getPar(selection.start), endpit);
|
||||||
|
|
||||||
clearSelection();
|
clearSelection();
|
||||||
setCursor(selection.start.par(), selection.start.pos());
|
setCursor(selection.start.par(), selection.start.pos());
|
||||||
@ -1123,11 +1123,11 @@ void LyXText::updateCounters()
|
|||||||
|
|
||||||
void LyXText::insertInset(InsetOld * inset)
|
void LyXText::insertInset(InsetOld * inset)
|
||||||
{
|
{
|
||||||
if (!cursor.par()->insetAllowed(inset->lyxCode()))
|
if (!cursorPar()->insetAllowed(inset->lyxCode()))
|
||||||
return;
|
return;
|
||||||
recordUndo(bv(), Undo::ATOMIC, cursor.par());
|
recordUndo(bv(), Undo::ATOMIC, cursorPar());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cursor.par()->insertInset(cursor.pos(), inset);
|
cursorPar()->insertInset(cursor.pos(), inset);
|
||||||
// Just to rebreak and refresh correctly.
|
// Just to rebreak and refresh correctly.
|
||||||
// The character will not be inserted a second time
|
// The character will not be inserted a second time
|
||||||
insertChar(Paragraph::META_INSET);
|
insertChar(Paragraph::META_INSET);
|
||||||
@ -1161,7 +1161,7 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
|||||||
// and selection.end
|
// and selection.end
|
||||||
|
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator endpit = boost::next(selection.end.par());
|
ParagraphList::iterator endpit = getPar(selection.end.par() + 1);
|
||||||
ParagraphList::iterator undoendpit = endpit;
|
ParagraphList::iterator undoendpit = endpit;
|
||||||
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
ParagraphList::iterator pars_end = ownerParagraphs().end();
|
||||||
|
|
||||||
@ -1175,40 +1175,40 @@ void LyXText::cutSelection(bool doclear, bool realcut)
|
|||||||
++endpit;
|
++endpit;
|
||||||
}
|
}
|
||||||
|
|
||||||
recordUndo(bv(), Undo::DELETE, selection.start.par(),
|
recordUndo(bv(), Undo::DELETE, getPar(selection.start),
|
||||||
boost::prior(undoendpit));
|
boost::prior(undoendpit));
|
||||||
|
|
||||||
endpit = selection.end.par();
|
endpit = getPar(selection.end.par());
|
||||||
int endpos = selection.end.pos();
|
int endpos = selection.end.pos();
|
||||||
|
|
||||||
BufferParams const & bufparams = bv()->buffer()->params();
|
BufferParams const & bufparams = bv()->buffer()->params();
|
||||||
boost::tie(endpit, endpos) = realcut ?
|
boost::tie(endpit, endpos) = realcut ?
|
||||||
CutAndPaste::cutSelection(bufparams,
|
CutAndPaste::cutSelection(bufparams,
|
||||||
ownerParagraphs(),
|
ownerParagraphs(),
|
||||||
selection.start.par(), endpit,
|
getPar(selection.start.par()), endpit,
|
||||||
selection.start.pos(), endpos,
|
selection.start.pos(), endpos,
|
||||||
bufparams.textclass,
|
bufparams.textclass,
|
||||||
doclear)
|
doclear)
|
||||||
: CutAndPaste::eraseSelection(bufparams,
|
: CutAndPaste::eraseSelection(bufparams,
|
||||||
ownerParagraphs(),
|
ownerParagraphs(),
|
||||||
selection.start.par(), endpit,
|
getPar(selection.start.par()), endpit,
|
||||||
selection.start.pos(), endpos,
|
selection.start.pos(), endpos,
|
||||||
doclear);
|
doclear);
|
||||||
// sometimes necessary
|
// sometimes necessary
|
||||||
if (doclear)
|
if (doclear)
|
||||||
selection.start.par()->stripLeadingSpaces();
|
getPar(selection.start.par())->stripLeadingSpaces();
|
||||||
|
|
||||||
redoParagraphs(selection.start.par(), boost::next(endpit));
|
redoParagraphs(getPar(selection.start.par()), boost::next(endpit));
|
||||||
// cutSelection can invalidate the cursor so we need to set
|
// cutSelection can invalidate the cursor so we need to set
|
||||||
// it anew. (Lgb)
|
// it anew. (Lgb)
|
||||||
// we prefer the end for when tracking changes
|
// we prefer the end for when tracking changes
|
||||||
cursor.pos(endpos);
|
cursor.pos(endpos);
|
||||||
cursor.par(endpit);
|
cursor.par(parOffset(endpit));
|
||||||
|
|
||||||
// need a valid cursor. (Lgb)
|
// need a valid cursor. (Lgb)
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
updateCounters();
|
updateCounters();
|
||||||
}
|
}
|
||||||
@ -1227,14 +1227,14 @@ void LyXText::copySelection()
|
|||||||
// and sel_end cursor
|
// and sel_end cursor
|
||||||
|
|
||||||
// copy behind a space if there is one
|
// copy behind a space if there is one
|
||||||
while (selection.start.par()->size() > selection.start.pos()
|
while (getPar(selection.start)->size() > selection.start.pos()
|
||||||
&& selection.start.par()->isLineSeparator(selection.start.pos())
|
&& getPar(selection.start)->isLineSeparator(selection.start.pos())
|
||||||
&& (selection.start.par() != selection.end.par()
|
&& (selection.start.par() != selection.end.par()
|
||||||
|| selection.start.pos() < selection.end.pos()))
|
|| selection.start.pos() < selection.end.pos()))
|
||||||
selection.start.pos(selection.start.pos() + 1);
|
selection.start.pos(selection.start.pos() + 1);
|
||||||
|
|
||||||
CutAndPaste::copySelection(selection.start.par(),
|
CutAndPaste::copySelection(getPar(selection.start.par()),
|
||||||
selection.end.par(),
|
getPar(selection.end.par()),
|
||||||
selection.start.pos(), selection.end.pos(),
|
selection.start.pos(), selection.end.pos(),
|
||||||
bv()->buffer()->params().textclass);
|
bv()->buffer()->params().textclass);
|
||||||
}
|
}
|
||||||
@ -1246,7 +1246,7 @@ void LyXText::pasteSelection(size_t sel_index)
|
|||||||
if (!CutAndPaste::checkPastePossible())
|
if (!CutAndPaste::checkPastePossible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::INSERT, cursor.par());
|
recordUndo(bv(), Undo::INSERT, cursorPar());
|
||||||
|
|
||||||
ParagraphList::iterator endpit;
|
ParagraphList::iterator endpit;
|
||||||
PitPosPair ppp;
|
PitPosPair ppp;
|
||||||
@ -1256,13 +1256,13 @@ void LyXText::pasteSelection(size_t sel_index)
|
|||||||
boost::tie(ppp, endpit) =
|
boost::tie(ppp, endpit) =
|
||||||
CutAndPaste::pasteSelection(*bv()->buffer(),
|
CutAndPaste::pasteSelection(*bv()->buffer(),
|
||||||
ownerParagraphs(),
|
ownerParagraphs(),
|
||||||
cursor.par(), cursor.pos(),
|
cursorPar(), cursor.pos(),
|
||||||
bv()->buffer()->params().textclass,
|
bv()->buffer()->params().textclass,
|
||||||
sel_index, el);
|
sel_index, el);
|
||||||
bufferErrors(*bv()->buffer(), el);
|
bufferErrors(*bv()->buffer(), el);
|
||||||
bv()->showErrorList(_("Paste"));
|
bv()->showErrorList(_("Paste"));
|
||||||
|
|
||||||
redoParagraphs(cursor.par(), endpit);
|
redoParagraphs(cursorPar(), endpit);
|
||||||
|
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursor.par(), cursor.pos());
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@ -1299,7 +1299,7 @@ void LyXText::replaceSelectionWithString(string const & str)
|
|||||||
|
|
||||||
// Get font setting before we cut
|
// Get font setting before we cut
|
||||||
pos_type pos = selection.end.pos();
|
pos_type pos = selection.end.pos();
|
||||||
LyXFont const font = selection.start.par()
|
LyXFont const font = getPar(selection.start)
|
||||||
->getFontSettings(bv()->buffer()->params(),
|
->getFontSettings(bv()->buffer()->params(),
|
||||||
selection.start.pos());
|
selection.start.pos());
|
||||||
|
|
||||||
@ -1307,7 +1307,7 @@ void LyXText::replaceSelectionWithString(string const & str)
|
|||||||
string::const_iterator cit = str.begin();
|
string::const_iterator cit = str.begin();
|
||||||
string::const_iterator end = str.end();
|
string::const_iterator end = str.end();
|
||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit) {
|
||||||
selection.end.par()->insertChar(pos, (*cit), font);
|
getPar(selection.end)->insertChar(pos, (*cit), font);
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1321,9 +1321,9 @@ void LyXText::replaceSelectionWithString(string const & str)
|
|||||||
// needed to insert the selection
|
// needed to insert the selection
|
||||||
void LyXText::insertStringAsLines(string const & str)
|
void LyXText::insertStringAsLines(string const & str)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
pos_type pos = cursor.pos();
|
pos_type pos = cursor.pos();
|
||||||
ParagraphList::iterator endpit = boost::next(cursor.par());
|
ParagraphList::iterator endpit = boost::next(cursorPar());
|
||||||
|
|
||||||
recordUndo(bv(), Undo::ATOMIC);
|
recordUndo(bv(), Undo::ATOMIC);
|
||||||
|
|
||||||
@ -1332,8 +1332,8 @@ void LyXText::insertStringAsLines(string const & str)
|
|||||||
|
|
||||||
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
|
bv()->buffer()->insertStringAsLines(pit, pos, current_font, str);
|
||||||
|
|
||||||
redoParagraphs(cursor.par(), endpit);
|
redoParagraphs(cursorPar(), endpit);
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
setCursor(pit, pos);
|
setCursor(pit, pos);
|
||||||
setSelection();
|
setSelection();
|
||||||
@ -1368,12 +1368,16 @@ void LyXText::insertStringAsParagraphs(string const & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LyXText::setCursor(ParagraphList::iterator pit,
|
void LyXText::setCursor(ParagraphList::iterator pit, pos_type pos)
|
||||||
pos_type pos,
|
{
|
||||||
bool setfont, bool boundary)
|
setCursor(parOffset(pit), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LyXText::setCursor(paroffset_type par, pos_type pos, bool setfont, bool boundary)
|
||||||
{
|
{
|
||||||
LyXCursor old_cursor = cursor;
|
LyXCursor old_cursor = cursor;
|
||||||
setCursorIntern(pit, pos, setfont, boundary);
|
setCursorIntern(par, pos, setfont, boundary);
|
||||||
return deleteEmptyParagraphMechanism(old_cursor);
|
return deleteEmptyParagraphMechanism(old_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,12 +1389,12 @@ void LyXText::redoCursor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
|
||||||
pos_type pos, bool boundary)
|
pos_type pos, bool boundary)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pit != ownerParagraphs().end());
|
BOOST_ASSERT(par != int(ownerParagraphs().size()));
|
||||||
|
|
||||||
cur.par(pit);
|
cur.par(par);
|
||||||
cur.pos(pos);
|
cur.pos(pos);
|
||||||
cur.boundary(boundary);
|
cur.boundary(boundary);
|
||||||
|
|
||||||
@ -1400,6 +1404,7 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
|
|||||||
|
|
||||||
// get the cursor y position in text
|
// get the cursor y position in text
|
||||||
|
|
||||||
|
ParagraphList::iterator pit = getPar(par);
|
||||||
RowList::iterator row = getRow(pit, pos);
|
RowList::iterator row = getRow(pit, pos);
|
||||||
int y = row->y();
|
int y = row->y();
|
||||||
|
|
||||||
@ -1489,10 +1494,10 @@ float LyXText::getCursorX(ParagraphList::iterator pit, RowList::iterator rit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCursorIntern(ParagraphList::iterator pit,
|
void LyXText::setCursorIntern(paroffset_type par,
|
||||||
pos_type pos, bool setfont, bool boundary)
|
pos_type pos, bool setfont, bool boundary)
|
||||||
{
|
{
|
||||||
setCursor(cursor, pit, pos, boundary);
|
setCursor(cursor, par, pos, boundary);
|
||||||
if (setfont)
|
if (setfont)
|
||||||
setCurrentFont();
|
setCurrentFont();
|
||||||
}
|
}
|
||||||
@ -1501,7 +1506,7 @@ void LyXText::setCursorIntern(ParagraphList::iterator pit,
|
|||||||
void LyXText::setCurrentFont()
|
void LyXText::setCurrentFont()
|
||||||
{
|
{
|
||||||
pos_type pos = cursor.pos();
|
pos_type pos = cursor.pos();
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
|
|
||||||
if (cursor.boundary() && pos > 0)
|
if (cursor.boundary() && pos > 0)
|
||||||
--pos;
|
--pos;
|
||||||
@ -1662,7 +1667,7 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
|
|||||||
|
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
pos_type const column = getColumnNearX(pit, rit, x, bound);
|
pos_type const column = getColumnNearX(pit, rit, x, bound);
|
||||||
cur.par(pit);
|
cur.par(parOffset(pit));
|
||||||
cur.pos(rit->pos() + column);
|
cur.pos(rit->pos() + column);
|
||||||
cur.x(x);
|
cur.x(x);
|
||||||
cur.y(y + rit->baseline());
|
cur.y(y + rit->baseline());
|
||||||
@ -1677,31 +1682,30 @@ void LyXText::cursorLeft(bool internal)
|
|||||||
bool boundary = cursor.boundary();
|
bool boundary = cursor.boundary();
|
||||||
setCursor(cursor.par(), cursor.pos() - 1, true, false);
|
setCursor(cursor.par(), cursor.pos() - 1, true, false);
|
||||||
if (!internal && !boundary &&
|
if (!internal && !boundary &&
|
||||||
isBoundary(*bv()->buffer(), *cursor.par(), cursor.pos() + 1))
|
isBoundary(*bv()->buffer(), *cursorPar(), cursor.pos() + 1))
|
||||||
setCursor(cursor.par(), cursor.pos() + 1, true, true);
|
setCursor(cursor.par(), cursor.pos() + 1, true, true);
|
||||||
} else if (cursor.par() != ownerParagraphs().begin()) {
|
} else if (cursor.par() != 0) {
|
||||||
// steps into the paragraph above
|
// steps into the paragraph above
|
||||||
ParagraphList::iterator pit = boost::prior(cursor.par());
|
setCursor(cursor.par() - 1, boost::prior(cursorPar())->size());
|
||||||
setCursor(pit, pit->size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorRight(bool internal)
|
void LyXText::cursorRight(bool internal)
|
||||||
{
|
{
|
||||||
bool const at_end = (cursor.pos() == cursor.par()->size());
|
bool const at_end = (cursor.pos() == cursorPar()->size());
|
||||||
bool const at_newline = !at_end &&
|
bool const at_newline = !at_end &&
|
||||||
cursor.par()->isNewline(cursor.pos());
|
cursorPar()->isNewline(cursor.pos());
|
||||||
|
|
||||||
if (!internal && cursor.boundary() && !at_newline)
|
if (!internal && cursor.boundary() && !at_newline)
|
||||||
setCursor(cursor.par(), cursor.pos(), true, false);
|
setCursor(cursor.par(), cursor.pos(), true, false);
|
||||||
else if (!at_end) {
|
else if (!at_end) {
|
||||||
setCursor(cursor.par(), cursor.pos() + 1, true, false);
|
setCursor(cursor.par(), cursor.pos() + 1, true, false);
|
||||||
if (!internal &&
|
if (!internal &&
|
||||||
isBoundary(*bv()->buffer(), *cursor.par(), cursor.pos()))
|
isBoundary(*bv()->buffer(), *cursorPar(), cursor.pos()))
|
||||||
setCursor(cursor.par(), cursor.pos(), true, true);
|
setCursor(cursor.par(), cursor.pos(), true, true);
|
||||||
} else if (boost::next(cursor.par()) != ownerParagraphs().end())
|
} else if (cursor.par() + 1 != int(ownerParagraphs().size()))
|
||||||
setCursor(boost::next(cursor.par()), 0);
|
setCursor(cursor.par() + 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1758,15 +1762,15 @@ void LyXText::cursorDown(bool selecting)
|
|||||||
void LyXText::cursorUpParagraph()
|
void LyXText::cursorUpParagraph()
|
||||||
{
|
{
|
||||||
if (cursor.pos() > 0)
|
if (cursor.pos() > 0)
|
||||||
setCursor(cursor.par(), 0);
|
setCursor(cursorPar(), 0);
|
||||||
else if (cursor.par() != ownerParagraphs().begin())
|
else if (cursorPar() != ownerParagraphs().begin())
|
||||||
setCursor(boost::prior(cursor.par()), 0);
|
setCursor(boost::prior(cursorPar()), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::cursorDownParagraph()
|
void LyXText::cursorDownParagraph()
|
||||||
{
|
{
|
||||||
ParagraphList::iterator par = cursor.par();
|
ParagraphList::iterator par = cursorPar();
|
||||||
ParagraphList::iterator next_par = boost::next(par);
|
ParagraphList::iterator next_par = boost::next(par);
|
||||||
|
|
||||||
if (next_par != ownerParagraphs().end())
|
if (next_par != ownerParagraphs().end())
|
||||||
@ -1792,8 +1796,8 @@ void LyXText::fixCursorAfterDelete(LyXCursor & cur, LyXCursor const & where)
|
|||||||
|
|
||||||
// check also if we don't want to set the cursor on a spot behind the
|
// check also if we don't want to set the cursor on a spot behind the
|
||||||
// pagragraph because we erased the last character.
|
// pagragraph because we erased the last character.
|
||||||
if (cur.pos() > cur.par()->size())
|
if (cur.pos() > getPar(cur)->size())
|
||||||
cur.pos(cur.par()->size());
|
cur.pos(getPar(cur)->size());
|
||||||
|
|
||||||
// recompute row et al. for this cursor
|
// recompute row et al. for this cursor
|
||||||
setCursor(cur, cur.par(), cur.pos(), cur.boundary());
|
setCursor(cur, cur.par(), cur.pos(), cur.boundary());
|
||||||
@ -1807,7 +1811,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
||||||
if (old_cursor.par()->isFreeSpacing())
|
if (getPar(old_cursor)->isFreeSpacing())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Ok I'll put some comments here about what is missing.
|
/* Ok I'll put some comments here about what is missing.
|
||||||
@ -1834,16 +1838,17 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
// MISSING
|
// MISSING
|
||||||
|
|
||||||
// If the pos around the old_cursor were spaces, delete one of them.
|
// If the pos around the old_cursor were spaces, delete one of them.
|
||||||
|
ParagraphList::iterator const old_pit = getPar(old_cursor);
|
||||||
if (old_cursor.par() != cursor.par()
|
if (old_cursor.par() != cursor.par()
|
||||||
|| old_cursor.pos() != cursor.pos()) {
|
|| old_cursor.pos() != cursor.pos()) {
|
||||||
|
|
||||||
// Only if the cursor has really moved
|
// Only if the cursor has really moved
|
||||||
if (old_cursor.pos() > 0
|
if (old_cursor.pos() > 0
|
||||||
&& old_cursor.pos() < old_cursor.par()->size()
|
&& old_cursor.pos() < old_pit->size()
|
||||||
&& old_cursor.par()->isLineSeparator(old_cursor.pos())
|
&& old_pit->isLineSeparator(old_cursor.pos())
|
||||||
&& old_cursor.par()->isLineSeparator(old_cursor.pos() - 1)) {
|
&& old_pit->isLineSeparator(old_cursor.pos() - 1)) {
|
||||||
bool erased = old_cursor.par()->erase(old_cursor.pos() - 1);
|
bool erased = old_pit->erase(old_cursor.pos() - 1);
|
||||||
redoParagraph(old_cursor.par());
|
redoParagraph(old_pit);
|
||||||
|
|
||||||
if (!erased)
|
if (!erased)
|
||||||
return false;
|
return false;
|
||||||
@ -1867,7 +1872,7 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Do not delete empty paragraphs with keepempty set.
|
// Do not delete empty paragraphs with keepempty set.
|
||||||
if (old_cursor.par()->allowEmpty())
|
if (old_pit->allowEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// only do our magic if we changed paragraph
|
// only do our magic if we changed paragraph
|
||||||
@ -1878,30 +1883,29 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
// we can't possibly have deleted a paragraph before this point
|
// we can't possibly have deleted a paragraph before this point
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
|
|
||||||
if (old_cursor.par()->empty() ||
|
if (old_pit->empty() ||
|
||||||
(old_cursor.par()->size() == 1 &&
|
(old_pit->size() == 1 && old_pit->isLineSeparator(0))) {
|
||||||
old_cursor.par()->isLineSeparator(0))) {
|
|
||||||
// ok, we will delete something
|
// ok, we will delete something
|
||||||
LyXCursor tmpcursor;
|
LyXCursor tmpcursor;
|
||||||
|
|
||||||
deleted = true;
|
deleted = true;
|
||||||
|
|
||||||
bool selection_position_was_oldcursor_position = (
|
bool selection_position_was_oldcursor_position =
|
||||||
selection.cursor.par() == old_cursor.par()
|
selection.cursor.par() == old_cursor.par()
|
||||||
&& selection.cursor.pos() == old_cursor.pos());
|
&& selection.cursor.pos() == old_cursor.pos();
|
||||||
|
|
||||||
tmpcursor = cursor;
|
tmpcursor = cursor;
|
||||||
cursor = old_cursor; // that undo can restore the right cursor position
|
cursor = old_cursor; // that undo can restore the right cursor position
|
||||||
|
|
||||||
ParagraphList::iterator endpit = boost::next(old_cursor.par());
|
ParagraphList::iterator endpit = boost::next(old_pit);
|
||||||
while (endpit != ownerParagraphs().end() && endpit->getDepth())
|
while (endpit != ownerParagraphs().end() && endpit->getDepth())
|
||||||
++endpit;
|
++endpit;
|
||||||
|
|
||||||
recordUndo(bv(), Undo::DELETE, old_cursor.par(), boost::prior(endpit));
|
recordUndo(bv(), Undo::DELETE, old_pit, boost::prior(endpit));
|
||||||
cursor = tmpcursor;
|
cursor = tmpcursor;
|
||||||
|
|
||||||
// delete old par
|
// delete old par
|
||||||
ownerParagraphs().erase(old_cursor.par());
|
ownerParagraphs().erase(old_pit);
|
||||||
redoParagraph();
|
redoParagraph();
|
||||||
|
|
||||||
// correct cursor y
|
// correct cursor y
|
||||||
@ -1913,8 +1917,8 @@ bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!deleted) {
|
if (!deleted) {
|
||||||
if (old_cursor.par()->stripLeadingSpaces()) {
|
if (old_pit->stripLeadingSpaces()) {
|
||||||
redoParagraph(old_cursor.par());
|
redoParagraph(old_pit);
|
||||||
// correct cursor y
|
// correct cursor y
|
||||||
setCursorIntern(cursor.par(), cursor.pos());
|
setCursorIntern(cursor.par(), cursor.pos());
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
|
154
src/text3.C
154
src/text3.C
@ -100,11 +100,11 @@ namespace {
|
|||||||
// check if the given co-ordinates are inside an inset at the
|
// check if the given co-ordinates are inside an inset at the
|
||||||
// given cursor, if one exists. If so, the inset is returned,
|
// given cursor, if one exists. If so, the inset is returned,
|
||||||
// and the co-ordinates are made relative. Otherwise, 0 is returned.
|
// and the co-ordinates are made relative. Otherwise, 0 is returned.
|
||||||
InsetOld * checkInset(BufferView * /*bv*/, LyXText & text,
|
InsetOld * checkInset(LyXText & text,
|
||||||
LyXCursor const & cur, int & x, int & y)
|
LyXCursor const & cur, int & x, int & y)
|
||||||
{
|
{
|
||||||
lyx::pos_type const pos = cur.pos();
|
lyx::pos_type const pos = cur.pos();
|
||||||
ParagraphList::iterator par = cur.par();
|
ParagraphList::iterator par = text.getPar(cur);
|
||||||
|
|
||||||
if (pos >= par->size() || !par->isInset(pos))
|
if (pos >= par->size() || !par->isInset(pos))
|
||||||
return 0;
|
return 0;
|
||||||
@ -137,7 +137,7 @@ namespace {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
text.setCursor(par, pos, true);
|
text.setCursor(cur.par(), pos, true);
|
||||||
|
|
||||||
x -= b.x1;
|
x -= b.x1;
|
||||||
// The origin of an inset is on the baseline
|
// The origin of an inset is on the baseline
|
||||||
@ -156,7 +156,7 @@ InsetOld * LyXText::checkInsetHit(int & x, int & y)
|
|||||||
LyXCursor cur;
|
LyXCursor cur;
|
||||||
setCursorFromCoordinates(cur, x, y_tmp);
|
setCursorFromCoordinates(cur, x, y_tmp);
|
||||||
|
|
||||||
InsetOld * inset = checkInset(bv(), *this, cur, x, y_tmp);
|
InsetOld * inset = checkInset(*this, cur, x, y_tmp);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
y = y_tmp;
|
y = y_tmp;
|
||||||
return inset;
|
return inset;
|
||||||
@ -169,7 +169,7 @@ InsetOld * LyXText::checkInsetHit(int & x, int & y)
|
|||||||
// move back one
|
// move back one
|
||||||
setCursor(cur, cur.par(), cur.pos() - 1, true);
|
setCursor(cur, cur.par(), cur.pos() - 1, true);
|
||||||
|
|
||||||
inset = checkInset(bv(), *this, cur, x, y_tmp);
|
inset = checkInset(*this, cur, x, y_tmp);
|
||||||
if (inset)
|
if (inset)
|
||||||
y = y_tmp;
|
y = y_tmp;
|
||||||
return inset;
|
return inset;
|
||||||
@ -180,7 +180,7 @@ bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
|
|||||||
string const & contents)
|
string const & contents)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator end = ownerParagraphs().end();
|
ParagraphList::iterator end = ownerParagraphs().end();
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
pos_type pos = cursor.pos();
|
pos_type pos = cursor.pos();
|
||||||
|
|
||||||
InsetOld * inset;
|
InsetOld * inset;
|
||||||
@ -200,11 +200,11 @@ bool LyXText::gotoNextInset(vector<InsetOld::Code> const & codes,
|
|||||||
static_cast<InsetCommand *>(pit->getInset(pos))->getContents()
|
static_cast<InsetCommand *>(pit->getInset(pos))->getContents()
|
||||||
== contents)));
|
== contents)));
|
||||||
|
|
||||||
if (pit != end) {
|
if (pit == end)
|
||||||
setCursor(pit, pos, false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
setCursor(parOffset(pit), pos, false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,18 +214,18 @@ void LyXText::gotoInset(vector<InsetOld::Code> const & codes,
|
|||||||
bv()->beforeChange(this);
|
bv()->beforeChange(this);
|
||||||
|
|
||||||
string contents;
|
string contents;
|
||||||
if (same_content && cursor.pos() < cursor.par()->size()
|
if (same_content && cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isInset(cursor.pos())) {
|
&& cursorPar()->isInset(cursor.pos())) {
|
||||||
InsetOld const * inset = cursor.par()->getInset(cursor.pos());
|
InsetOld const * inset = cursorPar()->getInset(cursor.pos());
|
||||||
if (find(codes.begin(), codes.end(), inset->lyxCode())
|
if (find(codes.begin(), codes.end(), inset->lyxCode())
|
||||||
!= codes.end())
|
!= codes.end())
|
||||||
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
contents = static_cast<InsetCommand const *>(inset)->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gotoNextInset(codes, contents)) {
|
if (!gotoNextInset(codes, contents)) {
|
||||||
if (cursor.pos() || cursor.par() != ownerParagraphs().begin()) {
|
if (cursor.pos() || cursorPar() != ownerParagraphs().begin()) {
|
||||||
LyXCursor tmp = cursor;
|
LyXCursor tmp = cursor;
|
||||||
cursor.par(ownerParagraphs().begin());
|
cursor.par(0);
|
||||||
cursor.pos(0);
|
cursor.pos(0);
|
||||||
if (!gotoNextInset(codes, contents)) {
|
if (!gotoNextInset(codes, contents)) {
|
||||||
cursor = tmp;
|
cursor = tmp;
|
||||||
@ -284,9 +284,9 @@ void LyXText::cursorPrevious()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LyXCursor cur;
|
LyXCursor cur;
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
previousRow(pit, rit);
|
previousRow(pit, rit);
|
||||||
setCursor(cur, pit, rit->pos(), false);
|
setCursor(cur, parOffset(pit), rit->pos(), false);
|
||||||
if (cur.y() > bv_owner->top_y())
|
if (cur.y() > bv_owner->top_y())
|
||||||
cursorUp(true);
|
cursorUp(true);
|
||||||
bv()->updateScrollbar();
|
bv()->updateScrollbar();
|
||||||
@ -340,10 +340,10 @@ void LyXText::cursorNext()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
nextRow(pit, rit);
|
nextRow(pit, rit);
|
||||||
LyXCursor cur;
|
LyXCursor cur;
|
||||||
setCursor(cur, pit, rit->pos(), false);
|
setCursor(cur, parOffset(pit), rit->pos(), false);
|
||||||
if (cur.y() < bv_owner->top_y() + bv()->workHeight())
|
if (cur.y() < bv_owner->top_y() + bv()->workHeight())
|
||||||
cursorDown(true);
|
cursorDown(true);
|
||||||
bv()->updateScrollbar();
|
bv()->updateScrollbar();
|
||||||
@ -402,7 +402,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_APPENDIX: {
|
case LFUN_APPENDIX: {
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
bool start = !pit->params().startOfAppendix();
|
bool start = !pit->params().startOfAppendix();
|
||||||
|
|
||||||
// ensure that we have only one start_of_appendix in this document
|
// ensure that we have only one start_of_appendix in this document
|
||||||
@ -423,8 +423,8 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
// we can set the refreshing parameters now
|
// we can set the refreshing parameters now
|
||||||
updateCounters();
|
updateCounters();
|
||||||
redoParagraph(cursor.par());
|
redoParagraph(cursorPar());
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
bv->update();
|
bv->update();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_WORDRIGHT:
|
case LFUN_WORDRIGHT:
|
||||||
if (!selection.mark())
|
if (!selection.mark())
|
||||||
bv->beforeChange(this);
|
bv->beforeChange(this);
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorLeftOneWord();
|
cursorLeftOneWord();
|
||||||
else
|
else
|
||||||
cursorRightOneWord();
|
cursorRightOneWord();
|
||||||
@ -460,7 +460,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_WORDLEFT:
|
case LFUN_WORDLEFT:
|
||||||
if (!selection.mark())
|
if (!selection.mark())
|
||||||
bv->beforeChange(this);
|
bv->beforeChange(this);
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorRightOneWord();
|
cursorRightOneWord();
|
||||||
else
|
else
|
||||||
cursorLeftOneWord();
|
cursorLeftOneWord();
|
||||||
@ -484,7 +484,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_RIGHTSEL:
|
case LFUN_RIGHTSEL:
|
||||||
if (!selection.set())
|
if (!selection.set())
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorLeft(bv);
|
cursorLeft(bv);
|
||||||
else
|
else
|
||||||
cursorRight(bv);
|
cursorRight(bv);
|
||||||
@ -494,7 +494,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_LEFTSEL:
|
case LFUN_LEFTSEL:
|
||||||
if (!selection.set())
|
if (!selection.set())
|
||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorRight(bv);
|
cursorRight(bv);
|
||||||
else
|
else
|
||||||
cursorLeft(bv);
|
cursorLeft(bv);
|
||||||
@ -558,7 +558,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_WORDRIGHTSEL:
|
case LFUN_WORDRIGHTSEL:
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorLeftOneWord();
|
cursorLeftOneWord();
|
||||||
else
|
else
|
||||||
cursorRightOneWord();
|
cursorRightOneWord();
|
||||||
@ -566,7 +566,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_WORDLEFTSEL:
|
case LFUN_WORDLEFTSEL:
|
||||||
if (cursor.par()->isRightToLeftPar(bv->buffer()->params()))
|
if (cursorPar()->isRightToLeftPar(bv->buffer()->params()))
|
||||||
cursorRightOneWord();
|
cursorRightOneWord();
|
||||||
else
|
else
|
||||||
cursorLeftOneWord();
|
cursorLeftOneWord();
|
||||||
@ -576,7 +576,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_WORDSEL: {
|
case LFUN_WORDSEL: {
|
||||||
LyXCursor cur1 = cursor;
|
LyXCursor cur1 = cursor;
|
||||||
LyXCursor cur2;
|
LyXCursor cur2;
|
||||||
::getWord(cur1, cur2, lyx::WHOLE_WORD, ownerParagraphs());
|
::getWord(*this, cur1, cur2, lyx::WHOLE_WORD, ownerParagraphs());
|
||||||
setCursor(cur1.par(), cur1.pos());
|
setCursor(cur1.par(), cur1.pos());
|
||||||
bv->beforeChange(this);
|
bv->beforeChange(this);
|
||||||
setCursor(cur2.par(), cur2.pos());
|
setCursor(cur2.par(), cur2.pos());
|
||||||
@ -585,15 +585,15 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_RIGHT: {
|
case LFUN_RIGHT: {
|
||||||
bool is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params());
|
bool is_rtl = cursorPar()->isRightToLeftPar(bv->buffer()->params());
|
||||||
if (!selection.mark())
|
if (!selection.mark())
|
||||||
bv->beforeChange(this);
|
bv->beforeChange(this);
|
||||||
if (is_rtl)
|
if (is_rtl)
|
||||||
cursorLeft(false);
|
cursorLeft(false);
|
||||||
if (cursor.pos() < cursor.par()->size()
|
if (cursor.pos() < cursorPar()->size()
|
||||||
&& cursor.par()->isInset(cursor.pos())
|
&& cursorPar()->isInset(cursor.pos())
|
||||||
&& isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
|
&& isHighlyEditableInset(cursorPar()->getInset(cursor.pos()))) {
|
||||||
InsetOld * tmpinset = cursor.par()->getInset(cursor.pos());
|
InsetOld * tmpinset = cursorPar()->getInset(cursor.pos());
|
||||||
cmd.message(tmpinset->editMessage());
|
cmd.message(tmpinset->editMessage());
|
||||||
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left");
|
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left");
|
||||||
tmpinset->localDispatch(cmd1);
|
tmpinset->localDispatch(cmd1);
|
||||||
@ -608,17 +608,17 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_LEFT: {
|
case LFUN_LEFT: {
|
||||||
// This is soooo ugly. Isn`t it possible to make
|
// This is soooo ugly. Isn`t it possible to make
|
||||||
// it simpler? (Lgb)
|
// it simpler? (Lgb)
|
||||||
bool const is_rtl = cursor.par()->isRightToLeftPar(bv->buffer()->params());
|
bool const is_rtl = cursorPar()->isRightToLeftPar(bv->buffer()->params());
|
||||||
if (!selection.mark())
|
if (!selection.mark())
|
||||||
bv->beforeChange(this);
|
bv->beforeChange(this);
|
||||||
LyXCursor const cur = cursor;
|
LyXCursor const cur = cursor;
|
||||||
if (!is_rtl)
|
if (!is_rtl)
|
||||||
cursorLeft(false);
|
cursorLeft(false);
|
||||||
if ((is_rtl || cur != cursor) && // only if really moved!
|
if ((is_rtl || cur != cursor) && // only if really moved!
|
||||||
cursor.pos() < cursor.par()->size() &&
|
cursor.pos() < cursorPar()->size() &&
|
||||||
cursor.par()->isInset(cursor.pos()) &&
|
cursorPar()->isInset(cursor.pos()) &&
|
||||||
isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) {
|
isHighlyEditableInset(cursorPar()->getInset(cursor.pos()))) {
|
||||||
InsetOld * tmpinset = cursor.par()->getInset(cursor.pos());
|
InsetOld * tmpinset = cursorPar()->getInset(cursor.pos());
|
||||||
cmd.message(tmpinset->editMessage());
|
cmd.message(tmpinset->editMessage());
|
||||||
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right");
|
FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right");
|
||||||
tmpinset->localDispatch(cmd1);
|
tmpinset->localDispatch(cmd1);
|
||||||
@ -687,7 +687,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BREAKLINE: {
|
case LFUN_BREAKLINE: {
|
||||||
lyx::pos_type body = cursor.par()->beginningOfBody();
|
lyx::pos_type body = cursorPar()->beginningOfBody();
|
||||||
|
|
||||||
// Not allowed by LaTeX (labels or empty par)
|
// Not allowed by LaTeX (labels or empty par)
|
||||||
if (cursor.pos() <= body)
|
if (cursor.pos() <= body)
|
||||||
@ -695,7 +695,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
replaceSelection(bv->getLyXText());
|
replaceSelection(bv->getLyXText());
|
||||||
insertInset(new InsetNewline);
|
insertInset(new InsetNewline);
|
||||||
setCursor(cursor.par(), cursor.pos());
|
setCursor(cursorPar(), cursor.pos());
|
||||||
moveCursorUpdate(bv, false);
|
moveCursorUpdate(bv, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -717,22 +717,22 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
|
||||||
if (!selection.set()) {
|
if (!selection.set()) {
|
||||||
LyXCursor cur = cursor;
|
LyXCursor cur = cursor;
|
||||||
if (cur.pos() == cur.par()->size()) {
|
if (cur.pos() == getPar(cur)->size()) {
|
||||||
cursorRight(bv);
|
cursorRight(bv);
|
||||||
cur = cursor;
|
cur = cursor;
|
||||||
if (cur.pos() == 0
|
if (cur.pos() == 0
|
||||||
&& !(cur.par()->params().spaceTop()
|
&& !(getPar(cur)->params().spaceTop()
|
||||||
== VSpace (VSpace::NONE))) {
|
== VSpace (VSpace::NONE))) {
|
||||||
setParagraph(
|
setParagraph(
|
||||||
cur.par()->params().lineTop(),
|
getPar(cur)->params().lineTop(),
|
||||||
cur.par()->params().lineBottom(),
|
getPar(cur)->params().lineBottom(),
|
||||||
cur.par()->params().pagebreakTop(),
|
getPar(cur)->params().pagebreakTop(),
|
||||||
cur.par()->params().pagebreakBottom(),
|
getPar(cur)->params().pagebreakBottom(),
|
||||||
VSpace(VSpace::NONE),
|
VSpace(VSpace::NONE),
|
||||||
cur.par()->params().spaceBottom(),
|
getPar(cur)->params().spaceBottom(),
|
||||||
cur.par()->params().spacing(),
|
getPar(cur)->params().spacing(),
|
||||||
cur.par()->params().align(),
|
getPar(cur)->params().align(),
|
||||||
cur.par()->params().labelWidthString(), 0);
|
getPar(cur)->params().labelWidthString(), 0);
|
||||||
cursorLeft(bv);
|
cursorLeft(bv);
|
||||||
} else {
|
} else {
|
||||||
cursorLeft(bv);
|
cursorLeft(bv);
|
||||||
@ -771,17 +771,17 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
if (!selection.set()) {
|
if (!selection.set()) {
|
||||||
LyXCursor cur = cursor;
|
LyXCursor cur = cursor;
|
||||||
if (cur.pos() == 0
|
if (cur.pos() == 0
|
||||||
&& !(cur.par()->params().spaceTop() == VSpace(VSpace::NONE))) {
|
&& !(getPar(cur)->params().spaceTop() == VSpace(VSpace::NONE))) {
|
||||||
setParagraph(
|
setParagraph(
|
||||||
cur.par()->params().lineTop(),
|
getPar(cur)->params().lineTop(),
|
||||||
cur.par()->params().lineBottom(),
|
getPar(cur)->params().lineBottom(),
|
||||||
cur.par()->params().pagebreakTop(),
|
getPar(cur)->params().pagebreakTop(),
|
||||||
cur.par()->params().pagebreakBottom(),
|
getPar(cur)->params().pagebreakBottom(),
|
||||||
VSpace(VSpace::NONE),
|
VSpace(VSpace::NONE),
|
||||||
cur.par()->params().spaceBottom(),
|
getPar(cur)->params().spaceBottom(),
|
||||||
cur.par()->params().spacing(),
|
getPar(cur)->params().spacing(),
|
||||||
cur.par()->params().align(),
|
getPar(cur)->params().align(),
|
||||||
cur.par()->params().labelWidthString(), 0);
|
getPar(cur)->params().labelWidthString(), 0);
|
||||||
} else {
|
} else {
|
||||||
backspace();
|
backspace();
|
||||||
selection.cursor = cur;
|
selection.cursor = cur;
|
||||||
@ -817,16 +817,16 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
LyXCursor cur = cursor;
|
LyXCursor cur = cursor;
|
||||||
replaceSelection(bv->getLyXText());
|
replaceSelection(bv->getLyXText());
|
||||||
if (cur.pos() == 0) {
|
if (cur.pos() == 0) {
|
||||||
if (cur.par()->params().spaceTop() == VSpace(VSpace::NONE)) {
|
if (getPar(cur)->params().spaceTop() == VSpace(VSpace::NONE)) {
|
||||||
setParagraph(
|
setParagraph(
|
||||||
cur.par()->params().lineTop(),
|
getPar(cur)->params().lineTop(),
|
||||||
cur.par()->params().lineBottom(),
|
getPar(cur)->params().lineBottom(),
|
||||||
cur.par()->params().pagebreakTop(),
|
getPar(cur)->params().pagebreakTop(),
|
||||||
cur.par()->params().pagebreakBottom(),
|
getPar(cur)->params().pagebreakBottom(),
|
||||||
VSpace(VSpace::DEFSKIP), cur.par()->params().spaceBottom(),
|
VSpace(VSpace::DEFSKIP), getPar(cur)->params().spaceBottom(),
|
||||||
cur.par()->params().spacing(),
|
getPar(cur)->params().spacing(),
|
||||||
cur.par()->params().align(),
|
getPar(cur)->params().align(),
|
||||||
cur.par()->params().labelWidthString(), 1);
|
getPar(cur)->params().labelWidthString(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -840,7 +840,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_PARAGRAPH_SPACING: {
|
case LFUN_PARAGRAPH_SPACING: {
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
Spacing::Space cur_spacing = pit->params().spacing().getSpace();
|
Spacing::Space cur_spacing = pit->params().spacing().getSpace();
|
||||||
float cur_value = 1.0;
|
float cur_value = 1.0;
|
||||||
if (cur_spacing == Spacing::Other)
|
if (cur_spacing == Spacing::Other)
|
||||||
@ -894,7 +894,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SPACE_INSERT:
|
case LFUN_SPACE_INSERT:
|
||||||
if (cursor.par()->layout()->free_spacing)
|
if (cursorPar()->layout()->free_spacing)
|
||||||
insertChar(' ');
|
insertChar(' ');
|
||||||
else
|
else
|
||||||
doInsertInset(this, cmd, false, false);
|
doInsertInset(this, cmd, false, false);
|
||||||
@ -964,7 +964,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_TRANSPOSE_CHARS:
|
case LFUN_TRANSPOSE_CHARS:
|
||||||
recordUndo(bv, Undo::ATOMIC, cursor.par());
|
recordUndo(bv, Undo::ATOMIC, cursorPar());
|
||||||
redoParagraph();
|
redoParagraph();
|
||||||
bv->update();
|
bv->update();
|
||||||
break;
|
break;
|
||||||
@ -1038,7 +1038,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_GETLAYOUT:
|
case LFUN_GETLAYOUT:
|
||||||
cmd.message(tostr(cursor.par()->layout()));
|
cmd.message(tostr(cursorPar()->layout()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LAYOUT: {
|
case LFUN_LAYOUT: {
|
||||||
@ -1079,8 +1079,8 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
if (!change_layout && selection.set() &&
|
if (!change_layout && selection.set() &&
|
||||||
selection.start.par() != selection.end.par())
|
selection.start.par() != selection.end.par())
|
||||||
{
|
{
|
||||||
ParagraphList::iterator spit = selection.start.par();
|
ParagraphList::iterator spit = getPar(selection.start);
|
||||||
ParagraphList::iterator epit = boost::next(selection.end.par());
|
ParagraphList::iterator epit = boost::next(getPar(selection.end));
|
||||||
while (spit != epit) {
|
while (spit != epit) {
|
||||||
if (spit->layout()->name() != current_layout) {
|
if (spit->layout()->name() != current_layout) {
|
||||||
change_layout = true;
|
change_layout = true;
|
||||||
@ -1135,7 +1135,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_QUOTE: {
|
case LFUN_QUOTE: {
|
||||||
replaceSelection(bv->getLyXText());
|
replaceSelection(bv->getLyXText());
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = cursorPar();
|
||||||
lyx::pos_type pos = cursor.pos();
|
lyx::pos_type pos = cursor.pos();
|
||||||
char c;
|
char c;
|
||||||
if (!pos)
|
if (!pos)
|
||||||
@ -1217,7 +1217,7 @@ InsetOld::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
|||||||
if (bv->theLockingInset()) {
|
if (bv->theLockingInset()) {
|
||||||
InsetOld * tli = bv->theLockingInset();
|
InsetOld * tli = bv->theLockingInset();
|
||||||
LyXCursor cursor = bv->text->cursor;
|
LyXCursor cursor = bv->text->cursor;
|
||||||
LyXFont font = bv->text->getFont(cursor.par(), cursor.pos());
|
LyXFont font = bv->text->getFont(cursorPar(), cursor.pos());
|
||||||
int width = tli->width();
|
int width = tli->width();
|
||||||
int inset_x = font.isVisibleRightToLeft()
|
int inset_x = font.isVisibleRightToLeft()
|
||||||
? cursor.x() - width : cursor.x();
|
? cursor.x() - width : cursor.x();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "text_funcs.h"
|
#include "text_funcs.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "lyxcursor.h"
|
#include "lyxcursor.h"
|
||||||
|
#include "lyxtext.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
|
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
@ -27,9 +28,9 @@ using lyx::word_location;
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
bool transposeChars(LyXCursor const & cursor)
|
bool transposeChars(LyXText & text, LyXCursor const & cursor)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator tmppit = cursor.par();
|
ParagraphList::iterator tmppit = text.cursorPar();
|
||||||
pos_type tmppos = cursor.pos();
|
pos_type tmppos = cursor.pos();
|
||||||
|
|
||||||
// First decide if it is possible to transpose at all
|
// First decide if it is possible to transpose at all
|
||||||
@ -58,11 +59,12 @@ bool transposeChars(LyXCursor const & cursor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cursorLeftOneWord(LyXCursor & cursor, ParagraphList const & pars)
|
void cursorLeftOneWord(LyXText & text,
|
||||||
|
LyXCursor & cursor, ParagraphList const & pars)
|
||||||
{
|
{
|
||||||
// treat HFills, floats and Insets as words
|
// treat HFills, floats and Insets as words
|
||||||
|
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = text.cursorPar();
|
||||||
size_t pos = cursor.pos();
|
size_t pos = cursor.pos();
|
||||||
|
|
||||||
while (pos &&
|
while (pos &&
|
||||||
@ -88,15 +90,16 @@ void cursorLeftOneWord(LyXCursor & cursor, ParagraphList const & pars)
|
|||||||
--pos;
|
--pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.par(pit);
|
cursor.par(text.parOffset(pit));
|
||||||
cursor.pos(pos);
|
cursor.pos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cursorRightOneWord(LyXCursor & cursor, ParagraphList const & pars)
|
void cursorRightOneWord(LyXText & text,
|
||||||
|
LyXCursor & cursor, ParagraphList const & pars)
|
||||||
{
|
{
|
||||||
// treat floats, HFills and Insets as words
|
// treat floats, HFills and Insets as words
|
||||||
ParagraphList::iterator pit = cursor.par();
|
ParagraphList::iterator pit = text.cursorPar();
|
||||||
pos_type pos = cursor.pos();
|
pos_type pos = cursor.pos();
|
||||||
|
|
||||||
// CHECK See comment on top of text.C
|
// CHECK See comment on top of text.C
|
||||||
@ -117,25 +120,27 @@ void cursorRightOneWord(LyXCursor & cursor, ParagraphList const & pars)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.par(pit);
|
cursor.par(text.parOffset(pit));
|
||||||
cursor.pos(pos);
|
cursor.pos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Select current word. This depends on behaviour of
|
// Select current word. This depends on behaviour of
|
||||||
// CursorLeftOneWord(), so it is patched as well.
|
// CursorLeftOneWord(), so it is patched as well.
|
||||||
void getWord(LyXCursor & from, LyXCursor & to, word_location const loc,
|
void getWord(LyXText & text, LyXCursor & from, LyXCursor & to,
|
||||||
ParagraphList const & pars)
|
word_location const loc, ParagraphList const & pars)
|
||||||
{
|
{
|
||||||
|
ParagraphList::iterator from_par = text.getPar(from);
|
||||||
|
ParagraphList::iterator to_par = text.getPar(to);
|
||||||
switch (loc) {
|
switch (loc) {
|
||||||
case lyx::WHOLE_WORD_STRICT:
|
case lyx::WHOLE_WORD_STRICT:
|
||||||
if (from.pos() == 0 || from.pos() == from.par()->size()
|
if (from.pos() == 0 || from.pos() == from_par->size()
|
||||||
|| from.par()->isSeparator(from.pos())
|
|| from_par->isSeparator(from.pos())
|
||||||
|| from.par()->isKomma(from.pos())
|
|| from_par->isKomma(from.pos())
|
||||||
|| from.par()->isNewline(from.pos())
|
|| from_par->isNewline(from.pos())
|
||||||
|| from.par()->isSeparator(from.pos() - 1)
|
|| from_par->isSeparator(from.pos() - 1)
|
||||||
|| from.par()->isKomma(from.pos() - 1)
|
|| from_par->isKomma(from.pos() - 1)
|
||||||
|| from.par()->isNewline(from.pos() - 1)) {
|
|| from_par->isNewline(from.pos() - 1)) {
|
||||||
to = from;
|
to = from;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -143,14 +148,14 @@ void getWord(LyXCursor & from, LyXCursor & to, word_location const loc,
|
|||||||
|
|
||||||
case lyx::WHOLE_WORD:
|
case lyx::WHOLE_WORD:
|
||||||
// Move cursor to the beginning, when not already there.
|
// Move cursor to the beginning, when not already there.
|
||||||
if (from.pos() && !from.par()->isSeparator(from.pos() - 1)
|
if (from.pos() && !from_par->isSeparator(from.pos() - 1)
|
||||||
&& !(from.par()->isKomma(from.pos() - 1)
|
&& !(from_par->isKomma(from.pos() - 1)
|
||||||
|| from.par()->isNewline(from.pos() - 1)))
|
|| from_par->isNewline(from.pos() - 1)))
|
||||||
cursorLeftOneWord(from, pars);
|
cursorLeftOneWord(text, from, pars);
|
||||||
break;
|
break;
|
||||||
case lyx::PREVIOUS_WORD:
|
case lyx::PREVIOUS_WORD:
|
||||||
// always move the cursor to the beginning of previous word
|
// always move the cursor to the beginning of previous word
|
||||||
cursorLeftOneWord(from, pars);
|
cursorLeftOneWord(text, from, pars);
|
||||||
break;
|
break;
|
||||||
case lyx::NEXT_WORD:
|
case lyx::NEXT_WORD:
|
||||||
lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet"
|
lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet"
|
||||||
@ -160,12 +165,12 @@ void getWord(LyXCursor & from, LyXCursor & to, word_location const loc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
to = from;
|
to = from;
|
||||||
while (to.pos() < to.par()->size()
|
while (to.pos() < to_par->size()
|
||||||
&& !to.par()->isSeparator(to.pos())
|
&& !to_par->isSeparator(to.pos())
|
||||||
&& !to.par()->isKomma(to.pos())
|
&& !to_par->isKomma(to.pos())
|
||||||
&& !to.par()->isNewline(to.pos())
|
&& !to_par->isNewline(to.pos())
|
||||||
&& !to.par()->isHfill(to.pos())
|
&& !to_par->isHfill(to.pos())
|
||||||
&& !to.par()->isInset(to.pos()))
|
&& !to_par->isInset(to.pos()))
|
||||||
{
|
{
|
||||||
to.pos(to.pos() + 1);
|
to.pos(to.pos() + 1);
|
||||||
}
|
}
|
||||||
|
@ -20,21 +20,22 @@
|
|||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
class LyXCursor;
|
class LyXCursor;
|
||||||
|
class LyXText;
|
||||||
|
|
||||||
|
|
||||||
// do no use LyXText or BufferView here
|
// do no use LyXText or BufferView here
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
bool transposeChars(LyXCursor const & cursor);
|
bool transposeChars(LyXText &, LyXCursor const & cursor);
|
||||||
///
|
///
|
||||||
void cursorLeftOneWord(LyXCursor &, ParagraphList const &);
|
void cursorLeftOneWord(LyXText &, LyXCursor &, ParagraphList const &);
|
||||||
///
|
///
|
||||||
void cursorRightOneWord(LyXCursor &, ParagraphList const &);
|
void cursorRightOneWord(LyXText &, LyXCursor &, ParagraphList const &);
|
||||||
|
|
||||||
// Select current word. This depends on behaviour of
|
// Select current word. This depends on behaviour of
|
||||||
// CursorLeftOneWord(), so it is patched as well.
|
// CursorLeftOneWord(), so it is patched as well.
|
||||||
void getWord(LyXCursor & from, LyXCursor & to, lyx::word_location const loc,
|
void getWord(LyXText &, LyXCursor & from, LyXCursor & to, lyx::word_location const loc,
|
||||||
ParagraphList const & pars);
|
ParagraphList const & pars);
|
||||||
|
|
||||||
#endif // TEXT_FUNCS_H
|
#endif // TEXT_FUNCS_H
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "textcursor.h"
|
#include "textcursor.h"
|
||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
|
#include "ParagraphList_fwd.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -65,33 +66,3 @@ void TextCursor::clearSelection()
|
|||||||
selection.cursor = cursor;
|
selection.cursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const TextCursor::selectionAsString(Buffer const & buffer,
|
|
||||||
bool label) const
|
|
||||||
{
|
|
||||||
if (!selection.set())
|
|
||||||
return string();
|
|
||||||
|
|
||||||
// should be const ...
|
|
||||||
ParagraphList::iterator startpit = selection.start.par();
|
|
||||||
ParagraphList::iterator endpit = selection.end.par();
|
|
||||||
size_t const startpos = selection.start.pos();
|
|
||||||
size_t const endpos = selection.end.pos();
|
|
||||||
|
|
||||||
if (startpit == endpit)
|
|
||||||
return startpit->asString(buffer, startpos, endpos, label);
|
|
||||||
|
|
||||||
// First paragraph in selection
|
|
||||||
string result =
|
|
||||||
startpit->asString(buffer, startpos, startpit->size(), label) + "\n\n";
|
|
||||||
|
|
||||||
// The paragraphs in between (if any)
|
|
||||||
ParagraphList::iterator pit = startpit;
|
|
||||||
for (++pit; pit != endpit; ++pit)
|
|
||||||
result += pit->asString(buffer, 0, pit->size(), label) + "\n\n";
|
|
||||||
|
|
||||||
// Last paragraph in selection
|
|
||||||
result += endpit->asString(buffer, 0, endpos, label);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
|
|
||||||
#include "lyxcursor.h"
|
#include "lyxcursor.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class Buffer;
|
|
||||||
|
|
||||||
// Do not even think of forward declaring LyXText/BufferView etc here!
|
// Do not even think of forward declaring LyXText/BufferView etc here!
|
||||||
// If you need Paragraph proper, go to text_func.h
|
// If you need Paragraph proper, go to text_func.h
|
||||||
|
|
||||||
@ -69,8 +65,6 @@ struct TextCursor {
|
|||||||
void setSelection();
|
void setSelection();
|
||||||
///
|
///
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
///
|
|
||||||
std::string const selectionAsString(Buffer const & buffer, bool label) const;
|
|
||||||
|
|
||||||
// actual cursor position
|
// actual cursor position
|
||||||
LyXCursor cursor;
|
LyXCursor cursor;
|
||||||
|
@ -79,8 +79,7 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Record the cursor position in a stable way.
|
// Record the cursor position in a stable way.
|
||||||
int const cursor_offset = std::distance
|
int const cursor_offset = text->cursor.par();
|
||||||
(text->ownerParagraphs().begin(), text->cursor.par());
|
|
||||||
|
|
||||||
// Make and push the Undo entry
|
// Make and push the Undo entry
|
||||||
stack.push(Undo(kind, inset_id,
|
stack.push(Undo(kind, inset_id,
|
||||||
@ -140,9 +139,7 @@ bool performUndoOrRedo(BufferView * bv, Undo & undo)
|
|||||||
buf->getInsetFromID(undo.inset_id));
|
buf->getInsetFromID(undo.inset_id));
|
||||||
|
|
||||||
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
LyXText * text = inset ? inset->getLyXText(bv) : bv->text;
|
||||||
ParagraphList::iterator cursor = text->ownerParagraphs().begin();
|
text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
|
||||||
advance(cursor, undo.cursor_par_offset);
|
|
||||||
text->setCursorIntern(cursor, undo.cursor_pos);
|
|
||||||
|
|
||||||
if (inset) {
|
if (inset) {
|
||||||
// Magic needed to update inset internal state
|
// Magic needed to update inset internal state
|
||||||
@ -151,7 +148,7 @@ bool performUndoOrRedo(BufferView * bv, Undo & undo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set cursor again to force the position to be the right one
|
// set cursor again to force the position to be the right one
|
||||||
text->setCursorIntern(cursor, undo.cursor_pos);
|
text->setCursorIntern(undo.cursor_par_offset, undo.cursor_pos);
|
||||||
|
|
||||||
// Clear any selection and set the selection
|
// Clear any selection and set the selection
|
||||||
// cursor for any new selection.
|
// cursor for any new selection.
|
||||||
@ -268,6 +265,6 @@ void recordUndo(BufferView * bv, Undo::undo_kind kind,
|
|||||||
|
|
||||||
void recordUndo(BufferView * bv, Undo::undo_kind kind)
|
void recordUndo(BufferView * bv, Undo::undo_kind kind)
|
||||||
{
|
{
|
||||||
recordUndo(bv, kind, bv->text->cursor.par());
|
recordUndo(bv, kind, bv->text->cursorPar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user