beforeChange(bv_->text);
if (!lout.empty()) {
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);
if (!bv_->text->cursor.par()->empty()) {
bv_->text->cursorLeft(bv_);
- bv_->text->breakParagraph(bv_);
+ bv_->text->breakParagraph(bv_, bv_->buffer()->paragraphs);
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
+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>
* commandtags.h:
Paragraph * pit = startpar->next();
- while (1) {
+ while (true) {
// *endpar can be 0
if (!pit)
break;
// paste the paragraphs again, if possible
if (startpar->hasSameLayout(startpar->next()) ||
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!
(*endpar) = startpar;
}
// if necessary
if (((*par)->size() > pos) || !(*par)->next()) {
breakParagraphConservative(
- current_view->buffer(), *par, pos);
+ current_view->buffer()->params, current_view->buffer()->paragraphs, *par, pos);
paste_the_end = true;
}
// set the end for redoing later
if ((*par)->next() == lastbuffer)
lastbuffer = *par;
- mergeParagraph(current_view->buffer(), *par);
+ mergeParagraph(current_view->buffer()->params,
+ current_view->buffer()->paragraphs, *par);
// store the new cursor position
*par = lastbuffer;
pos = lastbuffer->size();
// maybe some pasting
if (lastbuffer->next() && paste_the_end) {
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()) {
lastbuffer->next()->makeSameLayout(lastbuffer);
- mergeParagraph(current_view->buffer(), lastbuffer);
+ mergeParagraph(current_view->buffer()->params, current_view->buffer()->paragraphs, lastbuffer);
} else if (!lastbuffer->size()) {
lastbuffer->makeSameLayout(lastbuffer->next());
- mergeParagraph(current_view->buffer(), lastbuffer);
+ mergeParagraph(current_view->buffer()->params,
+ current_view->buffer()->paragraphs, lastbuffer);
} else
lastbuffer->next()->stripLeadingSpaces();
}
par->layout(params.getLyXTextClass().defaultLayout());
} else {
// We are inserting into an existing document
- users->text->breakParagraph(users);
+ users->text->breakParagraph(users, paragraphs);
first_par = users->text->ownerParagraph();
pos = 0;
markDirty();
cit != str.end(); ++cit) {
if (*cit == '\n') {
if (autobreakrows && (!par->empty() || layout->keepempty)) {
- breakParagraph(this, par, pos,
+ breakParagraph(params, paragraphs, par, pos,
layout->isEnvironment());
par = par->next();
pos = 0;
if (layout->isEnvironment() ||
!par->params().leftIndent().zero())
{
- par = TeXEnvironment(this, params, par, ofs, texrow);
+ par = TeXEnvironment(this, params, paragraphs, par, ofs, texrow);
} else {
- par = TeXOnePar(this, params, par, ofs, texrow, moving_arg);
+ par = TeXOnePar(this, params, paragraphs, par, ofs, texrow, moving_arg);
}
} 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
+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>
* insetwrap.[Ch]: define a new class InsetWrapMailer and use
}
-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())
collapseParagraphs(bv);
result = DISPATCHED;
break;
}
- lt->breakParagraph(bv, 0);
+ lt->breakParagraph(bv, paragraphs, 0);
updwhat = CURSOR | FULL;
updflag = true;
break;
result = DISPATCHED;
break;
}
- lt->breakParagraph(bv, 1);
+ lt->breakParagraph(bv, paragraphs, 1);
updwhat = CURSOR | FULL;
updflag = true;
break;
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
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
bv->updateScrollbar();
} else {
}
t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
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
bv->updateScrollbar();
} else {
}
-void InsetText::collapseParagraphs(BufferView * bv) const
+void InsetText::collapseParagraphs(BufferView * bv)
{
LyXText * llt = getLyXText(bv);
llt->selection.end.pos() + paragraphs.begin()->size());
}
}
- mergeParagraph(bv->buffer(), paragraphs.begin());
+ mergeParagraph(bv->buffer()->params, paragraphs, paragraphs.begin());
}
reinitLyXText();
}
// paste it!
lastbuffer->next(buf);
buf->previous(lastbuffer);
- mergeParagraph(buffer, lastbuffer);
+ mergeParagraph(buffer->params, paragraphs, lastbuffer);
reinitLyXText();
}
ParagraphList paragraphs;
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
void lockInset(BufferView *);
/// lock an inset inside this one
///
void reinitLyXText() const;
///
- void collapseParagraphs(BufferView *) const;
+ void collapseParagraphs(BufferView *);
/* Private structures and variables */
///
class UpdatableInset;
class VSpace;
class WordLangTuple;
+class ParagraphList;
/**
///
void breakAgainOneRow(BufferView *, Row * row);
/// 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
those paragraphs
case LFUN_INSET_APPLY: {
string const name = cmd.getArg(0);
- InsetBase * base =
+ InsetBase * base =
bv->owner()->getDialogs().getOpenInset(name);
if (base) {
using std::endl;
using std::ostream;
-void breakParagraph(Buffer * buf,
+void breakParagraph(BufferParams const & bparams,
+ ParagraphList & paragraphs,
ParagraphList::iterator par,
pos_type pos,
int flag)
{
- BufferParams const & bparams = buf->params;
-
// create a new paragraph, and insert into the list
- ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par),
- new Paragraph);
+ ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
+ new Paragraph);
// without doing that we get a crash when typing <Return> at the
// end of a paragraph
}
-void breakParagraphConservative(Buffer * buf,
+void breakParagraphConservative(BufferParams const & bparams,
+ ParagraphList & paragraphs,
ParagraphList::iterator par,
pos_type pos)
{
- BufferParams const & bparams = buf->params;
-
// create a new paragraph
- ParagraphList::iterator tmp = buf->paragraphs.insert(boost::next(par),
- new Paragraph);
+ ParagraphList::iterator tmp = paragraphs.insert(boost::next(par),
+ new Paragraph);
tmp->makeSameLayout(&*par);
// When can pos > Last()?
}
-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);
// first the DTP-stuff
++j;
}
- buf->paragraphs.erase(the_next);
+ paragraphs.erase(the_next);
}
ParagraphList::iterator
TeXDeeper(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
ostream & os, TexRow & texrow)
{
lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
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()) {
- par = TeXEnvironment(buf, bparams, par,
+ par = TeXEnvironment(buf, bparams, paragraphs, par,
os, texrow);
} else {
- par = TeXOnePar(buf, bparams, par,
+ par = TeXOnePar(buf, bparams, paragraphs, par,
os, texrow, false);
}
}
ParagraphList::iterator
TeXEnvironment(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
ostream & os, TexRow & texrow)
{
Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language =
- (pit != buf->paragraphs.begin())
+ (pit != paragraphs.begin())
? boost::prior(pit)->getParLanguage(bparams)
: doc_language;
if (language->babel() != previous_language->babel()) {
}
ParagraphList::iterator par = pit;
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()) {
// Thinko!
os << '\n';
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->params().depth() == pit->params().depth()
&& par->params().leftIndent() == pit->params().leftIndent());
ParagraphList::iterator
TeXOnePar(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
ostream & os, TexRow & texrow,
bool moving_arg)
}
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';
texrow.newline();
}
Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language =
- (pit != buf->paragraphs.begin())
+ (pit != paragraphs.begin())
? boost::prior(pit)->getParLanguage(bparams)
: doc_language;
if (language->babel() != previous_language->babel()
// check if we already put language command in TeXEnvironment()
&& !(style->isEnvironment()
- && (pit == buf->paragraphs.begin() ||
+ && (pit == paragraphs.begin() ||
(boost::prior(pit)->layout() != pit->layout() &&
boost::prior(pit)->getDepth() <= pit->getDepth())
|| boost::prior(pit)->getDepth() < pit->getDepth())))
bool is_command = style->isCommand();
if (style->resfont.size() != font.size()
- && boost::next(pit) != buf->paragraphs.end()
+ && boost::next(pit) != paragraphs.end()
&& !is_command) {
if (!need_par)
os << '{';
switch (style->latextype) {
case LATEX_ITEM_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())) {
os << '\n';
texrow.newline();
case LATEX_ENVIRONMENT:
// if its the last paragraph of the current environment
// 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)->params().depth() != pit->params().depth()))
break;
// fall through possible
default:
// we don't need it for the last paragraph!!!
- if (boost::next(pit) != buf->paragraphs.end()) {
+ if (boost::next(pit) != paragraphs.end()) {
os << '\n';
texrow.newline();
}
}
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';
texrow.newline();
}
}
// we don't need it for the last paragraph!!!
- if (boost::next(pit) != buf->paragraphs.end()) {
+ if (boost::next(pit) != paragraphs.end()) {
os << '\n';
texrow.newline();
} else {
class TexRow;
///
-void breakParagraph(Buffer * buf,
+void breakParagraph(BufferParams const & bparams,
+ ParagraphList & paragraphs,
ParagraphList::iterator par,
lyx::pos_type pos,
int flag);
///
-void breakParagraphConservative(Buffer * buf,
+void breakParagraphConservative(BufferParams const & bparams,
+ ParagraphList & paragraphs,
ParagraphList::iterator par,
lyx::pos_type pos);
* Append the next paragraph onto the tail of this one.
* 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
TeXDeeper(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow);
ParagraphList::iterator
TeXEnvironment(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow);
ParagraphList::iterator
TeXOnePar(Buffer const * buf,
BufferParams const & bparams,
+ ParagraphList const & paragraphs,
ParagraphList::iterator pit,
std::ostream & os, TexRow & texrow,
bool moving_arg);
}
-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
if (cursor.pos() && cursor.pos() != cursor.par()->size()
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
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);
// well this is the caption hack since one caption is really enough
&& cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(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))
; //cursor.par()->insertChar(cursor.pos(), ' ');
case LFUN_BREAKPARAGRAPH:
bv->beforeChange(this);
- breakParagraph(bv, 0);
+ breakParagraph(bv, bv->buffer()->paragraphs, 0);
update(bv);
selection.cursor = cursor;
bv->switchKeyMap();
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
bv->beforeChange(this);
- breakParagraph(bv, 1);
+ breakParagraph(bv, bv->buffer()->paragraphs, 1);
update(bv);
selection.cursor = cursor;
bv->switchKeyMap();
}
}
else {
- breakParagraph(bv, 0);
+ breakParagraph(bv, bv->buffer()->paragraphs, 0);
//update(bv);
}
update(bv);