]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
InsetMathHull.cpp: whitespace
[lyx.git] / src / mathed / InsetMathNest.cpp
index a2da9d0d14e541398b787e6adfcadad5da09dfa6..c77b24068f3bdc616fb0bc34013b6ba61b54b284 100644 (file)
@@ -73,11 +73,6 @@ using cap::cutSelection;
 using cap::replaceSelection;
 using cap::selClearOrDel;
 
-char const * text_commands[] =
-{ "text", "textrm", "textsf", "texttt", "textmd", "textbf", "textup", "textit",
-  "textsl", "textsc" };
-int const num_text_commands = sizeof(text_commands) / sizeof(*text_commands);
-
 
 InsetMathNest::InsetMathNest(idx_type nargs)
        : cells_(nargs), lock_(false), mouse_hover_(false)
@@ -341,14 +336,8 @@ MathData InsetMathNest::glue() const
 
 void InsetMathNest::write(WriteStream & os) const
 {
-       bool oldmode = os.textMode();
-       docstring const latex_name = name().c_str();
-       for (int i = 0; i < num_text_commands; ++i) {
-               if (latex_name == from_ascii(text_commands[i])) {
-                       os.textMode(true);
-                       break;
-               }
-       }
+       ModeSpecifier specifier(os, currentMode());
+       docstring const latex_name = name();
        os << '\\' << latex_name;
        for (size_t i = 0; i < nargs(); ++i)
                os << '{' << cell(i) << '}';
@@ -358,13 +347,12 @@ void InsetMathNest::write(WriteStream & os) const
                os << "\\lyxlock";
                os.pendingSpace(true);
        }
-       os.textMode(oldmode);
 }
 
 
 void InsetMathNest::normalize(NormalStream & os) const
 {
-       os << '[' << name().c_str();
+       os << '[' << name();
        for (size_t i = 0; i < nargs(); ++i)
                os << ' ' << cell(i);
        os << ']';
@@ -373,7 +361,8 @@ void InsetMathNest::normalize(NormalStream & os) const
 
 int InsetMathNest::latex(odocstream & os, OutputParams const & runparams) const
 {
-       WriteStream wi(os, runparams.moving_arg, true, runparams.dryrun);
+       WriteStream wi(os, runparams.moving_arg, true, runparams.dryrun,
+                       runparams.encoding);
        write(wi);
        return wi.line();
 }
@@ -931,11 +920,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                else
                        handleFont(cur, cmd.argument(), "mathbb");
                break;
-       /*
-       case LFUN_FONT_FREE_APPLY:
-               handleFont(cur, cmd.argument(), "textrm");
-               break;
-       */
        case LFUN_FONT_DEFAULT:
                handleFont(cur, cmd.argument(), "textnormal");
                break;
@@ -965,12 +949,11 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_MATH_SIZE:
-#if 0
-               cur.recordUndoSelection();
-               cur.setSize(arg);
-#endif
+       case LFUN_MATH_SIZE: {
+               FuncRequest fr = FuncRequest(LFUN_MATH_INSERT, cmd.argument());
+               doDispatch(cur, fr);
                break;
+       }
 
        case LFUN_MATH_MATRIX: {
                cur.recordUndo();
@@ -1034,11 +1017,18 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_SPACE_INSERT:
-       case LFUN_MATH_SPACE:
                cur.recordUndoSelection();
                cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
                break;
 
+       case LFUN_MATH_SPACE:
+               cur.recordUndoSelection();
+               if (cmd.argument().empty())
+                       cur.insert(MathAtom(new InsetMathSpace(from_ascii(","))));
+               else
+                       cur.insert(MathAtom(new InsetMathSpace(cmd.argument())));
+               break;
+
        case LFUN_ERT_INSERT:
                // interpret this as if a backslash was typed
                cur.recordUndo();