Both bugs above were due to a missing screen update. This patch
updates the current view after dispatching a lyxserver command
and thus solves both.

The patch is quite strightforward and the only difficulty was due
to the fact that the lyxserver needs the result of the dispatched
command. Now, GuiApplication::dispatch(FuncRequest const &) does
right this, but does not return the result, while
GuiApplication::dispatch(FuncRequest const &, DispatchResult &)
is called by the former but does not return the result. So, I
split the first one, isolating the code performing the update,
such that the second one can also update the current view when
the caller is the lyx server. When the action is initiated by
anything different from the lyx server, the behavior is unchanged.
This commit is contained in:
Enrico Forestieri 2012-04-13 02:57:25 +02:00
parent d07f9eec20
commit ea31541848
5 changed files with 23 additions and 4 deletions

View File

@ -35,6 +35,7 @@ public:
TOOLBAR, // A toolbar icon TOOLBAR, // A toolbar icon
KEYBOARD, // a keyboard binding KEYBOARD, // a keyboard binding
COMMANDBUFFER, COMMANDBUFFER,
LYXSERVER,
TOC TOC
}; };

View File

@ -1173,10 +1173,10 @@ void Server::callback(string const & msg)
// connect to the lyxfunc in the single GuiView we // connect to the lyxfunc in the single GuiView we
// support currently. (Lgb) // support currently. (Lgb)
FuncRequest const fr(lyxaction.lookupFunc(cmd), arg); FuncRequest fr(lyxaction.lookupFunc(cmd), arg);
fr.setOrigin(FuncRequest::LYXSERVER);
DispatchResult dr; DispatchResult dr;
theApp()->dispatch(fr, dr); theApp()->dispatch(fr, dr);
theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
string const rval = to_utf8(dr.message()); string const rval = to_utf8(dr.message());
// all commands produce an INFO or ERROR message // all commands produce an INFO or ERROR message

View File

@ -141,9 +141,10 @@ void ServerSocket::dataCallback(int fd)
string const key = line.substr(0, pos); string const key = line.substr(0, pos);
if (key == "LYXCMD") { if (key == "LYXCMD") {
string const cmd = line.substr(pos + 1); string const cmd = line.substr(pos + 1);
FuncRequest fr(lyxaction.lookupFunc(cmd));
fr.setOrigin(FuncRequest::LYXSERVER);
DispatchResult dr; DispatchResult dr;
theApp()->dispatch(lyxaction.lookupFunc(cmd), dr); theApp()->dispatch(fr, dr);
theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
string const rval = to_utf8(dr.message()); string const rval = to_utf8(dr.message());
if (dr.error()) if (dr.error())
client->writeln("ERROR:" + cmd + ':' + rval); client->writeln("ERROR:" + cmd + ':' + rval);

View File

@ -1140,7 +1140,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd)
// This is done unless explicitly requested otherwise // This is done unless explicitly requested otherwise
dr.screenUpdate(Update::FitCursor); dr.screenUpdate(Update::FitCursor);
dispatch(cmd, dr); dispatch(cmd, dr);
updateCurrentView(cmd, dr);
}
void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult & dr)
{
if (!current_view_) if (!current_view_)
return; return;
@ -1311,6 +1316,13 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
return; 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. // Assumes that the action will be dispatched.
dr.dispatched(true); dr.dispatched(true);
@ -1663,6 +1675,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
current_view_->dispatch(cmd, dr); current_view_->dispatch(cmd, dr);
break; break;
} }
if (cmd.origin() == FuncRequest::LYXSERVER)
updateCurrentView(cmd, dr);
} }

View File

@ -192,6 +192,8 @@ private:
/// ///
void validateCurrentView(); void validateCurrentView();
/// ///
void updateCurrentView(FuncRequest const & cmd, DispatchResult & dr);
///
bool closeAllViews(); bool closeAllViews();
/// read the given ui (menu/toolbar) file /// read the given ui (menu/toolbar) file
bool readUIFile(QString const & name, bool include = false); bool readUIFile(QString const & name, bool include = false);