]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
Fix bug 886 and others not reported related with the document paper size.
[lyx.git] / src / lyxfunc.C
index 57bd08c78862eb7c06499c5ac47dcecf86f11c79..a679f52b4bb2ebd19bd10c2a03ca3f65b46f3ad4 100644 (file)
@@ -428,12 +428,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                enable = false;
                if (!cur)
                        break;
-               UpdatableInset * inset = cur.inset().asUpdatableInset();
-               lyxerr << "inset: " << inset << endl;
-               if (!inset)
-                       break;
-
-               InsetBase::Code code = inset->lyxCode();
+               InsetBase::Code code = cur.inset().lyxCode();
                switch (code) {
                        case InsetBase::TABULAR_CODE:
                                enable = cmd.argument == "tabular";
@@ -957,7 +952,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        break;
 
                case LFUN_QUIT:
-                       QuitLyX();
+                       QuitLyX(argument == "force");
                        break;
 
                case LFUN_TOCVIEW: {
@@ -1455,6 +1450,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_TEXTCLASS_APPLY: {
+                       recordUndoFullDocument(view());
                        Buffer * buffer = owner->buffer();
 
                        lyx::textclass_type const old_class =
@@ -1474,11 +1470,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                break;
 
                        owner->message(_("Converting document to new document class..."));
+                       StableDocIterator backcur(view()->cursor());
                        ErrorList el;
                        lyx::cap::SwitchBetweenClasses(
                                old_class, new_class,
                                buffer->paragraphs(), el);
 
+                       view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
                        bufferErrors(*buffer, el);
                        view()->showErrorList(_("Class switch"));
                        updateCounters(*buffer);
@@ -1510,10 +1508,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                default: {
                        view()->cursor().dispatch(cmd);
                        update |= view()->cursor().result().update();
-                       if (!view()->cursor().result().dispatched()) {
+                       if (!view()->cursor().result().dispatched())
                                update |= view()->dispatch(cmd);
-                       }
-
                        break;
                }
                }
@@ -1522,7 +1518,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        // Redraw screen unless explicitly told otherwise.
                        // This also initializes the position cache for all insets
                        // in (at least partially) visible top-level paragraphs.
-                       view()->update(true, update);
+                       if (update)
+                               view()->update(Update::FitCursor | Update::Force);
+                       else
+                               view()->update(Update::FitCursor);
 
                        // if we executed a mutating lfun, mark the buffer as dirty
                        // FIXME: Why not use flag.enabled() but call getStatus again?
@@ -1572,15 +1571,14 @@ void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd)
 
        string const shortcuts = toplevel_keymap->printbindings(cmd);
 
-       if (!shortcuts.empty()) {
+       if (!shortcuts.empty())
                comname += ": " + shortcuts;
-       } else if (!argsadded && !cmd.argument.empty()) {
+       else if (!argsadded && !cmd.argument.empty())
                comname += ' ' + cmd.argument;
-       }
 
        if (!comname.empty()) {
                comname = rtrim(comname);
-               dispatch_msg += '(' + comname + ')';
+               dispatch_msg += '(' + rtrim(comname) + ')';
        }
 
        lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;