Text::Text(InsetText * owner, bool use_default_layout)
- : owner_(owner), autoBreakRows_(false), undo_counter_(0)
+ : owner_(owner)
{
pars_.push_back(Paragraph());
Paragraph & par = pars_.back();
Text::Text(InsetText * owner, Text const & text)
- : owner_(owner), autoBreakRows_(text.autoBreakRows_), undo_counter_(0)
+ : owner_(owner)
{
pars_ = text.pars_;
ParagraphList::iterator const end = pars_.end();
} else if (token == "\\color") {
lex.next();
setLyXColor(lex.getString(), font.fontInfo());
- } else if (token == "\\SpecialChar") {
+ } else if (token == "\\SpecialChar" ||
+ (token == "\\SpecialCharNoPassThru" &&
+ !par.layout().pass_thru && !inset().isPassThru())) {
auto_ptr<Inset> inset;
inset.reset(new InsetSpecialChar);
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
+ } else if (token == "\\SpecialCharNoPassThru") {
+ lex.next();
+ 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);
inset->read(lex);
inset->setBuffer(*buf);
par.insertInset(par.size(), inset.release(), font, change);
+ } else if (token == "\\twohyphens" || token == "\\threehyphens") {
+ // Ideally, this should be done by lyx2lyx, but lyx2lyx does not know the
+ // running font and does not know anything about layouts (and CopyStyle).
+ Layout const & layout(par.layout());
+ FontInfo info = font.fontInfo();
+ info.realize(layout.resfont);
+ if (layout.pass_thru || inset().isPassThru() ||
+ info.family() == TYPEWRITER_FAMILY) {
+ if (token == "\\twohyphens")
+ par.insert(par.size(), from_ascii("--"), font, change);
+ else
+ par.insert(par.size(), from_ascii("---"), font, change);
+ } else {
+ if (token == "\\twohyphens")
+ par.insertChar(par.size(), 0x2013, font, change);
+ else
+ par.insertChar(par.size(), 0x2014, font, change);
+ }
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);
} else if (token == "\\LyXTable") {
cit != str.end(); ++cit) {
Paragraph & par = pars_[pit];
if (*cit == '\n') {
- if (autoBreakRows_ && (!par.empty() || par.allowEmpty())) {
+ if (inset().allowMultiPar() && (!par.empty() || par.allowEmpty())) {
lyx::breakParagraph(*this, pit, pos,
par.layout().isEnvironment());
++pit;
}
}
- par.insertChar(cur.pos(), c, cur.current_font,
+ pos_type pos = cur.pos();
+ if (!cur.paragraph().isPassThru() && owner_->lyxCode() != IPA_CODE &&
+ cur.current_font.fontInfo().family() != TYPEWRITER_FAMILY &&
+ c == '-' && pos > 0) {
+ if (par.getChar(pos - 1) == '-') {
+ // convert "--" to endash
+ par.eraseChar(pos - 1, cur.buffer()->params().track_changes);
+ c = 0x2013;
+ pos--;
+ } else if (par.getChar(pos - 1) == 0x2013) {
+ // convert "---" to emdash
+ par.eraseChar(pos - 1, cur.buffer()->params().track_changes);
+ c = 0x2014;
+ pos--;
+ } else if (par.getChar(pos - 1) == 0x2014) {
+ // convert "----" to "-"
+ par.eraseChar(pos - 1, cur.buffer()->params().track_changes);
+ c = '-';
+ pos--;
+ }
+ }
+
+ par.insertChar(pos, c, cur.current_font,
cur.buffer()->params().track_changes);
cur.checkBufferStructure();
// cur.screenUpdateFlags(Update::Force);
bool boundary = cur.boundary()
- || tm.isRTLBoundary(cur.pit(), cur.pos() + 1);
- setCursor(cur, cur.pit(), cur.pos() + 1, false, boundary);
+ || tm.isRTLBoundary(cur.pit(), pos + 1);
+ setCursor(cur, cur.pit(), pos + 1, false, boundary);
charInserted(cur);
}
{
Paragraph & par = cur.paragraph();
- // Here we call finishUndo for every 20 characters inserted.
- // This is from my experience how emacs does it. (Lgb)
- if (undo_counter_ < 20) {
- ++undo_counter_;
- } else {
- cur.finishUndo();
- undo_counter_ = 0;
- }
-
// register word if a non-letter was entered
if (cur.pos() > 1
&& !par.isWordSeparator(cur.pos() - 2)
// if a bibitem is deleted, merge with previous paragraph
// if this is a bibliography item as well
if (cur.pit() > 0 && par.layout() == prevpar.layout()) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, cur.text()->paragraphs(),
prevcur.pit());
cur.forceBufferUpdate();
// is it an empty paragraph?
if (cur.lastpos() == 0
|| (cur.lastpos() == 1 && par.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
+ cur.recordUndo(prevcur.pit());
plist.erase(boost::next(plist.begin(), cur.pit()));
needsUpdate = true;
}
// is previous par empty?
else if (prevcur.lastpos() == 0
|| (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit(), cur.pit());
+ cur.recordUndo(prevcur.pit());
plist.erase(boost::next(plist.begin(), prevcur.pit()));
needsUpdate = true;
}
else if (par.layout() == prevpar.layout()
|| tclass.isDefaultLayout(par.layout())
|| tclass.isPlainLayout(par.layout())) {
- cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
+ cur.recordUndo(prevcur.pit());
mergeParagraph(bufparams, plist, prevcur.pit());
needsUpdate = true;
}
--prev_cur.pit();
if (!prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
- cur.recordUndo(ATOMIC_UNDO, prev_cur.pit(), prev_cur.pit());
+ cur.recordUndo(prev_cur.pit(), prev_cur.pit());
prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));
setCursorIntern(cur, prev_cur.pit(), prev_cur.lastpos());
return true;