]> git.lyx.org Git - features.git/commitdiff
Use FuncRequest::getArg instead of splitting the argument
authorRichard Heck <rikiheck@lyx.org>
Tue, 17 Apr 2018 02:32:04 +0000 (22:32 -0400)
committerRichard Heck <rikiheck@lyx.org>
Tue, 17 Apr 2018 02:32:04 +0000 (22:32 -0400)
ourselves.

src/Text3.cpp
src/mathed/InsetMathNest.cpp

index 195879ad17ecc04273521c3a70def239789ce544..833a7ed645340aa110571e32e1c4c1c689bf3e56 100644 (file)
@@ -1699,12 +1699,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UNICODE_INSERT: {
                if (cmd.argument().empty())
                        break;
-               // splits on whitespace
-               vector<docstring> args =
-                       getVectorFromString(cmd.argument(), from_ascii(" "), false, true);
-               for (auto const & arg : args) {
+               int i = 0;
+               while (true) {
+                       docstring const arg = from_utf8(cmd.getArg(i));
+                       if (arg.empty())
+                               break;
                        if (!isHex(arg)) {
                                LYXERR0("Not a hexstring: " << arg);
+                               ++i;
                                continue;
                        }
                        char_type c = hexToInt(arg);
@@ -1712,6 +1714,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                LYXERR(Debug::KEY, "Inserting c: " << c);
                                lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, docstring(1, c)));
                        }
+                       ++i;
                }
                break;
        }
index ec464134be53cb9728c184a8ee743d6407be3a72..6f415913b1250fd1b1fa0ef39e7258aca1319cd0 100644 (file)
@@ -1249,20 +1249,24 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UNICODE_INSERT: {
                if (cmd.argument().empty())
                        break;
-               // splits on whitespace
-               vector<docstring> args =
-                       getVectorFromString(cmd.argument(), from_ascii(" "), false, true);
-               for (auto const & arg : args) {
+               int i = 0;
+               while (true) {
+                       docstring const arg = from_utf8(cmd.getArg(i));
+                       if (arg.empty())
+                               break;
                        if (!isHex(arg)) {
                                LYXERR0("Not a hexstring: " << arg);
+                               ++i;
                                continue;
                        }
                        char_type c = hexToInt(arg);
                        if (c >= 32 && c < 0x10ffff) {
+                               LYXERR(Debug::KEY, "Inserting c: " << c);
                                FuncCode code = currentMode() == MATH_MODE ?
                                        LFUN_MATH_INSERT : LFUN_SELF_INSERT;
                                lyx::dispatch(FuncRequest(code, docstring(1, c)));
                        }
+                       ++i;
                }
                break;
        }