more ParagraphList work

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6362 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2003-03-06 10:02:40 +00:00
parent 01ecde6ab8
commit 3bee5faf12
13 changed files with 114 additions and 66 deletions

View File

@ -1315,13 +1315,13 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
beforeChange(bv_->text); beforeChange(bv_->text);
if (!lout.empty()) { if (!lout.empty()) {
update(bv_->text, BufferView::SELECT|BufferView::FITCUR); update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
bv_->text->breakParagraph(bv_); bv_->text->breakParagraph(bv_, bv_->buffer()->paragraphs);
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
if (!bv_->text->cursor.par()->empty()) { if (!bv_->text->cursor.par()->empty()) {
bv_->text->cursorLeft(bv_); bv_->text->cursorLeft(bv_);
bv_->text->breakParagraph(bv_); bv_->text->breakParagraph(bv_, bv_->buffer()->paragraphs);
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
} }

View File

@ -1,3 +1,27 @@
2003-03-06 Lars Gullik Bjønnes <larsbj@gullik.net>
* text3.C (dispatch): adjust
* text.C (breakParagraph): add a ParagraphList as arg
* paragraph_funcs.C (breakParagraph): change to take a
BufferParams and a ParagraphList as args.
(breakParagraphConservative): ditto
(mergeParagraph): ditto
(TeXDeeper): add a ParagraphList arg
(TeXEnvironment): ditto
(TeXOnePar): ditto
* buffer.C (readLyXformat2): adjust
(insertStringAsLines): adjust
(latexParagraphs): adjust
* CutAndPaste.C (cutSelection): use 'true' not '1' as truth value.
(cutSelection): adjust
(pasteSelection): adjust
* BufferView_pimpl.C (insertInset): adjust
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* commandtags.h: * commandtags.h:

View File

@ -113,7 +113,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
Paragraph * pit = startpar->next(); Paragraph * pit = startpar->next();
while (1) { while (true) {
// *endpar can be 0 // *endpar can be 0
if (!pit) if (!pit)
break; break;
@ -165,7 +165,11 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
// paste the paragraphs again, if possible // paste the paragraphs again, if possible
if (startpar->hasSameLayout(startpar->next()) || if (startpar->hasSameLayout(startpar->next()) ||
startpar->next()->empty()) { startpar->next()->empty()) {
mergeParagraph(buffer, startpar); #warning This is suspect. (Lgb)
// When doing this merge we must know if the par really
// belongs to an inset, and if it does then we have to use
// the insets paragraphs, and not the buffers. (Lgb)
mergeParagraph(buffer->params, buffer->paragraphs, startpar);
// this because endpar gets deleted here! // this because endpar gets deleted here!
(*endpar) = startpar; (*endpar) = startpar;
} }
@ -361,7 +365,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
// if necessary // if necessary
if (((*par)->size() > pos) || !(*par)->next()) { if (((*par)->size() > pos) || !(*par)->next()) {
breakParagraphConservative( breakParagraphConservative(
current_view->buffer(), *par, pos); current_view->buffer()->params, current_view->buffer()->paragraphs, *par, pos);
paste_the_end = true; paste_the_end = true;
} }
// set the end for redoing later // set the end for redoing later
@ -377,20 +381,23 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
if ((*par)->next() == lastbuffer) if ((*par)->next() == lastbuffer)
lastbuffer = *par; lastbuffer = *par;
mergeParagraph(current_view->buffer(), *par); mergeParagraph(current_view->buffer()->params,
current_view->buffer()->paragraphs, *par);
// store the new cursor position // store the new cursor position
*par = lastbuffer; *par = lastbuffer;
pos = lastbuffer->size(); pos = lastbuffer->size();
// maybe some pasting // maybe some pasting
if (lastbuffer->next() && paste_the_end) { if (lastbuffer->next() && paste_the_end) {
if (lastbuffer->next()->hasSameLayout(lastbuffer)) { if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
mergeParagraph(current_view->buffer(), lastbuffer); mergeParagraph(current_view->buffer()->params,
current_view->buffer()->paragraphs, lastbuffer);
} else if (!lastbuffer->next()->size()) { } else if (!lastbuffer->next()->size()) {
lastbuffer->next()->makeSameLayout(lastbuffer); lastbuffer->next()->makeSameLayout(lastbuffer);
mergeParagraph(current_view->buffer(), lastbuffer); mergeParagraph(current_view->buffer()->params, current_view->buffer()->paragraphs, lastbuffer);
} else if (!lastbuffer->size()) { } else if (!lastbuffer->size()) {
lastbuffer->makeSameLayout(lastbuffer->next()); lastbuffer->makeSameLayout(lastbuffer->next());
mergeParagraph(current_view->buffer(), lastbuffer); mergeParagraph(current_view->buffer()->params,
current_view->buffer()->paragraphs, lastbuffer);
} else } else
lastbuffer->next()->stripLeadingSpaces(); lastbuffer->next()->stripLeadingSpaces();
} }

View File

@ -317,7 +317,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
par->layout(params.getLyXTextClass().defaultLayout()); par->layout(params.getLyXTextClass().defaultLayout());
} else { } else {
// We are inserting into an existing document // We are inserting into an existing document
users->text->breakParagraph(users); users->text->breakParagraph(users, paragraphs);
first_par = users->text->ownerParagraph(); first_par = users->text->ownerParagraph();
pos = 0; pos = 0;
markDirty(); markDirty();
@ -1030,7 +1030,7 @@ void Buffer::insertStringAsLines(Paragraph *& par, pos_type & pos,
cit != str.end(); ++cit) { cit != str.end(); ++cit) {
if (*cit == '\n') { if (*cit == '\n') {
if (autobreakrows && (!par->empty() || layout->keepempty)) { if (autobreakrows && (!par->empty() || layout->keepempty)) {
breakParagraph(this, par, pos, breakParagraph(params, paragraphs, par, pos,
layout->isEnvironment()); layout->isEnvironment());
par = par->next(); par = par->next();
pos = 0; pos = 0;
@ -1867,12 +1867,12 @@ void Buffer::latexParagraphs(ostream & ofs,
if (layout->isEnvironment() || if (layout->isEnvironment() ||
!par->params().leftIndent().zero()) !par->params().leftIndent().zero())
{ {
par = TeXEnvironment(this, params, par, ofs, texrow); par = TeXEnvironment(this, params, paragraphs, par, ofs, texrow);
} else { } else {
par = TeXOnePar(this, params, par, ofs, texrow, moving_arg); par = TeXOnePar(this, params, paragraphs, par, ofs, texrow, moving_arg);
} }
} else { } else {
par = TeXOnePar(this, params, par, ofs, texrow, moving_arg); par = TeXOnePar(this, params, paragraphs, par, ofs, texrow, moving_arg);
} }
} }
// It might be that we only have a title in this document // It might be that we only have a title in this document

View File

@ -1,3 +1,10 @@
2003-03-06 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (updateLocal): un-const function
(updateLocal): adjust
(collapseParagraphs): un-const function
(collapseParagraphs): adjust
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* insetwrap.[Ch]: define a new class InsetWrapMailer and use * insetwrap.[Ch]: define a new class InsetWrapMailer and use

View File

@ -635,7 +635,7 @@ void InsetText::setUpdateStatus(BufferView * bv, int what) const
} }
void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty)
{ {
if (!autoBreakRows && paragraphs.begin()->next()) if (!autoBreakRows && paragraphs.begin()->next())
collapseParagraphs(bv); collapseParagraphs(bv);
@ -1448,7 +1448,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
result = DISPATCHED; result = DISPATCHED;
break; break;
} }
lt->breakParagraph(bv, 0); lt->breakParagraph(bv, paragraphs, 0);
updwhat = CURSOR | FULL; updwhat = CURSOR | FULL;
updflag = true; updflag = true;
break; break;
@ -1457,7 +1457,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
result = DISPATCHED; result = DISPATCHED;
break; break;
} }
lt->breakParagraph(bv, 1); lt->breakParagraph(bv, paragraphs, 1);
updwhat = CURSOR | FULL; updwhat = CURSOR | FULL;
updflag = true; updflag = true;
break; break;
@ -2388,7 +2388,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y); t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
if (!owner()) { if (!owner()) {
updateLocal(bv, FULL, false); const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar(); bv->updateScrollbar();
} else { } else {
@ -2427,7 +2427,7 @@ void InsetText::reinitLyXText() const
} }
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y); t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
if (!owner()) { if (!owner()) {
updateLocal(bv, FULL, false); const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
// this will scroll the screen such that the cursor becomes visible // this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar(); bv->updateScrollbar();
} else { } else {
@ -2768,7 +2768,7 @@ bool InsetText::checkInsertChar(LyXFont & font)
} }
void InsetText::collapseParagraphs(BufferView * bv) const void InsetText::collapseParagraphs(BufferView * bv)
{ {
LyXText * llt = getLyXText(bv); LyXText * llt = getLyXText(bv);
@ -2790,7 +2790,7 @@ void InsetText::collapseParagraphs(BufferView * bv) const
llt->selection.end.pos() + paragraphs.begin()->size()); llt->selection.end.pos() + paragraphs.begin()->size());
} }
} }
mergeParagraph(bv->buffer(), paragraphs.begin()); mergeParagraph(bv->buffer()->params, paragraphs, paragraphs.begin());
} }
reinitLyXText(); reinitLyXText();
} }
@ -2837,7 +2837,7 @@ void InsetText::appendParagraphs(Buffer * buffer,
// paste it! // paste it!
lastbuffer->next(buf); lastbuffer->next(buf);
buf->previous(lastbuffer); buf->previous(lastbuffer);
mergeParagraph(buffer, lastbuffer); mergeParagraph(buffer->params, paragraphs, lastbuffer);
reinitLyXText(); reinitLyXText();
} }

