+ // 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--;
+ } 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);