diff --git a/src/FuncRequest.h b/src/FuncRequest.h index 7fd3e1222f..175eb59fd1 100644 --- a/src/FuncRequest.h +++ b/src/FuncRequest.h @@ -35,6 +35,7 @@ public: TOOLBAR, // A toolbar icon KEYBOARD, // a keyboard binding COMMANDBUFFER, + LYXSERVER, TOC }; diff --git a/src/Server.cpp b/src/Server.cpp index fed89ace5b..1e673e6f87 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -1173,10 +1173,10 @@ void Server::callback(string const & msg) // connect to the lyxfunc in the single GuiView we // support currently. (Lgb) - FuncRequest const fr(lyxaction.lookupFunc(cmd), arg); + FuncRequest fr(lyxaction.lookupFunc(cmd), arg); + fr.setOrigin(FuncRequest::LYXSERVER); DispatchResult dr; theApp()->dispatch(fr, dr); - theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); string const rval = to_utf8(dr.message()); // all commands produce an INFO or ERROR message diff --git a/src/ServerSocket.cpp b/src/ServerSocket.cpp index 7940b7fc38..7b9d6df5af 100644 --- a/src/ServerSocket.cpp +++ b/src/ServerSocket.cpp @@ -141,9 +141,10 @@ void ServerSocket::dataCallback(int fd) string const key = line.substr(0, pos); if (key == "LYXCMD") { string const cmd = line.substr(pos + 1); + FuncRequest fr(lyxaction.lookupFunc(cmd)); + fr.setOrigin(FuncRequest::LYXSERVER); DispatchResult dr; - theApp()->dispatch(lyxaction.lookupFunc(cmd), dr); - theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); + theApp()->dispatch(fr, dr); string const rval = to_utf8(dr.message()); if (dr.error()) client->writeln("ERROR:" + cmd + ':' + rval); diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index e4a4797f61..2cec2e333a 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1140,7 +1140,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd) // This is done unless explicitly requested otherwise dr.screenUpdate(Update::FitCursor); dispatch(cmd, dr); + updateCurrentView(cmd, dr); +} + +void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult & dr) +{ if (!current_view_) return; @@ -1311,6 +1316,13 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) return; }; + if (cmd.origin() == FuncRequest::LYXSERVER) { + if (current_view_ && current_view_->currentBufferView()) + current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY(); + // we will also need to redraw the screen at the end + dr.screenUpdate(Update::FitCursor); + } + // Assumes that the action will be dispatched. dr.dispatched(true); @@ -1663,6 +1675,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) current_view_->dispatch(cmd, dr); break; } + + if (cmd.origin() == FuncRequest::LYXSERVER) + updateCurrentView(cmd, dr); } diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index b4c7615749..7691452881 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -192,6 +192,8 @@ private: /// void validateCurrentView(); /// + void updateCurrentView(FuncRequest const & cmd, DispatchResult & dr); + /// bool closeAllViews(); /// read the given ui (menu/toolbar) file bool readUIFile(QString const & name, bool include = false);