View File

@ -262,7 +262,7 @@ public:
ParagraphList paragraphs; ParagraphList paragraphs;
protected: protected:
/// ///
void updateLocal(BufferView *, int what, bool mark_dirty) const; void updateLocal(BufferView *, int what, bool mark_dirty);
/// set parameters for an initial lock of this inset /// set parameters for an initial lock of this inset
void lockInset(BufferView *); void lockInset(BufferView *);
/// lock an inset inside this one /// lock an inset inside this one
@ -358,7 +358,7 @@ private:
/// ///
void reinitLyXText() const; void reinitLyXText() const;
/// ///
void collapseParagraphs(BufferView *) const; void collapseParagraphs(BufferView *);
/* Private structures and variables */ /* Private structures and variables */
/// ///

View File

@ -28,6 +28,7 @@ class Spacing;
class UpdatableInset; class UpdatableInset;
class VSpace; class VSpace;
class WordLangTuple; class WordLangTuple;
class ParagraphList;
/** /**
@ -106,7 +107,8 @@ public:
/// ///
void breakAgainOneRow(BufferView *, Row * row); void breakAgainOneRow(BufferView *, Row * row);
/// what you expect when pressing <enter> at cursor position /// what you expect when pressing <enter> at cursor position
void breakParagraph(BufferView *, char keep_layout = 0); void breakParagraph(BufferView *,
ParagraphList & paragraphs, char keep_layout = 0);
/** set layout over selection and make a total rebreak of /** set layout over selection and make a total rebreak of
those paragraphs those paragraphs

View File

@ -817,7 +817,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_INSET_APPLY: { case LFUN_INSET_APPLY: {
string const name = cmd.getArg(0); string const name = cmd.getArg(0);
InsetBase * base = InsetBase * base =
bv->owner()->getDialogs().getOpenInset(name); bv->owner()->getDialogs().getOpenInset(name);
if (base) { if (base) {

View File

@ -29,16 +29,15 @@ using lyx::pos_type;
using std::endl; using std::endl;
using std::ostream; using std::ostream;
void breakParagraph(Buffer * buf, void breakParagraph(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par, ParagraphList::iterator par,
pos_type pos, pos_type pos,
int flag) int flag)
{ {
BufferParams const & bparams = buf->params;
// create a new paragraph, and insert into the list // create a new paragraph, and insert into the list
ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par), ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
new Paragraph); new Paragraph);
// without doing that we get a crash when typing <Return> at the // without doing that we get a crash when typing <Return> at the
// end of a paragraph // end of a paragraph
@ -130,15 +129,14 @@ void breakParagraph(Buffer * buf,
} }
void breakParagraphConservative(Buffer * buf, void breakParagraphConservative(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par, ParagraphList::iterator par,
pos_type pos) pos_type pos)
{ {
BufferParams const & bparams = buf->params;
// create a new paragraph // create a new paragraph
ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par), ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
new Paragraph); new Paragraph);
tmp->makeSameLayout(&*par); tmp->makeSameLayout(&*par);
// When can pos > Last()? // When can pos > Last()?
@ -161,10 +159,10 @@ void breakParagraphConservative(Buffer * buf,
} }
void mergeParagraph(Buffer * buf, ParagraphList::iterator par) void mergeParagraph(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par)
{ {
BufferParams const & bparams = buf->params;
ParagraphList::iterator the_next = boost::next(par); ParagraphList::iterator the_next = boost::next(par);
// first the DTP-stuff // first the DTP-stuff
@ -182,7 +180,7 @@ void mergeParagraph(Buffer * buf, ParagraphList::iterator par)
++j; ++j;
} }
buf->paragraphs.erase(the_next); paragraphs.erase(the_next);
} }
@ -255,18 +253,19 @@ int getEndLabel(Paragraph * para, BufferParams const & bparams)
ParagraphList::iterator ParagraphList::iterator
TeXDeeper(Buffer const * buf, TeXDeeper(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
ostream & os, TexRow & texrow) ostream & os, TexRow & texrow)
{ {
lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl; lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
ParagraphList::iterator par = pit; ParagraphList::iterator par = pit;
while (par != buf->paragraphs.end()&& par->params().depth() == pit->params().depth()) { while (par != paragraphs.end()&& par->params().depth() == pit->params().depth()) {
if (par->layout()->isEnvironment()) { if (par->layout()->isEnvironment()) {
par = TeXEnvironment(buf, bparams, par, par = TeXEnvironment(buf, bparams, paragraphs, par,
os, texrow); os, texrow);
} else { } else {
par = TeXOnePar(buf, bparams, par, par = TeXOnePar(buf, bparams, paragraphs, par,
os, texrow, false); os, texrow, false);
} }
} }
@ -279,6 +278,7 @@ TeXDeeper(Buffer const * buf,
ParagraphList::iterator ParagraphList::iterator
TeXEnvironment(Buffer const * buf, TeXEnvironment(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
ostream & os, TexRow & texrow) ostream & os, TexRow & texrow)
{ {
@ -289,7 +289,7 @@ TeXEnvironment(Buffer const * buf,
Language const * language = pit->getParLanguage(bparams); Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language; Language const * doc_language = bparams.language;
Language const * previous_language = Language const * previous_language =
(pit != buf->paragraphs.begin()) (pit != paragraphs.begin())
? boost::prior(pit)->getParLanguage(bparams) ? boost::prior(pit)->getParLanguage(bparams)
: doc_language; : doc_language;
if (language->babel() != previous_language->babel()) { if (language->babel() != previous_language->babel()) {
@ -338,9 +338,9 @@ TeXEnvironment(Buffer const * buf,
} }
ParagraphList::iterator par = pit; ParagraphList::iterator par = pit;
do { do {
par = TeXOnePar(buf, bparams, par, os, texrow, false); par = TeXOnePar(buf, bparams, paragraphs, par, os, texrow, false);
if (par != buf->paragraphs.end()&& par->params().depth() > pit->params().depth()) { if (par != paragraphs.end()&& par->params().depth() > pit->params().depth()) {
if (par->layout()->isParagraph()) { if (par->layout()->isParagraph()) {
// Thinko! // Thinko!
@ -360,9 +360,9 @@ TeXEnvironment(Buffer const * buf,
os << '\n'; os << '\n';
texrow.newline(); texrow.newline();
} }
par = TeXDeeper(buf, bparams, par, os, texrow); par = TeXDeeper(buf, bparams, paragraphs, par, os, texrow);
} }
} while (par != buf->paragraphs.end() } while (par != paragraphs.end()
&& par->layout() == pit->layout() && par->layout() == pit->layout()
&& par->params().depth() == pit->params().depth() && par->params().depth() == pit->params().depth()
&& par->params().leftIndent() == pit->params().leftIndent()); && par->params().leftIndent() == pit->params().leftIndent());
@ -404,6 +404,7 @@ InsetOptArg * optArgInset(Paragraph const & par)
ParagraphList::iterator ParagraphList::iterator
TeXOnePar(Buffer const * buf, TeXOnePar(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
ostream & os, TexRow & texrow, ostream & os, TexRow & texrow,
bool moving_arg) bool moving_arg)
@ -426,7 +427,7 @@ TeXOnePar(Buffer const * buf,
} }
if (!pit->params().spacing().isDefault() if (!pit->params().spacing().isDefault()
&& (pit == buf->paragraphs.begin() || !boost::prior(pit)->hasSameLayout(&*pit))) { && (pit == paragraphs.begin() || !boost::prior(pit)->hasSameLayout(&*pit))) {
os << pit->params().spacing().writeEnvirBegin() << '\n'; os << pit->params().spacing().writeEnvirBegin() << '\n';
texrow.newline(); texrow.newline();
} }
@ -462,14 +463,14 @@ TeXOnePar(Buffer const * buf,
Language const * language = pit->getParLanguage(bparams); Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language; Language const * doc_language = bparams.language;
Language const * previous_language = Language const * previous_language =
(pit != buf->paragraphs.begin()) (pit != paragraphs.begin())
? boost::prior(pit)->getParLanguage(bparams) ? boost::prior(pit)->getParLanguage(bparams)
: doc_language; : doc_language;
if (language->babel() != previous_language->babel() if (language->babel() != previous_language->babel()
// check if we already put language command in TeXEnvironment() // check if we already put language command in TeXEnvironment()
&& !(style->isEnvironment() && !(style->isEnvironment()
&& (pit == buf->paragraphs.begin() || && (pit == paragraphs.begin() ||
(boost::prior(pit)->layout() != pit->layout() && (boost::prior(pit)->layout() != pit->layout() &&
boost::prior(pit)->getDepth() <= pit->getDepth()) boost::prior(pit)->getDepth() <= pit->getDepth())
|| boost::prior(pit)->getDepth() < pit->getDepth()))) || boost::prior(pit)->getDepth() < pit->getDepth())))
@ -543,7 +544,7 @@ TeXOnePar(Buffer const * buf,
bool is_command = style->isCommand(); bool is_command = style->isCommand();
if (style->resfont.size() != font.size() if (style->resfont.size() != font.size()
&& boost::next(pit) != buf->paragraphs.end() && boost::next(pit) != paragraphs.end()
&& !is_command) { && !is_command) {
if (!need_par) if (!need_par)
os << '{'; os << '{';
@ -556,7 +557,7 @@ TeXOnePar(Buffer const * buf,
switch (style->latextype) { switch (style->latextype) {
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT:
if (boost::next(pit) != buf->paragraphs.end() if (boost::next(pit) != paragraphs.end()
&& (pit->params().depth() < boost::next(pit)->params().depth())) { && (pit->params().depth() < boost::next(pit)->params().depth())) {
os << '\n'; os << '\n';
texrow.newline(); texrow.newline();
@ -565,14 +566,14 @@ TeXOnePar(Buffer const * buf,
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
// if its the last paragraph of the current environment // if its the last paragraph of the current environment
// skip it otherwise fall through // skip it otherwise fall through
if (boost::next(pit) != buf->paragraphs.end() if (boost::next(pit) != paragraphs.end()
&& (boost::next(pit)->layout() != pit->layout() && (boost::next(pit)->layout() != pit->layout()
|| boost::next(pit)->params().depth() != pit->params().depth())) || boost::next(pit)->params().depth() != pit->params().depth()))
break; break;
// fall through possible // fall through possible
default: default:
// we don't need it for the last paragraph!!! // we don't need it for the last paragraph!!!
if (boost::next(pit) != buf->paragraphs.end()) { if (boost::next(pit) != paragraphs.end()) {
os << '\n'; os << '\n';
texrow.newline(); texrow.newline();
} }
@ -601,14 +602,14 @@ TeXOnePar(Buffer const * buf,
} }
if (!pit->params().spacing().isDefault() if (!pit->params().spacing().isDefault()
&& (boost::next(pit) == buf->paragraphs.end()|| !boost::next(pit)->hasSameLayout(&*pit))) { && (boost::next(pit) == paragraphs.end()|| !boost::next(pit)->hasSameLayout(&*pit))) {
os << pit->params().spacing().writeEnvirEnd() << '\n'; os << pit->params().spacing().writeEnvirEnd() << '\n';
texrow.newline(); texrow.newline();
} }
} }
// we don't need it for the last paragraph!!! // we don't need it for the last paragraph!!!
if (boost::next(pit) != buf->paragraphs.end()) { if (boost::next(pit) != paragraphs.end()) {
os << '\n'; os << '\n';
texrow.newline(); texrow.newline();
} else { } else {

View File

@ -21,13 +21,15 @@ class Paragraph;
class TexRow; class TexRow;
/// ///
void breakParagraph(Buffer * buf, void breakParagraph(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par, ParagraphList::iterator par,
lyx::pos_type pos, lyx::pos_type pos,
int flag); int flag);
/// ///
void breakParagraphConservative(Buffer * buf, void breakParagraphConservative(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par, ParagraphList::iterator par,
lyx::pos_type pos); lyx::pos_type pos);
@ -35,7 +37,8 @@ void breakParagraphConservative(Buffer * buf,
* Append the next paragraph onto the tail of this one. * Append the next paragraph onto the tail of this one.
* Be careful, this doesent make any check at all. * Be careful, this doesent make any check at all.
*/ */
void mergeParagraph(Buffer * buf, void mergeParagraph(BufferParams const & bparams,
ParagraphList & paragraphs,
ParagraphList::iterator par); ParagraphList::iterator par);
@ -56,18 +59,21 @@ int getEndLabel(Paragraph * para, BufferParams const & bparams);
ParagraphList::iterator ParagraphList::iterator
TeXDeeper(Buffer const * buf, TeXDeeper(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow); std::ostream & os, TexRow & texrow);
ParagraphList::iterator ParagraphList::iterator
TeXEnvironment(Buffer const * buf, TeXEnvironment(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow); std::ostream & os, TexRow & texrow);
ParagraphList::iterator ParagraphList::iterator
TeXOnePar(Buffer const * buf, TeXOnePar(Buffer const * buf,
BufferParams const & bparams, BufferParams const & bparams,
ParagraphList const & paragraphs,
ParagraphList::iterator pit, ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow, std::ostream & os, TexRow & texrow,
bool moving_arg); bool moving_arg);

