Programming for MGR

# 5 Programming for MGR

Contents of this section

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>

> `

and substituting or redefining BIT_XOR, BIT_AND, et al for B_XOR, B_AND, et al in the bitblt operations.

Compiling client code generally requires compiler options like

> `

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

> `

as well as an occasional -DOLDMGR or -DOLDLIBMGR for some dusty decks.

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. At present, the color palette itself is manipulated by programs external to MGR, but version 0.62 has experimental code for clients to get MGR to manipulate the color palette.

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/linux` directory. 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`.

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter