]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
Do not use \&@#^_~$ as lstinline delimiter, as suggested by Herbert
[lyx.git] / src / LyXFunc.cpp
index 490d0f6757e8f3e8f86b2446b76efec6a7379d94..33c724a7cdcf7fb98ba3ae36ad519e7b3facbe46 100644 (file)
@@ -67,6 +67,7 @@
 #include "insets/InsetERT.h"
 #include "insets/InsetExternal.h"
 #include "insets/InsetFloat.h"
+#include "insets/InsetListings.h"
 #include "insets/InsetGraphics.h"
 #include "insets/InsetInclude.h"
 #include "insets/InsetNote.h"
@@ -519,6 +520,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        case Inset::BOX_CODE:
                                enable = cmd.argument() == "box";
                                break;
+                       case Inset::LISTINGS_CODE:
+                               enable = cmd.argument() == "listings";
+                               break;
                        default:
                                break;
                }
@@ -546,6 +550,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        case LFUN_DIALOG_TOGGLE:
                flag.setOnOff(lyx_view_->getDialogs().visible(cmd.getArg(0)));
+               // fall through to set "enable"
        case LFUN_DIALOG_SHOW: {
                string const name = cmd.getArg(0);
                if (!buf)
@@ -557,7 +562,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        enable = Exporter::isExportable(*buf, "dvi")
                                && lyxrc.print_command != "none";
                else if (name == "character")
-                       enable = cur.inset().lyxCode() != Inset::ERT_CODE;
+                       enable = cur.inset().lyxCode() != Inset::ERT_CODE &&
+                               cur.inset().lyxCode() != Inset::LISTINGS_CODE;
                else if (name == "latexlog")
                        enable = isFileReadable(FileName(buf->getLogName().second));
                else if (name == "spellchecker")
@@ -572,7 +578,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        case LFUN_DIALOG_SHOW_NEW_INSET:
-               enable = cur.inset().lyxCode() != Inset::ERT_CODE;
+               enable = cur.inset().lyxCode() != Inset::ERT_CODE &&
+                       cur.inset().lyxCode() != Inset::LISTINGS_CODE;
                if (cur.inset().lyxCode() == Inset::CAPTION_CODE) {
                        FuncStatus flag;
                        if (cur.inset().getStatus(cur, cmd, flag))
@@ -616,6 +623,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
        }
 
+       case LFUN_TOOLBAR_TOGGLE: {
+               bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0));
+               flag.setOnOff(current);
+               break;
+       }
        // this one is difficult to get right. As a half-baked
        // solution, we consider only the first action of the sequence
        case LFUN_COMMAND_SEQUENCE: {
@@ -898,7 +910,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        docstring text = bformat(_("Any changes will be lost. Are you sure "
                                                             "you want to revert to the saved version of the document %1$s?"), file);
                        int const ret = Alert::prompt(_("Revert to saved document?"),
-                               text, 0, 1, _("&Revert"), _("&Cancel"));
+                               text, 1, 1, _("&Revert"), _("&Cancel"));
 
                        if (ret == 0)
                                reloadBuffer();
@@ -1316,6 +1328,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        } else if (name == "float") {
                                InsetFloatParams p;
                                data = InsetFloatMailer::params2string(p);
+                       } else if (name == "listings") {
+                               InsetListingsParams p;
+                               data = InsetListingsMailer::params2string(p);
                        } else if (name == "graphics") {
                                InsetGraphicsParams p;
                                Buffer const & buffer = *lyx_view_->buffer();
@@ -1398,18 +1413,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        FileName const filename =
                                makeAbsPath(argument, lyx_view_->buffer()->filePath());
-                       setMessage(bformat(_("Opening child document %1$s..."),
-                                          makeDisplayPath(filename.absFilename())));
                        view()->saveBookmark(false);
                        string const parentfilename = lyx_view_->buffer()->fileName();
                        if (theBufferList().exists(filename.absFilename()))
                                lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename()));
                        else
-                               lyx_view_->loadLyXFile(filename);
-                       // Set the parent name of the child document.
-                       // This makes insertion of citations and references in the child work,
-                       // when the target is in the parent or another child document.
-                       lyx_view_->buffer()->setParentName(parentfilename);
+                               if (lyx_view_->loadLyXFile(filename)) {
+                                       // Set the parent name of the child document.
+                                       // This makes insertion of citations and references in the child work,
+                                       // when the target is in the parent or another child document.
+                                       lyx_view_->buffer()->setParentName(parentfilename);
+                                       setMessage(bformat(_("Opening child document %1$s..."),
+                                                makeDisplayPath(filename.absFilename())));
+                               } else
+                                       setMessage(_("Document not loaded."));
                        break;
                }
 
@@ -1742,6 +1759,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        lyx_view_->toggleToolbarState(argument);
                        break;
 
+               case LFUN_TOOLBAR_TOGGLE: {
+                       BOOST_ASSERT(lyx_view_);
+                       string const name = to_utf8(cmd.argument());
+                       bool const current = lyx_view_->getToolbars().visible(name);
+                       lyx_view_->getToolbars().display(name, !current);
+                       break;
+               }
+
                default: {
                        BOOST_ASSERT(lyx_view_);
                        view()->cursor().dispatch(cmd);