commit 52cd43dfdcffa3d293cec1be11ac9d4fa55b46bd
Author: Juergen Spitzmueller <[email protected]>
Date: Mon Mar 23 12:07:47 2020 +0100
Paste some special chars as insets
See #11790
---
src/Text.cpp | 18 ++++++++++++++++--
src/insets/InsetSpecialChar.cpp | 9 ++++++++-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/Text.cpp b/src/Text.cpp
index 25ce684..4a44757 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -866,6 +866,13 @@ void Text::insertStringAsLines(Cursor & cur, docstring
const & str,
pit_type pit = cur.pit();
pos_type pos = cur.pos();
+ // The special chars we handle
+ map<wchar_t, InsetSpecialChar::Kind> specialchars;
+ specialchars[0x200c] = InsetSpecialChar::LIGATURE_BREAK;
+ specialchars[0x200b] = InsetSpecialChar::ALLOWBREAK;
+ specialchars[0x2026] = InsetSpecialChar::LDOTS;
+ specialchars[0x2011] = InsetSpecialChar::NOBREAKDASH;
+
// insert the string, don't insert doublespace
bool space_inserted = true;
for (auto const & ch : str) {
@@ -895,8 +902,15 @@ void Text::insertStringAsLines(Cursor & cur, docstring
const & str,
++pos;
space_inserted = true;
}
- } else if (!isPrintable(ch) && ch != 0x200c) {
- // Ignore unprintables, except for ZWNJ (0x200c)
+ } else if (specialchars.find(ch) != specialchars.end()) {
+ par.insertInset(pos, new
InsetSpecialChar(specialchars.find(ch)->second),
+ font, bparams.track_changes ?
+ Change(Change::INSERTED)
+ : Change(Change::UNCHANGED));
+ ++pos;
+ space_inserted = false;
+ } else if (!isPrintable(ch)) {
+ // Ignore (other) unprintables
continue;
} else {
// just insert the character
diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 76da971..740061e 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -15,6 +15,7 @@
#include "InsetSpecialChar.h"
#include "Dimension.h"
+#include "Encoding.h"
#include "Font.h"
#include "Language.h"
#include "LaTeXFeatures.h"
@@ -384,6 +385,7 @@ void InsetSpecialChar::latex(otexstream & os,
OutputParams const & rp) const
{
bool const rtl = rp.local_font->isRightToLeft();
+ bool const utf8 = rp.encoding->iconvName() == "UTF-8";
string lswitch = "";
string lswitche = "";
if (rtl && !rp.use_polyglossia) {
@@ -399,10 +401,15 @@ void InsetSpecialChar::latex(otexstream & os,
os << "\\-";
break;
case ALLOWBREAK:
+ // U+200B not yet supported by utf8 inputenc
os << "\\LyXZeroWidthSpace" << termcmd;
break;
case LIGATURE_BREAK:
- os << "\\textcompwordmark" << termcmd;
+ if (utf8)
+ // U+200C ZERO WIDTH NON-JOINER
+ os.put(0x200c);
+ else
+ os << "\\textcompwordmark" << termcmd;
break;
case END_OF_SENTENCE:
os << "\\@.";
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs