Previous Next Contents

5. Programming for MGR

The MGR programmers manual, the C language applications interface, is found in the doc directory in troff/nroff form. It covers general concepts, the function/macro calls controlling the server, a sample application, with an index and glossary.

Porting client code used with older versions of MGR sometimes requires the substitution of

    #include <mgr/mgr.h>
for
    #include <term.h>
    #include <dump.h>
and clients using old-style B_XOR, B_CLEAR, et al instead of BIT_XOR, BIT_CLR, et al can be accommodated by writing
    #define OLDMGRBITOPS
    #include <mgr/mgr.h>

Compiling client code generally requires compiler options like the following.

    -I/usr/mgr/include   -L/usr/mgr/lib -lmgr

One can get some interactive feel for the MGR server functions by reading and experimenting with the mgr.el terminal driver for GNU Emacs which implements the MGR interface library in ELisp.

The usual method of inquiring state from the server has the potential of stumbling on a race condition if the client also expects a large volume of event notifications. The problem arises if an (asynchronous) event notification arrives when a (synchronous) inquiry response was expected. If this arises in practice (unusual) then the MGR state inquiry functions would have to be integrated with your event handling loop.

The only major drawing function missing from the MGR protocol, it seems, is an area fill for areas other than upright rectangles. There is new code for manipulating the global colormap, as well as (advisory) allocation and freeing of color indices owned by windows.

If you are thinking of hacking on the server, you can find the mouse driver in mouse.* and mouse_get.*, the grotty parts of the keyboard interface in kbd.c, and the interface to the display in the src/libbitblit/* directories. The main procedure, much initialization, and the top level input loop are in mgr.c, and the interpretation of escape sequences is in put_window.c.


Previous Next Contents