]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
bug 183
[lyx.git] / src / lyxfunc.C
index c76ebbdd9ccf82295d657bb4c23415bf1232df5d..26c1f9fa9d3399273bfc4e7b6146e363ccb39461 100644 (file)
@@ -354,7 +354,7 @@ FuncStatus LyXFunc::getStatus(kb_action action,
        Buffer * buf = owner->buffer();
        
        if (action == LFUN_UNKNOWN_ACTION) {
-               setErrorMessage(N_("Unknown action"));
+               setStatusMessage(N_("Unknown action"));
                return flag.unknown(true);
        }
        
@@ -368,12 +368,12 @@ FuncStatus LyXFunc::getStatus(kb_action action,
                            !lyxaction.funcHasFlag(action,
                                                   LyXAction::ReadOnly)) {
                                // no
-                               setErrorMessage(N_("Document is read-only"));
+                               setStatusMessage(N_("Document is read-only"));
                                flag.disabled(true);
                        }
                } else {
                        // no
-                       setErrorMessage(N_("Command not allowed with"
+                       setStatusMessage(N_("Command not allowed with"
                                           "out any document open"));
                        return flag.disabled(true);
                }
@@ -756,16 +756,11 @@ void LyXFunc::miniDispatch(string const & s)
 
 void const LyXFunc::verboseDispatch(string const & s, bool show_sc) 
 {
-       // Split command string into command and argument
-       string cmd;
-       string line = frontStrip(s);
-       string const arg = strip(frontStrip(split(line, cmd, ' ')));
-
-       int action = lyxaction.LookupFunc(cmd);
+       int action = lyxaction.LookupFunc(frontStrip(s));
  
        if (action == LFUN_UNKNOWN_ACTION) {
                string const msg = string(_("Unknown function ("))
-                       + cmd + ")";
+                       + s + ")";
                owner->message(msg);
        } else {
                verboseDispatch(action, show_sc);
@@ -869,6 +864,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                       << lyxaction.getActionName(action)
                       << " [" << action << "] is disabled at this location"
                       << endl;
+               setErrorMessage(getStatusMessage());
                goto exit_with_message;
        }
 
@@ -884,36 +880,36 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                        // Undo/Redo is a bit tricky for insets.
                        if (action == LFUN_UNDO) {
                                owner->view()->menuUndo();
-                               return string();
+                               goto exit_with_message;
                        } else if (action == LFUN_REDO) {
                                owner->view()->menuRedo();
-                               return string();
+                               goto exit_with_message;
                        } else if (((result=owner->view()->theLockingInset()->
                                     localDispatch(owner->view(), action, argument)) ==
                                    UpdatableInset::DISPATCHED) ||
                                   (result == UpdatableInset::DISPATCHED_NOUPDATE))
-                               return string();
+                               goto exit_with_message;
                        else if (result == UpdatableInset::FINISHED) {
                                        if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
                                                TEXT()->cursorRight(owner->view());
                                                moveCursorUpdate(true, false);
                                                owner->showState();
                                        }
-                                       return string();
+                                       goto exit_with_message;
                        } else if (result == UpdatableInset::FINISHED_RIGHT) {
                                if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
                                        TEXT()->cursorRight(owner->view());
                                        moveCursorUpdate(true, false);
                                        owner->showState();
                                }
-                               return string();
+                               goto exit_with_message;
                        } else if (result == UpdatableInset::FINISHED_UP) {
                                if (TEXT()->cursor.row()->previous()) {
                                        TEXT()->cursorUp(owner->view());
                                        moveCursorUpdate(true, false);
                                        owner->showState();
                                }
-                               return string();
+                               goto exit_with_message;
                        } else if (result == UpdatableInset::FINISHED_DOWN) {
                                if (TEXT()->cursor.row()->next())
                                        TEXT()->cursorDown(owner->view());
@@ -921,7 +917,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                                        TEXT()->cursorRight(owner->view());
                                moveCursorUpdate(true, false);
                                owner->showState();
-                               return string();
+                               goto exit_with_message;
                        } else {
                                //setMessage(N_("Text mode"));
                                switch (action) {
@@ -938,14 +934,14 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                                                moveCursorUpdate(true, false);
                                                owner->showState();
                                        }
-                                       return string();
+                                       goto exit_with_message;
                                case LFUN_LEFT: 
                                        if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
                                                TEXT()->cursorRight(owner->view());
                                                moveCursorUpdate(true, false);
                                                owner->showState();
                                        }
-                                       return string();
+                                       goto exit_with_message;
                                case LFUN_DOWN:
                                        if (TEXT()->cursor.row()->next())
                                                TEXT()->cursorDown(owner->view());
@@ -953,7 +949,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                                                TEXT()->cursorRight(owner->view());
                                        moveCursorUpdate(true, false);
                                        owner->showState();
-                                       return string();
+                                       goto exit_with_message;
                                default:
                                        break;
                                }
@@ -1632,7 +1628,9 @@ exit_with_message:
 
        if (!res.empty())
                owner->message(_(res));
-
+       owner->updateMenubar();
+       owner->updateToolbar();
+       
        return res;
 }
 
@@ -1661,9 +1659,9 @@ void LyXFunc::menuNew(bool fromTemplate)
        if (lyxrc.new_ask_filename) {
                FileDialog fileDlg(owner, _("Enter filename for new document"),
                                   LFUN_SELECT_FILE_SYNC,
-                       make_pair(string(_("Documents")),
+                       make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
-                       make_pair(string(_("Templates")),
+                       make_pair(string(_("Templates|#T#t")),
                                  string(lyxrc.template_path)));
 
                FileDialog::Result result =
@@ -1745,9 +1743,9 @@ void LyXFunc::menuNew(bool fromTemplate)
        if (fromTemplate) {
                FileDialog fileDlg(owner, _("Select template file"),
                        LFUN_SELECT_FILE_SYNC,
-                       make_pair(string(_("Documents")),
+                       make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
-                       make_pair(string(_("Templates")),
+                       make_pair(string(_("Templates|#T#t")),
                                  string(lyxrc.template_path)));
 
                FileDialog::Result result =
@@ -1786,9 +1784,9 @@ void LyXFunc::open(string const & fname)
        if (fname.empty()) {
                FileDialog fileDlg(owner, _("Select document to open"),
                        LFUN_FILE_OPEN,
-                       make_pair(string(_("Documents")),
+                       make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
-                       make_pair(string(_("Examples")),
+                       make_pair(string(_("Examples|#E#e")),
                                  string(AddPath(system_lyxdir, "examples"))));
 
                FileDialog::Result result =
@@ -1863,9 +1861,9 @@ void LyXFunc::doImport(string const & argument)
 
                FileDialog fileDlg(owner, text, 
                        LFUN_IMPORT,
-                       make_pair(string(_("Documents")),
+                       make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
-                       make_pair(string(_("Examples")),
+                       make_pair(string(_("Examples|#E#e")),
                                  string(AddPath(system_lyxdir, "examples"))));
                        
                string const extension = "*." + formats.extension(format)
@@ -1965,12 +1963,18 @@ void LyXFunc::setErrorMessage(string const & m) const
 }
 
 
-void LyXFunc::setMessage(string const & m)
+void LyXFunc::setMessage(string const & m) const 
 {
        dispatch_buffer = m;
 }
 
 
+void LyXFunc::setStatusMessage(string const & m) const
+{
+       status_buffer = m;
+}
+
+
 void LyXFunc::initMiniBuffer() 
 {
        string text = _("Welcome to LyX!");