]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fixme comment.
[lyx.git] / src / Text3.cpp
index 6693e6297b29a320c3b38672586cd6d480ea76ca..11f5e4e9012b77683bd2a9680dc6fdd27f2b592b 100644 (file)
@@ -67,7 +67,6 @@
 
 #include "mathed/InsetMathHull.h"
 #include "mathed/MathMacroTemplate.h"
-#include "mathed/MathParser.h"
 
 #include <boost/next_prior.hpp>
 
@@ -1313,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);
 
@@ -1410,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();
@@ -1440,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
@@ -1873,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;
 
@@ -1986,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;
                }
@@ -2139,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;