mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
parlist-21-a.diff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7054 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a8e8e755fc
commit
4882d49f88
@ -260,9 +260,9 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
{
|
{
|
||||||
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
|
lyxerr[Debug::INFO] << "resizeCurrentBuffer" << endl;
|
||||||
|
|
||||||
Paragraph * par = 0;
|
ParagraphList::iterator par;
|
||||||
Paragraph * selstartpar = 0;
|
ParagraphList::iterator selstartpar;
|
||||||
Paragraph * selendpar = 0;
|
ParagraphList::iterator selendpar;
|
||||||
UpdatableInset * the_locking_inset = 0;
|
UpdatableInset * the_locking_inset = 0;
|
||||||
|
|
||||||
pos_type pos = 0;
|
pos_type pos = 0;
|
||||||
@ -276,11 +276,11 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
owner_->message(_("Formatting document..."));
|
owner_->message(_("Formatting document..."));
|
||||||
|
|
||||||
if (bv_->text) {
|
if (bv_->text) {
|
||||||
par = &*bv_->text->cursor.par();
|
par = bv_->text->cursor.par();
|
||||||
pos = bv_->text->cursor.pos();
|
pos = bv_->text->cursor.pos();
|
||||||
selstartpar = &*bv_->text->selection.start.par();
|
selstartpar = bv_->text->selection.start.par();
|
||||||
selstartpos = bv_->text->selection.start.pos();
|
selstartpos = bv_->text->selection.start.pos();
|
||||||
selendpar = &*bv_->text->selection.end.par();
|
selendpar = bv_->text->selection.end.par();
|
||||||
selendpos = bv_->text->selection.end.pos();
|
selendpos = bv_->text->selection.end.pos();
|
||||||
selection = bv_->text->selection.set();
|
selection = bv_->text->selection.set();
|
||||||
mark_set = bv_->text->selection.mark();
|
mark_set = bv_->text->selection.mark();
|
||||||
@ -311,9 +311,13 @@ int BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
bv_->text->init(bv_);
|
bv_->text->init(bv_);
|
||||||
//buffer_->resizeInsets(bv_);
|
//buffer_->resizeInsets(bv_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
par = bv_->text->ownerParagraphs().end();
|
||||||
|
selstartpar = bv_->text->ownerParagraphs().end();
|
||||||
|
selendpar = bv_->text->ownerParagraphs().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (par) {
|
if (par != bv_->text->ownerParagraphs().end()) {
|
||||||
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.
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
2003-05-27 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
|
* text3.C: adjust
|
||||||
|
|
||||||
|
* text2.C (cursorBottom): adjust
|
||||||
|
(setCounter): use ParagraphList::find, adjust
|
||||||
|
|
||||||
|
* text.C (workWidth): use ParagraphList::find, adjust
|
||||||
|
|
||||||
|
* lyxcursor.C (LyXCursor): adjust
|
||||||
|
|
||||||
|
* buffer.C (inset_iterator): adjust
|
||||||
|
|
||||||
|
* ParagraphList.h: make iterator(value_type) private, make
|
||||||
|
ParagraphList a friend of iterator.
|
||||||
|
|
||||||
|
* ParagraphList.C (find): new function
|
||||||
|
|
||||||
|
* BufferView_pimpl.C (resizeCurrentBuffer): adjust
|
||||||
|
|
||||||
2003-05-27 André Pönitz <poenitz@gmx.net>
|
2003-05-27 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
@ -315,4 +315,17 @@ bool ParagraphList::empty() const
|
|||||||
return parlist == 0;
|
return parlist == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ParagraphList::iterator ParagraphList::find(Paragraph const & p)
|
||||||
|
{
|
||||||
|
iterator it = begin();
|
||||||
|
iterator last = end();
|
||||||
|
for (;it != last; ++it) {
|
||||||
|
if (&*it == &p)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
///
|
///
|
||||||
class iterator {
|
class iterator {
|
||||||
public:
|
public:
|
||||||
|
friend class ParagraphList;
|
||||||
///
|
///
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
///
|
///
|
||||||
@ -39,8 +40,6 @@ public:
|
|||||||
///
|
///
|
||||||
iterator();
|
iterator();
|
||||||
///
|
///
|
||||||
iterator(value_type);
|
|
||||||
///
|
|
||||||
reference operator*();
|
reference operator*();
|
||||||
///
|
///
|
||||||
pointer operator->();
|
pointer operator->();
|
||||||
@ -53,6 +52,8 @@ public:
|
|||||||
///
|
///
|
||||||
iterator operator--(int);
|
iterator operator--(int);
|
||||||
private:
|
private:
|
||||||
|
///
|
||||||
|
iterator(value_type);
|
||||||
///
|
///
|
||||||
Paragraph * ptr;
|
Paragraph * ptr;
|
||||||
};
|
};
|
||||||
@ -98,6 +99,8 @@ public:
|
|||||||
int size() const;
|
int size() const;
|
||||||
///
|
///
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
///
|
||||||
|
iterator find(Paragraph const &);
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
Paragraph * parlist;
|
Paragraph * parlist;
|
||||||
|
@ -2383,7 +2383,7 @@ void Buffer::setParentName(string const & name)
|
|||||||
|
|
||||||
|
|
||||||
Buffer::inset_iterator::inset_iterator()
|
Buffer::inset_iterator::inset_iterator()
|
||||||
: pit(0), pend(0)
|
: pit(), pend()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2003-05-27 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
|
* insettext.C (saveLyXTextState): adjust
|
||||||
|
(restoreLyXTextState): adjust
|
||||||
|
(init): adjust
|
||||||
|
(lockInset): adjust
|
||||||
|
(unlockInsetInInset): adjust
|
||||||
|
(localDispatch): adjust
|
||||||
|
(getLyXText): adjust
|
||||||
|
|
||||||
|
* insettabular.C (insertAsciiString): adjust
|
||||||
|
|
||||||
2003-05-27 André Pönitz <poenitz@gmx.net>
|
2003-05-27 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
@ -2811,7 +2811,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
|||||||
if (cols < columns) {
|
if (cols < columns) {
|
||||||
InsetText * ti = loctab->GetCellInset(cell);
|
InsetText * ti = loctab->GetCellInset(cell);
|
||||||
LyXFont const font = ti->getLyXText(bv)->
|
LyXFont const font = ti->getLyXText(bv)->
|
||||||
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
|
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||||
ti->setText(buf.substr(op, p - op), font);
|
ti->setText(buf.substr(op, p - op), font);
|
||||||
++cols;
|
++cols;
|
||||||
++cell;
|
++cell;
|
||||||
@ -2822,7 +2822,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
|||||||
if (cols < columns) {
|
if (cols < columns) {
|
||||||
InsetText * ti = loctab->GetCellInset(cell);
|
InsetText * ti = loctab->GetCellInset(cell);
|
||||||
LyXFont const font = ti->getLyXText(bv)->
|
LyXFont const font = ti->getLyXText(bv)->
|
||||||
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
|
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||||
ti->setText(buf.substr(op, p - op), font);
|
ti->setText(buf.substr(op, p - op), font);
|
||||||
}
|
}
|
||||||
cols = ocol;
|
cols = ocol;
|
||||||
@ -2838,7 +2838,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
|
|||||||
if ((cell < cells) && (op < len)) {
|
if ((cell < cells) && (op < len)) {
|
||||||
InsetText * ti = loctab->GetCellInset(cell);
|
InsetText * ti = loctab->GetCellInset(cell);
|
||||||
LyXFont const font = ti->getLyXText(bv)->
|
LyXFont const font = ti->getLyXText(bv)->
|
||||||
getFont(bv->buffer(), &*ti->paragraphs.begin(), 0);
|
getFont(bv->buffer(), ti->paragraphs.begin(), 0);
|
||||||
ti->setText(buf.substr(op, len - op), font);
|
ti->setText(buf.substr(op, len - op), font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,31 +82,31 @@ void InsetText::saveLyXTextState(LyXText * t) const
|
|||||||
ParagraphList::iterator it = paragraphs.begin();
|
ParagraphList::iterator it = paragraphs.begin();
|
||||||
ParagraphList::iterator end = paragraphs.end();
|
ParagraphList::iterator end = paragraphs.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
if (&*it == t->cursor.par())
|
if (it == t->cursor.par())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != end && t->cursor.pos() <= it->size()) {
|
if (it != end && t->cursor.pos() <= it->size()) {
|
||||||
sstate.lpar = &*t->cursor.par();
|
sstate.lpar = t->cursor.par();
|
||||||
sstate.pos = t->cursor.pos();
|
sstate.pos = t->cursor.pos();
|
||||||
sstate.boundary = t->cursor.boundary();
|
sstate.boundary = t->cursor.boundary();
|
||||||
sstate.selstartpar = &*t->selection.start.par();
|
sstate.selstartpar = t->selection.start.par();
|
||||||
sstate.selstartpos = t->selection.start.pos();
|
sstate.selstartpos = t->selection.start.pos();
|
||||||
sstate.selstartboundary = t->selection.start.boundary();
|
sstate.selstartboundary = t->selection.start.boundary();
|
||||||
sstate.selendpar = &*t->selection.end.par();
|
sstate.selendpar = t->selection.end.par();
|
||||||
sstate.selendpos = t->selection.end.pos();
|
sstate.selendpos = t->selection.end.pos();
|
||||||
sstate.selendboundary = t->selection.end.boundary();
|
sstate.selendboundary = t->selection.end.boundary();
|
||||||
sstate.selection = t->selection.set();
|
sstate.selection = t->selection.set();
|
||||||
sstate.mark_set = t->selection.mark();
|
sstate.mark_set = t->selection.mark();
|
||||||
} else {
|
} else {
|
||||||
sstate.lpar = 0;
|
sstate.lpar = paragraphs.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::restoreLyXTextState(LyXText * t) const
|
void InsetText::restoreLyXTextState(LyXText * t) const
|
||||||
{
|
{
|
||||||
if (!sstate.lpar)
|
if (sstate.lpar == paragraphs.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t->selection.set(true);
|
t->selection.set(true);
|
||||||
@ -193,10 +193,10 @@ void InsetText::init(InsetText const * ins)
|
|||||||
drawTextXOffset = 0;
|
drawTextXOffset = 0;
|
||||||
drawTextYOffset = 0;
|
drawTextYOffset = 0;
|
||||||
locked = false;
|
locked = false;
|
||||||
old_par = 0;
|
old_par = paragraphs.end();
|
||||||
last_drawn_width = -1;
|
last_drawn_width = -1;
|
||||||
cached_bview = 0;
|
cached_bview = 0;
|
||||||
sstate.lpar = 0;
|
sstate.lpar = paragraphs.end();
|
||||||
in_insetAllowed = false;
|
in_insetAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,8 +671,8 @@ void InsetText::lockInset(BufferView * bv)
|
|||||||
the_locking_inset = 0;
|
the_locking_inset = 0;
|
||||||
inset_pos = inset_x = inset_y = 0;
|
inset_pos = inset_x = inset_y = 0;
|
||||||
inset_boundary = false;
|
inset_boundary = false;
|
||||||
inset_par = 0;
|
inset_par = paragraphs.end();
|
||||||
old_par = 0;
|
old_par = paragraphs.end();
|
||||||
bool clear = false;
|
bool clear = false;
|
||||||
if (!lt) {
|
if (!lt) {
|
||||||
lt = getLyXText(bv);
|
lt = getLyXText(bv);
|
||||||
@ -774,7 +774,7 @@ bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
|
|||||||
the_locking_inset = 0;
|
the_locking_inset = 0;
|
||||||
if (lr)
|
if (lr)
|
||||||
moveRightIntern(bv, true, false);
|
moveRightIntern(bv, true, false);
|
||||||
old_par = 0; // force layout setting
|
old_par = paragraphs.end(); // force layout setting
|
||||||
if (scroll())
|
if (scroll())
|
||||||
scroll(bv, 0.0F);
|
scroll(bv, 0.0F);
|
||||||
else
|
else
|
||||||
@ -1029,8 +1029,8 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
|||||||
the_locking_inset = 0;
|
the_locking_inset = 0;
|
||||||
inset_pos = inset_x = inset_y = 0;
|
inset_pos = inset_x = inset_y = 0;
|
||||||
inset_boundary = false;
|
inset_boundary = false;
|
||||||
inset_par = 0;
|
inset_par = paragraphs.end();
|
||||||
old_par = 0;
|
old_par = paragraphs.end();
|
||||||
|
|
||||||
bool clear = false;
|
bool clear = false;
|
||||||
if (!lt) {
|
if (!lt) {
|
||||||
@ -2204,7 +2204,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv,
|
|||||||
if (locked) {
|
if (locked) {
|
||||||
saveLyXTextState(it->second.text.get());
|
saveLyXTextState(it->second.text.get());
|
||||||
} else {
|
} else {
|
||||||
sstate.lpar = 0;
|
sstate.lpar = paragraphs.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -386,9 +386,9 @@ private:
|
|||||||
mutable boost::shared_ptr<LyXText> cached_text;
|
mutable boost::shared_ptr<LyXText> cached_text;
|
||||||
///
|
///
|
||||||
struct save_state {
|
struct save_state {
|
||||||
Paragraph * lpar;
|
ParagraphList::iterator lpar;
|
||||||
Paragraph * selstartpar;
|
ParagraphList::iterator selstartpar;
|
||||||
Paragraph * selendpar;
|
ParagraphList::iterator selendpar;
|
||||||
lyx::pos_type pos;
|
lyx::pos_type pos;
|
||||||
lyx::pos_type selstartpos;
|
lyx::pos_type selstartpos;
|
||||||
lyx::pos_type selendpos;
|
lyx::pos_type selendpos;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
LyXCursor::LyXCursor()
|
LyXCursor::LyXCursor()
|
||||||
: par_(0), pos_(0), boundary_(false),
|
: par_(), pos_(0), boundary_(false),
|
||||||
x_(0), ix_(0), x_fix_(0), y_(0), iy_(0), row_(0)
|
x_(0), ix_(0), x_fix_(0), y_(0), iy_(0), row_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -147,8 +147,8 @@ int LyXText::workWidth() const
|
|||||||
|
|
||||||
int LyXText::workWidth(Inset const * inset) const
|
int LyXText::workWidth(Inset const * inset) const
|
||||||
{
|
{
|
||||||
Paragraph * par = inset->parOwner();
|
ParagraphList::iterator par = ownerParagraphs().find(*inset->parOwner());
|
||||||
lyx::Assert(par);
|
//lyx::Assert(par);
|
||||||
|
|
||||||
pos_type pos = par->getPositionOfInset(inset);
|
pos_type pos = par->getPositionOfInset(inset);
|
||||||
lyx::Assert(pos != -1);
|
lyx::Assert(pos != -1);
|
||||||
|
12
src/text2.C
12
src/text2.C
@ -885,8 +885,14 @@ void LyXText::cursorBottom()
|
|||||||
{
|
{
|
||||||
#warning FIXME
|
#warning FIXME
|
||||||
// This is how it should be:
|
// This is how it should be:
|
||||||
// ParagraphList::iterator lastpit = boost::prior(ownerParagraphs().end());
|
#ifndef NO_STD_LIST
|
||||||
ParagraphList::iterator lastpit = &ownerParagraphs().back();
|
ParagraphList::iterator lastpit = boost::prior(ownerParagraphs().end());
|
||||||
|
#else
|
||||||
|
ParagraphList::iterator lastpit = ownerParagraphs().begin();
|
||||||
|
ParagraphList::iterator end = ownerParagraphs().end();
|
||||||
|
while (boost::next(lastpit) != end)
|
||||||
|
++lastpit;
|
||||||
|
#endif
|
||||||
int pos = lastpit->size();
|
int pos = lastpit->size();
|
||||||
setCursor(lastpit, pos);
|
setCursor(lastpit, pos);
|
||||||
}
|
}
|
||||||
@ -1191,7 +1197,7 @@ void LyXText::setCounter(Buffer const * buf, ParagraphList::iterator pit)
|
|||||||
isOK = true;
|
isOK = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
tmppit = in->parOwner();
|
tmppit = ownerParagraphs().find(*in->parOwner());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/text3.C
12
src/text3.C
@ -95,20 +95,20 @@ namespace {
|
|||||||
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();
|
||||||
Paragraph /*const*/ & par = *cur.par();
|
ParagraphList::iterator par = cur.par();
|
||||||
|
|
||||||
if (pos >= par.size() || !par.isInset(pos))
|
if (pos >= par->size() || !par->isInset(pos))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Inset /*const*/ * inset = par.getInset(pos);
|
Inset /*const*/ * inset = par->getInset(pos);
|
||||||
|
|
||||||
if (!isEditableInset(inset))
|
if (!isEditableInset(inset))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// get inset dimensions
|
// get inset dimensions
|
||||||
lyx::Assert(par.getInset(pos));
|
lyx::Assert(par->getInset(pos));
|
||||||
|
|
||||||
LyXFont const & font = text.getFont(bv->buffer(), &par, pos);
|
LyXFont const & font = text.getFont(bv->buffer(), par, pos);
|
||||||
|
|
||||||
int const width = inset->width(bv, font);
|
int const width = inset->width(bv, font);
|
||||||
int const inset_x = font.isVisibleRightToLeft()
|
int const inset_x = font.isVisibleRightToLeft()
|
||||||
@ -128,7 +128,7 @@ namespace {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
text.setCursor(&par, pos, true);
|
text.setCursor(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
|
||||||
|
Loading…
Reference in New Issue
Block a user