- // Next check, if there will be two blanks together or a blank at
- // the beginning of a paragraph.
- // I decided to handle blanks like normal characters, the main
- // difference are the special checks when calculating the row.fill
- // (blank does not count at the end of a row) and the check here
-
- // When the free-spacing option is set for the current layout,
- // disable the double-space checking
- if (!freeSpacing && isLineSeparatorChar(c)) {
- if (cur.pos() == 0) {
- cur.message(_(
- "You cannot insert a space at the "
- "beginning of a paragraph. Please read the Tutorial."));
- return;
- }
- // LASSERT: Is it safe to continue here?
- LASSERT(cur.pos() > 0, /**/);
- if ((par.isLineSeparator(cur.pos() - 1) || par.isNewline(cur.pos() - 1))
- && !par.isDeleted(cur.pos() - 1)) {
- cur.message(_(
- "You cannot type two spaces this way. "
- "Please read the Tutorial."));
- return;
- }
- }
-
- // Prevent to insert uncodable characters in verbatim and ERT
- // (workaround for bug 9012)
- // Don't do it for listings inset, since InsetListings::latex() tries
- // to switch to a usable encoding which works in many cases (bug 9102).
- if (cur.paragraph().isPassThru() && owner_->lyxCode() != LISTINGS_CODE &&
- cur.current_font.language()) {
- Encoding const * e = cur.current_font.language()->encoding();
- if (!e->encodable(c)) {
- cur.message(_("Character is uncodable in verbatim paragraphs."));
- return;
+ pos_type pos = cur.pos();
+ if (!cur.paragraph().isPassThru() && owner_->lyxCode() != IPA_CODE &&
+ cur.real_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--;