+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:
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>
#include "FuncStatus.h"
+using std::string;
+
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_;
}
else
return (v_ & OFF);
}
+
+
+void FuncStatus::message(string const & m)
+{
+ message_ = m;
+}
+
+
+string const & FuncStatus::message() const
+{
+ return message_;
+}
#ifndef FUNC_STATUS_H
#define FUNC_STATUS_H
+#include <string>
+
/// The status of a function.
class FuncStatus
unsigned int v_;
+ std::string message_;
+
public:
///
FuncStatus();
- //
+ ///
void clear();
///
void operator|=(FuncStatus const & f);
void setOnOff(bool b);
///
bool onoff(bool b) const;
+
+ ///
+ void message(std::string const & m);
+ ///
+ std::string const & message() const;
};
#endif
buf = owner->buffer();
if (cmd.action == LFUN_NOACTION) {
- setStatusMessage(N_("Nothing to do"));
+ flag.message(N_("Nothing to do"));
flag.enabled(false);
return flag;
}
}
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;
default:
- cur.getStatus(cmd, flag);
- if (!flag.enabled())
+ if (!cur.getStatus(cmd, flag))
flag = view()->getStatus(cmd);
}
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);
}
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())
if (view()->cursor().inTexted()) {
view()->owner()->updateLayoutChoice();
- sendDispatchMessage(getMessage(), cmd);
}
}
+ sendDispatchMessage(getMessage(), cmd);
}
}
-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-".
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);
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,