]> git.lyx.org Git - features.git/commitdiff
Fix bug #11084.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 22 Mar 2018 03:08:12 +0000 (23:08 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 22 Mar 2018 03:08:38 +0000 (23:08 -0400)
Allow unicode-insert to accept a sequence of codepoints.

src/LyXAction.cpp
src/Text3.cpp
src/mathed/InsetMathNest.cpp
src/support/lstrings.h

index 771a7e5c542e8abd9a4088a0de2b2489a3dcedad..7307d22b23f67aed0b07e3f1c1e66f8f6ed19c0f 100644 (file)
@@ -3850,10 +3850,10 @@ void LyXAction::init()
 /*!
  * \var lyx::FuncCode lyx::LFUN_UNICODE_INSERT
  * \li Action: Inserts a single unicode character.
- * \li Syntax: unicode-insert <CHAR>
- * \li Params: <CHAR>: The character to insert, given as its code
+ * \li Syntax: unicode-insert <CHAR1> <CHAR2> ...
+ * \li Params: <CHARn>: The character to insert, given as its code
                        point, in hexadecimal.
- * \li Sample: unicode-insert 0x0100
+ * \li Sample: unicode-insert 0x0100 0x0259
  * \li Origin: Lgb, 22 Oct 2006
  * \endvar
  */
index 84395adec46ebadead9ae57c7ab8e02dd4fa18ce..195879ad17ecc04273521c3a70def239789ce544 100644 (file)
@@ -1699,13 +1699,18 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UNICODE_INSERT: {
                if (cmd.argument().empty())
                        break;
-               docstring hexstring = cmd.argument();
-               if (isHex(hexstring)) {
-                       char_type c = hexToInt(hexstring);
+               // splits on whitespace
+               vector<docstring> args =
+                       getVectorFromString(cmd.argument(), from_ascii(" "), false, true);
+               for (auto const & arg : args) {
+                       if (!isHex(arg)) {
+                               LYXERR0("Not a hexstring: " << arg);
+                               continue;
+                       }
+                       char_type c = hexToInt(arg);
                        if (c >= 32 && c < 0x10ffff) {
-                               lyxerr << "Inserting c: " << c << endl;
-                               docstring s = docstring(1, c);
-                               lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, s));
+                               LYXERR(Debug::KEY, "Inserting c: " << c);
+                               lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, docstring(1, c)));
                        }
                }
                break;
index a03aaefb168a38304e91042f1d076bc59d1a13bd..2ce31a45e7061aad927da980ea922f36c50ca5e9 100644 (file)
@@ -1249,14 +1249,19 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UNICODE_INSERT: {
                if (cmd.argument().empty())
                        break;
-               docstring hexstring = cmd.argument();
-               if (isHex(hexstring)) {
-                       char_type c = hexToInt(hexstring);
+               // splits on whitespace
+               vector<docstring> args =
+                       getVectorFromString(cmd.argument(), from_ascii(" "), false, true);
+               for (auto const & arg : args) {
+                       if (!isHex(arg)) {
+                               LYXERR0("Not a hexstring: " << arg);
+                               continue;
+                       }
+                       char_type c = hexToInt(arg);
                        if (c >= 32 && c < 0x10ffff) {
-                               docstring s = docstring(1, c);
                                FuncCode code = currentMode() == MATH_MODE ?
                                        LFUN_MATH_INSERT : LFUN_SELF_INSERT;
-                               lyx::dispatch(FuncRequest(code, s));
+                               lyx::dispatch(FuncRequest(code, docstring(1, c)));
                        }
                }
                break;
index 398bf8dd337ae1a1ff0adced2343b4a04114a81c..9bcff42afa1a2e89470d76daa96959140006a804 100644 (file)
@@ -326,6 +326,8 @@ docstring wrapParas(docstring const & str, int const indent = 0,
 /// If \p keepempty is true, empty strings will be pushed to the vector as well
 /// If \p trimit is true, leading and trailing whitespace will be trimmed from
 /// all values. Note that this can affect what counts as "empty".
+/// NOTE: If you want to split a string on whitespace, then do:
+///    getVectorFromString(str, " ", false, true);
 std::vector<std::string> const getVectorFromString(std::string const & str,
         std::string const & delim = std::string(","),
         bool keepempty = false, bool trimit = true);