On Tue, 10 May 2005, Jean-Marc Lasgouttes wrote:

> >>>>> "Serge" == Serge Winitzki <[EMAIL PROTECTED]> writes:
>
> Serge> Dear LyX team, there are font-emph, font-bold etc. functions,
> Serge> but no font-slant function. Therefore one cannot bind the
> Serge> operation of making a word "slanted" to a key or a toolbar
> Serge> button. I tried to look at the LyX source to see how to add
> Serge> such a function but quickly got confused. It seems that the
> Serge> mechanism to add the "slanting" is not similar to that of
> Serge> "emphasizing" or other such font attributes. Is it somehow
> Serge> difficult for design reasons to add the "font-slant" function?
>
> No, it is just that the person who did that got lazy. The functions
> that got implemented are those that were needed for menus.
>
> Serge> A related question: there seems to be no documentation about
> Serge> the role of LyX functions. Are really *all* LyX functions
> Serge> listed in the file lyxfunctions.C? I thought that *all* LyX
> Serge> operations are LyX functions and that, for instance, *all*
> Serge> actions of a LyX user could be recorded and repeated by a
> Serge> client connected to a LyX server. Is this assumption correct?
>
> Not really. All actions that can be triggered from the menu, toolbar
> or keybindings work through an lfun. Then there are some more
> functions, but they are not very many of them.

I see. So "font-slant" is one of these functions that cannot be reproduced
by a client connected to a LyX server.

I am toying now with the idea of a "LyX chat" application where two
instances of LyX will be connected via pipes/TCP and both users will be
able to simultaneously edit a single LyX document in real time.

The implementation is reasonably straightforward except for some
difficulties that will not be solved without changes to the LyX code.

The basic idea so far is that the client will catch all user actions and
send them over to the other party. The client will also duplicate all
actions received from the other party. This will happen in real time,
similarly to what happens in a chat situation.

To catch all user actions, the client will run something like
"lyx -dbg action >& /tmp/pipe"; maybe there will have to be more
debug flags, e.g. "lyx -dbg 16396" (action|gui|key) or something like
that. The debug messages are too numerous so they must be filtered,
converted to the LyX server protocol format, and sent via a TCP connection
to the other LyX client which will send these messages to the second LyX
instance.

For example, when a user presses "Backspace", the debug messages include
the line

        LyXFunc::dispatch: action[64] arg[]

The action #64 is "LFUN_BACKSPACE" according to lfunc.h (although the
exact numbering is probably subject to change in each LyX version, so it
will have to be taken from the actual LyX source each time). So then the
chat client will prepare and send the message of the form

        LYXCMD:lyxchat:delete-backward:

to the second client. There will be some subtleties of this method, e.g.
the cursor position will have to be read and updated each time to allow
both users to edit different parts of the document. But the idea seems
simple enough for a quick Python script, based on the Python client class
for the LyX server (which I found on the LyX wiki site).

I may have some time to try implementing this next week. There will be
some actions that cannot be caught using the LyX debug output. One such
action is the setting of the "slanted" font, as described in my earlier
message. Another case I discovered today is that the "label-insert XYZ"
action cannot be detected when performed using the GUI, because the label
text "XYZ" does not appear in any debug messages. (If the label-insert XYZ
operation is performed using the minibuffer, the "XYZ" of course appears
in the debug output.) I hope this will be eventually fixed, but for now
let me try to implement even a simplistic chat application. I feel that a
LyX collaboration would be a great way for computer-literate scientists to
communicate (right now I have to send PDF or latex files if I want to
communicate anything more than a couple of equations).

I would be grateful for any further hints regarding the handling of LyX
events, concurrency problems in the LyX server (e.g. what happens if a
client sends a sequence of actions to the server while the user is
typing), and anything else that I am unaware of because of my ignorance of
the LyX internals.

Regards,
Sergei




Reply via email to