]> git.lyx.org Git - lyx.git/commitdiff
correctly display messages issued by getStatus
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 25 Nov 2004 09:15:26 +0000 (09:15 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 25 Nov 2004 09:15:26 +0000 (09:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9303 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/FuncStatus.C
src/FuncStatus.h
src/lyxfunc.C
src/lyxfunc.h

index 4995fc3697a24d95a65c16e9a1b06239be681a1a..6e03fbe666e5eb957bad0a2ff53f631ace9f964c 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-24  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * lyxfunc.C (getStatus, dispatch): use FuncStatus::message; only
+       call BufferView::getStatus if LCursor::getStatus did nothing
+       (setStatusMessage, getStatusMessage): removed.
+
+       * FuncStatus.C (message): new methods. Used to provide an error
+       message indicating why a command is disabled.
+       (clear, |=, FuncStatus): update for message.
+       
+2004-11-23  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * lyxfunc.C (dispatch): always call sendDispatchMessage
+       
 2004-11-24  Alfredo Braunstein  <abraunst@lyx.org>
 
        * BufferView.C:
@@ -36,7 +50,7 @@
 2004-11-22  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * lyxfind.C (findNextChange): update the bufferview after setting
-       the selection
+       the selection.
 
 2004-11-16  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
index 3e0c615096db04054d8f63173b824a315c20c5a5..2f0cf8e064bd3792cc37e6bdd91fd2c595f7f247 100644 (file)
@@ -12,6 +12,8 @@
 
 #include "FuncStatus.h"
 
+using std::string;
+
 FuncStatus::FuncStatus() : v_(OK)
 {
 }
@@ -20,12 +22,15 @@ FuncStatus::FuncStatus() : v_(OK)
 void FuncStatus::clear()
 {
        v_ = OK;
+       message_.erase();
 }
 
 
 void FuncStatus::operator|=(FuncStatus const & f)
 {
        v_ |= f.v_;
+       if (!f.message_.empty())
+               message_ = f.message_;
 }
 
 
@@ -73,3 +78,15 @@ bool FuncStatus::onoff(bool b) const
        else
                return (v_ & OFF);
 }
+
+
+void FuncStatus::message(string const & m)
+{
+       message_ = m;
+}
+
+
+string const & FuncStatus::message() const
+{
+       return message_;
+}
index c9629112de4b76f7cbc6671779190e5de40077e3..3f5d7b14c1293de2ae12af30751c849c96783568 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef FUNC_STATUS_H
 #define FUNC_STATUS_H
 
+#include <string>
+
 /// The status of a function.
 
 class FuncStatus
@@ -33,10 +35,12 @@ private:
 
        unsigned int v_;
 
+       std::string message_;
+
 public:
        ///
        FuncStatus();
-       //
+       ///
        void clear();
        ///
        void operator|=(FuncStatus const & f);
@@ -54,6 +58,11 @@ public:
        void setOnOff(bool b);
        ///
        bool onoff(bool b) const;
+
+       ///
+       void message(std::string const & m);
+       ///
+       std::string const & message() const;
 };
 
 #endif
index b5c3ad161bf90a3a99a692beb678cb354d1738b3..fb7343aab1542eb94adec58a41753ef5c4dc1a49 100644 (file)
@@ -286,7 +286,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                buf = owner->buffer();
 
        if (cmd.action == LFUN_NOACTION) {
-               setStatusMessage(N_("Nothing to do"));
+               flag.message(N_("Nothing to do"));
                flag.enabled(false);
                return flag;
        }
@@ -304,19 +304,19 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        if (flag.unknown()) {
-               setStatusMessage(N_("Unknown action"));
+               flag.message(N_("Unknown action"));
                return flag;
        }
 
        // the default error message if we disable the command
-       setStatusMessage(N_("Command disabled"));
+       flag.message(N_("Command disabled"));
        if (!flag.enabled())
                return flag;
 
        // Check whether we need a buffer
        if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
                // no, exit directly
-               setStatusMessage(N_("Command not allowed with"
+               flag.message(N_("Command not allowed with"
                                    "out any document open"));
                flag.enabled(false);
                return flag;
@@ -522,8 +522,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        default:
 
-               cur.getStatus(cmd, flag);
-               if (!flag.enabled())
+               if (!cur.getStatus(cmd, flag))
                        flag = view()->getStatus(cmd);
        }
 
@@ -534,7 +533,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        if (buf && buf->isReadonly()
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
            && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
-               setStatusMessage(N_("Document is read-only"));
+               flag.message(N_("Document is read-only"));
                flag.enabled(false);
        }
 
@@ -615,14 +614,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
        bool update = true;
 
-       // We cannot use this function here
-       if (!getStatus(cmd).enabled()) {
+       FuncStatus const flag = getStatus(cmd);
+       if (!flag.enabled()) {
+               // We cannot use this function here
                lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
                       << lyxaction.getActionName(action)
                       << " [" << action << "] is disabled at this location"
                       << endl;
-               setErrorMessage(getStatusMessage());
-
+               setErrorMessage(flag.message());
        } else {
 
                if (view()->available())
@@ -1477,9 +1476,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                if (view()->cursor().inTexted()) {
                        view()->owner()->updateLayoutChoice();
-                       sendDispatchMessage(getMessage(), cmd);
                }
        }
+       sendDispatchMessage(getMessage(), cmd);
 }
 
 
@@ -1779,12 +1778,6 @@ void LyXFunc::setMessage(string const & m) const
 }
 
 
-void LyXFunc::setStatusMessage(string const & m) const
-{
-       status_buffer = m;
-}
-
-
 string const LyXFunc::viewStatusMessage()
 {
        // When meta-fake key is pressed, show the key sequence so far + "M-".
index 5b9a57bd7b096b9edf61c6bbb2b867ef777a1795..0bc95eb9ac8ac6169ea59862abd818e6b83edadd 100644 (file)
@@ -64,12 +64,8 @@ public:
        void setMessage(std::string const & m) const;
        /// Buffer to store result messages
        void setErrorMessage(std::string const &) const;
-       /// Buffer to store result messages from getStatus
-       void setStatusMessage(std::string const &) const;
        /// Buffer to store result messages
        std::string const getMessage() const { return dispatch_buffer; }
-       /// Buffer to store result messages
-       std::string const getStatusMessage() const { return status_buffer; }
        /// Handle a accented char key sequence
        void handleKeyFunc(kb_action action);
 
@@ -98,8 +94,6 @@ private:
            good reason to have this one as static in Dispatch? (Ale)
        */
        mutable std::string dispatch_buffer;
-       /// Buffer to store messages and result data from getStatus
-       mutable std::string status_buffer;
 
        /// send a post-dispatch status message
        void sendDispatchMessage(std::string const & msg,