View File

@ -1324,7 +1324,8 @@ void LyXText::breakAgainOneRow(BufferView * bview, Row * row)
} }
void LyXText::breakParagraph(BufferView * bview, char keep_layout) void LyXText::breakParagraph(BufferView * bview,
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() != cursor.par()->size()
@ -1363,7 +1364,7 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
// 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 = (layout->keepempty && cursor.par()->empty()); bool const isempty = (layout->keepempty && cursor.par()->empty());
::breakParagraph(bview->buffer(), cursor.par(), cursor.pos(), ::breakParagraph(bview->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
keep_layout); keep_layout);
// well this is the caption hack since one caption is really enough // well this is the caption hack since one caption is really enough
@ -2444,7 +2445,7 @@ void LyXText::backspace(BufferView * bview)
&& cursor.par()->getAlign() == tmppar->getAlign()) { && cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(tmprow); removeParagraph(tmprow);
removeRow(tmprow); removeRow(tmprow);
mergeParagraph(bview->buffer(), cursor.par()); mergeParagraph(bview->buffer()->params, bview->buffer()->paragraphs, cursor.par());
if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1)) if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1))
; //cursor.par()->insertChar(cursor.pos(), ' '); ; //cursor.par()->insertChar(cursor.pos(), ' ');

View File

@ -830,7 +830,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPH:
bv->beforeChange(this); bv->beforeChange(this);
breakParagraph(bv, 0); breakParagraph(bv, bv->buffer()->paragraphs, 0);
update(bv); update(bv);
selection.cursor = cursor; selection.cursor = cursor;
bv->switchKeyMap(); bv->switchKeyMap();
@ -839,7 +839,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BREAKPARAGRAPHKEEPLAYOUT: case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
bv->beforeChange(this); bv->beforeChange(this);
breakParagraph(bv, 1); breakParagraph(bv, bv->buffer()->paragraphs, 1);
update(bv); update(bv);
selection.cursor = cursor; selection.cursor = cursor;
bv->switchKeyMap(); bv->switchKeyMap();
@ -867,7 +867,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
} }
} }
else { else {
breakParagraph(bv, 0); breakParagraph(bv, bv->buffer()->paragraphs, 0);
//update(bv); //update(bv);
} }
update(bv); update(bv);