]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetPhantom.cpp
Fix bad cursor positioning when entering an inset
[lyx.git] / src / insets / InsetPhantom.cpp
index deeb09744a3297cab3b008e325c4e2fbbf31510e..c6efe9a9c93416ddce6259b38d22ac5d73357819 100644 (file)
@@ -150,7 +150,7 @@ void InsetPhantom::draw(PainterInfo & pi, int x, int y) const
 
        // draw the inset marker
        drawMarkers(pi, x, y);
-       
+
        // draw the arrow(s)
        static int const arrow_size = 4;
        ColorCode const origcol = pi.base.font.color();
@@ -261,7 +261,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd)
        switch (cmd.action()) {
 
        case LFUN_INSET_MODIFY:
-               cur.recordUndoInset(ATOMIC_UNDO, this);
+               cur.recordUndoInset(this);
                string2params(to_utf8(cmd.argument()), params_);
                setButtonLabel();
                cur.forceBufferUpdate();
@@ -312,23 +312,23 @@ docstring InsetPhantom::toolTip(BufferView const &, int, int) const
 void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
 {
        if (runparams.moving_arg)
-               os << "\\protect";
+               os << "\\protect";
 
-    switch (params_.type) {
-    case InsetPhantomParams::Phantom:
+       switch (params_.type) {
+       case InsetPhantomParams::Phantom:
                os << "\\phantom{";
-        break;
-    case InsetPhantomParams::HPhantom:
+               break;
+       case InsetPhantomParams::HPhantom:
                os << "\\hphantom{";
-        break;
-    case InsetPhantomParams::VPhantom:
+               break;
+       case InsetPhantomParams::VPhantom:
                os << "\\vphantom{";
-        break;
-    default:
-        os << "\\phantom{";
-        break;
-    }
-    InsetCollapsable::latex(os, runparams);
+               break;
+       default:
+               os << "\\phantom{";
+               break;
+       }
+       InsetCollapsable::latex(os, runparams);
        os << "}";
 }
 
@@ -336,12 +336,20 @@ void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
 int InsetPhantom::plaintext(odocstringstream & os,
                            OutputParams const & runparams, size_t max_length) const
 {
-       if (params_.type == InsetPhantomParams::Phantom)
+       switch (params_.type) {
+       case InsetPhantomParams::Phantom:
                os << '[' << buffer().B_("phantom") << ":";
-       else if (params_.type == InsetPhantomParams::HPhantom)
+               break;
+       case InsetPhantomParams::HPhantom:
                os << '[' << buffer().B_("hphantom") << ":";
-       else if (params_.type == InsetPhantomParams::VPhantom)
+               break;
+       case InsetPhantomParams::VPhantom:
                os << '[' << buffer().B_("vphantom") << ":";
+               break;
+       default:
+               os << '[' << buffer().B_("phantom") << ":";
+               break;
+       }
        InsetCollapsable::plaintext(os, runparams, max_length);
        os << "]";
 
@@ -351,13 +359,15 @@ int InsetPhantom::plaintext(odocstringstream & os,
 
 int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const
 {
-       string cmdname;
-       if (params_.type == InsetPhantomParams::Phantom)
-               cmdname = "phantom";
-       else if (params_.type == InsetPhantomParams::HPhantom)
-               cmdname = "phantom";
-       else if (params_.type == InsetPhantomParams::VPhantom)
-               cmdname = "phantom";
+       docstring cmdname;
+       switch (params_.type) {
+       case InsetPhantomParams::Phantom:
+       case InsetPhantomParams::HPhantom:
+       case InsetPhantomParams::VPhantom:
+       default:
+               cmdname = from_ascii("phantom");
+               break;
+       }
        os << "<" + cmdname + ">";
        int const i = InsetCollapsable::docbook(os, runparams);
        os << "</" + cmdname + ">";