#include "support/lyxalgo.h"
#include "support/lyxtime.h"
#include "support/textutils.h"
+#include "support/unique_ptr.h"
#include <sstream>
void breakParagraphConservative(BufferParams const & bparams,
- ParagraphList & pars, pit_type par_offset, pos_type pos)
+ ParagraphList & pars, pit_type pit, pos_type pos)
{
// create a new paragraph
- Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), par_offset + 1),
+ Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), pit + 1),
Paragraph());
- Paragraph & par = pars[par_offset];
+ Paragraph & par = pars[pit];
tmp.setInsetOwner(&par.inInset());
tmp.makeSameLayout(par);
Text::Text(InsetText * owner, Text const & text)
- : owner_(owner)
+ : owner_(owner), pars_(text.pars_)
{
- pars_ = text.pars_;
ParagraphList::iterator const end = pars_.end();
ParagraphList::iterator it = pars_.begin();
for (; it != end; ++it)
if (added_one) {
// Warn the user.
docstring const s = bformat(_("Layout `%1$s' was not found."), layoutname);
- errorList.push_back(
- ErrorItem(_("Layout Not Found"), s, par.id(), 0, par.size()));
+ errorList.push_back(ErrorItem(_("Layout Not Found"), s,
+ {par.id(), 0}, {par.id(), -1}));
}
par.setLayout(bp.documentClass()[layoutname]);
lex.eatLine();
docstring line = lex.getDocString();
errorList.push_back(ErrorItem(_("Unknown Inset"), line,
- par.id(), 0, par.size()));
+ {par.id(), 0}, {par.id(), -1}));
}
} else if (token == "\\family") {
lex.next();
} else if (token == "\\SpecialChar" ||
(token == "\\SpecialCharNoPassThru" &&
!par.layout().pass_thru && !inset().isPassThru())) {
- auto_ptr<Inset> inset;
- inset.reset(new InsetSpecialChar);
+ auto inset = make_unique<InsetSpecialChar>();
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
docstring const s = ltrim(lex.getDocString(), "\\");
par.insert(par.size(), s, font, change);
} else if (token == "\\IPAChar") {
- auto_ptr<Inset> inset;
- inset.reset(new InsetIPAChar);
+ auto inset = make_unique<InsetIPAChar>();
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);
} else if (token == "\\LyXTable") {
- auto_ptr<Inset> inset(new InsetTabular(buf));
+ auto inset = make_unique<InsetTabular>(buf);
inset->read(lex);
par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\change_unchanged") {
"missing until the corresponding tracked changes "
"are merged or this user edits the file again.\n"),
aid),
- par.id(), par.size(), par.size() + 1
- ));
+ {par.id(), par.size()}, {par.id(), par.size() + 1}));
bp.addAuthor(Author(aid));
}
if (token == "\\change_inserted")
} else {
lex.eatLine();
errorList.push_back(ErrorItem(_("Unknown token"),
- bformat(_("Unknown token: %1$s %2$s\n"), from_utf8(token),
- lex.getDocString()),
- par.id(), 0, par.size()));
+ bformat(_("Unknown token: %1$s %2$s\n"),
+ from_utf8(token),
+ lex.getDocString()),
+ {par.id(), 0}, {par.id(), -1}));
}
}
Layout const & layout = cpar.layout();
if (cur.lastpos() == 0 && !cpar.allowEmpty()) {
- if (changeDepthAllowed(cur, DEC_DEPTH))
+ if (changeDepthAllowed(cur, DEC_DEPTH)) {
changeDepth(cur, DEC_DEPTH);
- else {
+ pit_type const prev = depthHook(cpit, cpar.getDepth());
+ docstring const & lay = pars_[prev].layout().name();
+ if (lay != layout.name())
+ setLayout(cur, lay);
+ } else {
docstring const & lay = cur.paragraph().usePlainLayout()
? tclass.plainLayoutName() : tclass.defaultLayoutName();
- setLayout(cur, lay);
+ if (lay != layout.name())
+ setLayout(cur, lay);
}
return;
}
if (lyxrc.auto_number) {
static docstring const number_operators = from_ascii("+-/*");
static docstring const number_unary_operators = from_ascii("+-");
- static docstring const number_seperators = from_ascii(".,:");
+ static docstring const number_separators = from_ascii(".,:");
if (cur.current_font.fontInfo().number() == FONT_ON) {
if (!isDigitASCII(c) && !contains(number_operators, c) &&
- !(contains(number_seperators, c) &&
+ !(contains(number_separators, c) &&
cur.pos() != 0 &&
cur.pos() != cur.lastpos() &&
tm.displayFont(pit, cur.pos()).fontInfo().number() == FONT_ON &&
) {
setCharFont(pit, cur.pos() - 1, cur.current_font,
tm.font_);
- } else if (contains(number_seperators, c)
+ } else if (contains(number_separators, c)
&& cur.pos() >= 2
&& tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
setCharFont(pit, cur.pos() - 1, cur.current_font,
return dissolveInset(cur);
if (!par.isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
+ cur.recordUndo(DELETE_UNDO);
par.setChange(cur.pos(), Change(Change::DELETED));
cur.forwardPos();
needsUpdate = true;
if (needsUpdate) {
// Make sure the cursor is correct. Is this really needed?
// No, not really... at least not here!
- cur.text()->setCursor(cur.top(), cur.pit(), cur.pos());
+ cur.top().setPitPos(cur.pit(), cur.pos());
cur.checkBufferStructure();
}
// A singlePar update is not enough in this case.
// cur.screenUpdateFlags(Update::Force);
- setCursor(cur.top(), cur.pit(), cur.pos());
+ cur.top().setPitPos(cur.pit(), cur.pos());
return needsUpdate;
}