]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fixme comment.
[lyx.git] / src / Text3.cpp
index 22408657cb4ddcb97a7d58c88f9ec1cbff53e8a9..11f5e4e9012b77683bd2a9680dc6fdd27f2b592b 100644 (file)
@@ -67,7 +67,6 @@
 
 #include "mathed/InsetMathHull.h"
 #include "mathed/MathMacroTemplate.h"
-#include "mathed/MathParser.h"
 
 #include <boost/next_prior.hpp>
 
@@ -164,13 +163,12 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
                        istringstream is(selstr);
                        Lexer lex;
                        lex.setStream(is);
-                       mathed_parser_warn_contents(false);
-                       formula->read(lex);
+                       formula->readQuiet(lex);
                        if (formula->getType() == hullNone) {
                                // No valid formula, let's try with delims
                                is.str("$" + selstr + "$");
                                lex.setStream(is);
-                               formula->read(lex);
+                               formula->readQuiet(lex);
                                if (formula->getType() == hullNone) {
                                        // Still not valid, leave it as is
                                        valid = false;
@@ -180,7 +178,6 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
                                        cur.insert(formula);
                        } else
                                cur.insert(formula);
-                       mathed_parser_warn_contents(true);
                } else {
                        cur.insert(new MathMacroTemplate(sel));
                }
@@ -1315,10 +1312,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        cutSelection(cur, false, false);
 
                cur.clearSelection();
-               Font const old_font = cur.real_current_font;
 
                docstring::const_iterator cit = cmd.argument().begin();
-               docstring::const_iterator end = cmd.argument().end();
+               docstring::const_iterator const end = cmd.argument().end();
                for (; cit != end; ++cit)
                        bv->translateAndInsert(*cit, this, cur);
 
@@ -1412,10 +1408,18 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_FLOAT_INSERT:
        case LFUN_FLOAT_WIDE_INSERT:
        case LFUN_WRAP_INSERT: {
-               bool content = cur.selection();  // will some text be moved into the inset?
+               // will some text be moved into the inset?
+               bool content = cur.selection();
 
                doInsertInset(cur, this, cmd, true, true);
                cur.posForward();
+
+               // If some text is moved into the inset, doInsertInset 
+               // puts the cursor outside the inset. To insert the
+               // caption we put it back into the inset.
+               if (content)
+                       cur.backwardPos();
+
                ParagraphList & pars = cur.text()->paragraphs();
 
                DocumentClass const & tclass = bv->buffer().params().documentClass();
@@ -1442,7 +1446,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // We cannot use Cursor::dispatch here it needs access to up to
                // date metrics.
                FuncRequest cmd_caption(LFUN_CAPTION_INSERT);
-               cur.text()->dispatch(cur, cmd_caption);
+               doInsertInset(cur, cur.text(), cmd_caption, true, false);
+               updateLabels(bv->buffer());
                cur.updateFlags(Update::Force);
                // FIXME: When leaving the Float (or Wrap) inset we should
                // delete any empty paragraph left above or below the
@@ -1875,8 +1880,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
 {
        LASSERT(cur.text() == this, /**/);
 
-       Font const & font = cur.real_current_font;
-       FontInfo const & fontinfo = font.fontInfo();
+       FontInfo const & fontinfo = cur.real_current_font.fontInfo();
        bool enable = true;
        InsetCode code = NO_CODE;
 
@@ -1988,10 +1992,10 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                string s = cmd.getArg(0);
                InsetLayout il =
                        cur.buffer().params().documentClass().insetLayout(from_utf8(s));
-               if (il.lyxtype() != "charstyle" &&
-                   il.lyxtype() != "custom" &&
-                   il.lyxtype() != "element" &&
-                   il.lyxtype ()!= "standard")
+               if (il.lyxtype() != InsetLayout::CHARSTYLE &&
+                   il.lyxtype() != InsetLayout::CUSTOM &&
+                   il.lyxtype() != InsetLayout::ELEMENT &&
+                   il.lyxtype ()!= InsetLayout::STANDARD)
                        enable = false;
                break;
                }
@@ -2141,9 +2145,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
 
        case LFUN_INSET_DISSOLVE:
                if (!cmd.argument().empty()) {
-                       InsetLayout il = cur.inset().getLayout(cur.buffer().params());
+                       InsetLayout const & il = cur.inset().getLayout(cur.buffer().params());
+                       InsetLayout::InsetLyXType const type = 
+                                       translateLyXType(to_utf8(cmd.argument()));
                        enable = cur.inset().lyxCode() == FLEX_CODE
-                                && il.lyxtype() == to_utf8(cmd.argument());
+                                && il.lyxtype() == type;
                } else {
                        enable = !isMainText(cur.bv().buffer())
                                 && cur.inset().nargs() == 1;