]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.C
make it compile again (hopefully)
[lyx.git] / src / mathed / InsetMathNest.C
index ccda9eb5493c75088c5be0a1e756a9098a8d1206..2ca97cde51311f60c3e99cd6a0769f6ad1b3ff71 100644 (file)
@@ -62,6 +62,7 @@
 
 using lyx::CoordCache;
 using lyx::docstring;
+using lyx::odocstream;
 using lyx::Point;
 
 using lyx::cap::copySelection;
@@ -208,13 +209,15 @@ bool InsetMathNest::idxLast(LCursor & cur) const
 
 void InsetMathNest::dump() const
 {
-       WriteStream os(lyxerr);
+       lyx::odocstringstream oss;
+       WriteStream os(oss);
        os << "---------------------------------------------\n";
        write(os);
        os << "\n";
        for (idx_type i = 0, n = nargs(); i != n; ++i)
                os << cell(i) << "\n";
        os << "---------------------------------------------\n";
+       lyxerr << lyx::to_utf8(oss.str());
 }
 
 
@@ -348,7 +351,7 @@ void InsetMathNest::normalize(NormalStream & os) const
 }
 
 
-int InsetMathNest::latex(Buffer const &, std::ostream & os,
+int InsetMathNest::latex(Buffer const &, odocstream & os,
                        OutputParams const & runparams) const
 {
        WriteStream wi(os, runparams.moving_arg, true);
@@ -702,15 +705,9 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
                                cur.posLeft();
                                cur.pushLeft(*cur.nextInset());
                        }
-               // FIXME: Change to
-               // } else if (!interpret(cur, cmd.argument()[0])) {
-               // when interpret accepts UCS4 characters
-               } else {
-                       std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
-                       if (!interpretChar(cur, arg0[0])) {
-                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
-                               cur.undispatched();
-                       }
+               } else if (!interpretChar(cur, cmd.argument()[0])) {
+                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                       cur.undispatched();
                }
                break;
 
@@ -937,8 +934,7 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_MATH_INSERT: {
                recordUndo(cur, Undo::ATOMIC);
                if (cmd.argument() == "^" || cmd.argument() == "_") {
-                       std::string arg0 = lyx::to_utf8(docstring(1, cmd.argument()[0]));
-                       interpretChar(cur, arg0[0]);
+                       interpretChar(cur, cmd.argument()[0]);
                } else
                        cur.niceInsert(lyx::to_utf8(cmd.argument()));
                break;
@@ -1166,7 +1162,7 @@ void InsetMathNest::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
 }
 
 
-bool InsetMathNest::interpretChar(LCursor & cur, char c)
+bool InsetMathNest::interpretChar(LCursor & cur, lyx::char_type c)
 {
        //lyxerr << "interpret 2: '" << c << "'" << endl;
        string save_selection;
@@ -1189,7 +1185,7 @@ bool InsetMathNest::interpretChar(LCursor & cur, char c)
                }
 
                if (isalpha(c)) {
-                       cur.activeMacro()->setName(name + c);
+                       cur.activeMacro()->setName(name + lyx::to_ascii(docstring(1, c)));
                        return true;
                }
 
@@ -1210,16 +1206,16 @@ bool InsetMathNest::interpretChar(LCursor & cur, char c)
                                cur.niceInsert(MathAtom(new InsetMathComment));
                        } else if (c == '#') {
                                BOOST_ASSERT(cur.activeMacro());
-                               cur.activeMacro()->setName(name + c);
+                               cur.activeMacro()->setName(name + lyx::to_ascii(docstring(1, c)));
                        } else {
                                cur.backspace();
-                               cur.niceInsert(createInsetMath(string(1, c)));
+                               cur.niceInsert(createInsetMath(lyx::to_ascii(docstring(1, c))));
                        }
                        return true;
                }
 
                // One character big delimiters. The others are handled in
-               // the other interpret() method.
+               // interpretString().
                latexkeys const * l = in_word_set(name.substr(1));
                if (name[0] == '\\' && l && l->inset == "big") {
                        string delim;
@@ -1231,7 +1227,7 @@ bool InsetMathNest::interpretChar(LCursor & cur, char c)
                                delim = "\\}";
                                break;
                        default:
-                               delim = string(1, c);
+                               delim = lyx::to_ascii(docstring(1, c));
                                break;
                        }
                        if (InsetMathBig::isBigInsetDelim(delim)) {
@@ -1326,7 +1322,7 @@ bool InsetMathNest::interpretChar(LCursor & cur, char c)
 
        if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
            c == '%' || c == '_' || c == '^') {
-               cur.niceInsert(createInsetMath(string(1, c)));
+               cur.niceInsert(createInsetMath(lyx::to_ascii(docstring(1, c))));
                return true;
        }