using cap::cutSelection;
using cap::pasteParagraphList;
-namespace {
+InsetText const & Text::inset() const
+{
+ return *owner_;
+}
+
-void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
+void Text::readParToken(Paragraph & par, Lexer & lex,
string const & token, Font & font, Change & change, ErrorList & errorList)
{
+ Buffer const & buf = owner_->buffer();
BufferParams const & bp = buf.params();
if (token[0] != '\\') {
if (layoutname.empty())
layoutname = tclass.defaultLayoutName();
- if (par.forcePlainLayout()) {
+ if (owner_->forcePlainLayout()) {
// in this case only the empty layout is allowed
layoutname = tclass.plainLayoutName();
} else if (par.usePlainLayout()) {
par.insertInset(par.size(), new InsetLine, font, change);
} else if (token == "\\change_unchanged") {
change = Change(Change::UNCHANGED);
- } else if (token == "\\change_inserted") {
+ } else if (token == "\\change_inserted" || token == "\\change_deleted") {
lex.eatLine();
istringstream is(lex.getString());
unsigned int aid;
time_t ct;
is >> aid >> ct;
- if (aid >= bp.author_map.size()) {
+ map<unsigned int, int> const & am = bp.author_map;
+ if (am.find(aid) == am.end()) {
errorList.push_back(ErrorItem(_("Change tracking error"),
- bformat(_("Unknown author index for insertion: %1$d\n"), aid),
+ bformat(_("Unknown author index for change: %1$d\n"), aid),
par.id(), 0, par.size()));
change = Change(Change::UNCHANGED);
- } else
- change = Change(Change::INSERTED, bp.author_map[aid], ct);
- } else if (token == "\\change_deleted") {
- lex.eatLine();
- istringstream is(lex.getString());
- unsigned int aid;
- time_t ct;
- is >> aid >> ct;
- if (aid >= bp.author_map.size()) {
- errorList.push_back(ErrorItem(_("Change tracking error"),
- bformat(_("Unknown author index for deletion: %1$d\n"), aid),
- par.id(), 0, par.size()));
- change = Change(Change::UNCHANGED);
- } else
- change = Change(Change::DELETED, bp.author_map[aid], ct);
+ } else {
+ if (token == "\\change_inserted")
+ change = Change(Change::INSERTED, am.find(aid)->second, ct);
+ else
+ change = Change(Change::DELETED, am.find(aid)->second, ct);
+ }
} else {
lex.eatLine();
errorList.push_back(ErrorItem(_("Unknown token"),
}
-void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex,
+void Text::readParagraph(Paragraph & par, Lexer & lex,
ErrorList & errorList)
{
lex.nextToken();
Change change(Change::UNCHANGED);
while (lex.isOK()) {
- readParToken(buf, par, lex, token, font, change, errorList);
+ readParToken(par, lex, token, font, change, errorList);
lex.nextToken();
token = lex.getString();
}
-} // namespace anon
-
class TextCompletionList : public CompletionList
{
public:
}
-double Text::spacing(Buffer const & buffer, Paragraph const & par) const
+double Text::spacing(Paragraph const & par) const
{
if (par.params().spacing().isDefault())
- return buffer.params().spacing().getValue();
+ return owner_->buffer().params().spacing().getValue();
return par.params().spacing().getValue();
}
|| par.isSeparator(cur.pos() - 2)
|| par.isNewline(cur.pos() - 2))
) {
- setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
+ setCharFont(pit, cur.pos() - 1, cur.current_font,
tm.font_);
} else if (contains(number_seperators, c)
&& cur.pos() >= 2
&& tm.displayFont(pit, cur.pos() - 2).fontInfo().number() == FONT_ON) {
- setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
+ setCharFont(pit, cur.pos() - 1, cur.current_font,
tm.font_);
}
}
cur.checkBufferStructure();
// cur.updateFlags(Update::Force);
- setCursor(cur.top(), cur.pit(), cur.pos() + 1);
+ bool boundary = tm.isRTLBoundary(cur.pit(), cur.pos() + 1);
+ setCursor(cur, cur.pit(), cur.pos() + 1, false, boundary);
charInserted(cur);
}
LASSERT(this == cur.text(), /**/);
if (!cur.selection()) {
- Change const & change = cur.paragraph().lookupChange(cur.pos());
- if (!(change.changed() && findNextChange(&cur.bv())))
+ bool const changed = cur.paragraph().isChanged(cur.pos());
+ if (!(changed && findNextChange(&cur.bv())))
return;
}
pos_type right = (pit == endPit ? endPos : parSize);
if (op == ACCEPT) {
- pars_[pit].acceptChanges(cur.buffer()->params(), left, right);
+ pars_[pit].acceptChanges(left, right);
} else {
- pars_[pit].rejectChanges(cur.buffer()->params(), left, right);
+ pars_[pit].rejectChanges(left, right);
}
}
}
-void Text::acceptChanges(BufferParams const & bparams)
+void Text::acceptChanges()
{
+ BufferParams const & bparams = owner_->buffer().params();
lyx::acceptChanges(pars_, bparams);
deleteEmptyParagraphMechanism(0, pars_.size() - 1, bparams.trackChanges);
}
-void Text::rejectChanges(BufferParams const & bparams)
+void Text::rejectChanges()
{
+ BufferParams const & bparams = owner_->buffer().params();
pit_type pars_size = static_cast<pit_type>(pars_.size());
// first, reject changes within each individual paragraph
// (do not consider end-of-par)
for (pit_type pit = 0; pit < pars_size; ++pit) {
if (!pars_[pit].empty()) // prevent assertion failure
- pars_[pit].rejectChanges(bparams, 0, pars_[pit].size());
+ pars_[pit].rejectChanges(0, pars_[pit].size());
}
// next, reject imaginary end-of-par characters
{
LASSERT(this == cur.text(), return false);
- if (isMainText(cur.bv().buffer()) || cur.inset().nargs() != 1)
+ if (isMainText() || cur.inset().nargs() != 1)
return false;
cur.recordUndoInset();
// restore position
cur.pit() = min(cur.lastpit(), spit);
cur.pos() = min(cur.lastpos(), spos);
- }
+ } else
+ // this is the least that needs to be done (bug 6003)
+ // in the above case, pasteParagraphList handles this
+ cur.buffer()->updateLabels();
cur.clearSelection();
cur.resetAnchor();
return true;
}
-void Text::write(Buffer const & buf, ostream & os) const
+void Text::write(ostream & os) const
{
+ Buffer const & buf = owner_->buffer();
ParagraphList::const_iterator pit = paragraphs().begin();
ParagraphList::const_iterator end = paragraphs().end();
depth_type dth = 0;
}
-bool Text::read(Buffer const & buf, Lexer & lex,
+bool Text::read(Lexer & lex,
ErrorList & errorList, InsetText * insetPtr)
{
+ Buffer const & buf = owner_->buffer();
depth_type depth = 0;
bool res = true;
par.params().depth(depth);
par.setFont(0, Font(inherit_font, buf.params().language));
pars_.push_back(par);
-
- // FIXME: goddamn InsetTabular makes us pass a Buffer
- // not BufferParams
- lyx::readParagraph(buf, pars_.back(), lex, errorList);
+ readParagraph(pars_.back(), lex, errorList);
// register the words in the global word list
CursorSlice sl = CursorSlice(*insetPtr);
Change change = par.lookupChange(cur.pos());
- if (change.type != Change::UNCHANGED) {
+ if (change.changed()) {
Author const & a = buf.params().authors().get(change.author);
os << _("Change: ") << a.name();
if (!a.email().empty())