Cleanups:

Remove dead code and make sendDispatchMessage() a local function.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31493 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-10-03 19:30:48 +00:00
parent d38ca04ff7
commit f47cfcf48b
2 changed files with 45 additions and 57 deletions

View File

@ -496,6 +496,49 @@ namespace {
void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
/// send a post-dispatch status message
docstring sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
{
const bool verbose = (cmd.origin == FuncRequest::MENU
|| cmd.origin == FuncRequest::TOOLBAR
|| cmd.origin == FuncRequest::COMMANDBUFFER);
if (cmd.action == LFUN_SELF_INSERT || !verbose) {
LYXERR(Debug::ACTION, "dispatch msg is " << msg);
return msg;
}
docstring dispatch_msg = msg;
if (!dispatch_msg.empty())
dispatch_msg += ' ';
docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
bool argsadded = false;
if (!cmd.argument().empty()) {
if (cmd.action != LFUN_UNKNOWN_ACTION) {
comname += ' ' + cmd.argument();
argsadded = true;
}
}
docstring const shortcuts = theTopLevelKeymap().
printBindings(cmd, KeySequence::ForGui);
if (!shortcuts.empty())
comname += ": " + shortcuts;
else if (!argsadded && !cmd.argument().empty())
comname += ' ' + cmd.argument();
if (!comname.empty()) {
comname = rtrim(comname);
dispatch_msg += '(' + rtrim(comname) + ')';
}
LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
return dispatch_msg;
}
} //namespace anon
@ -730,11 +773,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
if (lv == 0)
break;
Buffer * doc_buffer = (lv && lv->documentBufferView())
? &(lv->documentBufferView()->buffer()) : 0;
if (doc_buffer && !theBufferList().isLoaded(doc_buffer))
doc_buffer = 0;
// Let the current LyXView dispatch its own actions.
if (lv->dispatch(cmd)) {
BufferView * bv = lv->currentBufferView();
@ -846,58 +884,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
if (lv) {
// Some messages may already be translated, so we cannot use _()
sendDispatchMessage(translateIfPossible(getMessage()), cmd);
lv->message(sendDispatchMessage(
translateIfPossible(getMessage()), cmd));
}
}
void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
{
const bool verbose = (cmd.origin == FuncRequest::MENU
|| cmd.origin == FuncRequest::TOOLBAR
|| cmd.origin == FuncRequest::COMMANDBUFFER);
LyXView * lv = theApp()->currentWindow();
if (cmd.action == LFUN_SELF_INSERT || !verbose) {
LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
if (!msg.empty())
lv->message(msg);
return;
}
docstring dispatch_msg = msg;
if (!dispatch_msg.empty())
dispatch_msg += ' ';
docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
bool argsadded = false;
if (!cmd.argument().empty()) {
if (cmd.action != LFUN_UNKNOWN_ACTION) {
comname += ' ' + cmd.argument();
argsadded = true;
}
}
docstring const shortcuts = theTopLevelKeymap().printBindings(cmd, KeySequence::ForGui);
if (!shortcuts.empty())
comname += ": " + shortcuts;
else if (!argsadded && !cmd.argument().empty())
comname += ' ' + cmd.argument();
if (!comname.empty()) {
comname = rtrim(comname);
dispatch_msg += '(' + rtrim(comname) + ')';
}
LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
if (!dispatch_msg.empty())
lv->message(dispatch_msg);
}
// Each LyXView should have it's own message method. lyxview and
// the minibuffer would use the minibuffer, but lyxserver would
// send an ERROR signal to its client. Alejandro 970603

View File

@ -107,10 +107,6 @@ private:
good reason to have this one as static in Dispatch? (Ale)
*/
mutable docstring dispatch_buffer;
/// send a post-dispatch status message
void sendDispatchMessage(docstring const & msg,
FuncRequest const & ev);
};
/// Implementation is in LyX.cpp