]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathNest.cpp
Coding style
[lyx.git] / src / mathed / InsetMathNest.cpp
index 8c470759d5e7f836ca8eb5bb19e5f09198ceae41..c9fdc1abc6e9e7574bcf329c969b4a91d9dc587b 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();
 }
@@ -940,6 +929,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                // ignore math-mode on when already in math mode
                if (currentMode() == Inset::MATH_MODE && cmd.argument() == "on")
                        break;
+               cur.recordUndoSelection();
                cur.macroModeClose();
                docstring const save_selection = grabAndEraseSelection(cur);
                selClearOrDel(cur);
@@ -950,6 +940,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.niceInsert(save_selection);
 #else
                if (currentMode() == Inset::TEXT_MODE) {
+                       cur.recordUndoSelection();
                        cur.niceInsert(MathAtom(new InsetMathHull("simple")));
                        cur.message(_("create new math text environment ($...$)"));
                } else {
@@ -1824,12 +1815,12 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        // fill in global macros
        macros.clear();
        MacroTable::globalMacros().getMacroNames(macros);
-       lyxerr << "Globals completion macros: ";
+       //lyxerr << "Globals completion macros: ";
        for (it = macros.begin(); it != macros.end(); ++it) {
-               lyxerr << "\\" + *it << " ";
+               //lyxerr << "\\" + *it << " ";
                globals.push_back("\\" + *it);
        }
-       lyxerr << std::endl;
+       //lyxerr << std::endl;
 
        // fill in global commands
        globals.push_back(from_ascii("\\boxed"));
@@ -1845,6 +1836,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        globals.push_back(from_ascii("\\alignedat"));
        globals.push_back(from_ascii("\\cases"));
        globals.push_back(from_ascii("\\substack"));
+       globals.push_back(from_ascii("\\xymatrix"));
        globals.push_back(from_ascii("\\subarray"));
        globals.push_back(from_ascii("\\array"));
        globals.push_back(from_ascii("\\sqrt"));
@@ -1879,12 +1871,12 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        globals.push_back(from_ascii("\\vphantom"));
        MathWordList const & words = mathedWordList();
        MathWordList::const_iterator it2;
-       lyxerr << "Globals completion commands: ";
+       //lyxerr << "Globals completion commands: ";
        for (it2 = words.begin(); it2 != words.end(); ++it2) {
                globals.push_back("\\" + (*it2).first);
-               lyxerr << "\\" + (*it2).first << " ";
+               //lyxerr << "\\" + (*it2).first << " ";
        }
-       lyxerr << std::endl;
+       //lyxerr << std::endl;
        sort(globals.begin(), globals.end());
 }