From: Abdelrazak Younes Date: Sat, 3 Oct 2009 19:30:48 +0000 (+0000) Subject: Cleanups: X-Git-Tag: 2.0.0~5430 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f47cfcf48b6d752dbafae033cfe38063ceda56b9;p=features.git 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 --- diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 72bbee61ca..79d7ed2091 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -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 diff --git a/src/LyXFunc.h b/src/LyXFunc.h index c0fc35c4d0..d560b15f47 100644 --- a/src/LyXFunc.h +++ b/src/LyXFunc.h @@ -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