page Using the Library
Clients using The C Interface Library should specify: #include <mgr/mgr.h> which also includes <stdio.h> if it has not already been included. Programs are compiled either with cc -o foo -I$(inc) foo.c libmgr.a where $(inc) is the include directory or simply cc -o foo foo.c -lmgr if the library is installed in a standard location. The file contains the functions listed in the last section. Several compile time options are available to the client program using the library. Normally, the library setup routine, m_setup attempts to open to communicate with . Client programs may define the C preprocessor symbols or to override the selection of for input or output respectively. After each macro call, the flush flag is tested to see if output should be flushed to . If the C preprocessor symbol is defined, before the client program includes the flush flag is never tested, and it becomes the responsibility of the client program to insure output is flushed at the appropriate times. Several external variables maintained by the library are accessible to client programs. The pointers and are used for directing output to, and receiving input from . These file pointers are initialized in m_setup , and may be changed by client programs after m_setup is called. The integer contains the current library mode settings, as returned by m_setup . The and bits of may also be changed at any time after m_setup is called. The integer contains the current window context depth, and is used by m_popall to pop the appropriate number of contexts. should not be changed by client programs. Finally, the character defines the menu separator character used by menu_load . This character, set to '\005' by the library package, can be changed to any character that will not appear as part of a menu item or action.

page Glossary
is a coordinate system used in measured in units of pixels.
The window is the window logically in the front of the display, which is receiving keyboard and mouse input and has a bold border.
An is an additional window created by a client program that shares the communication channel with the main window.
A represents a rectangular array of pixels, either stored in server memory or displayed on-screen.
The is the bidirectional byte stream connecting with the client program. The is usually the program's standard input and output.
is the coordinate system used in windows for counting characters in and . The top left character coordinate is (0,0).
The points to the location in the window where the next character will be placed. The cursor location is always highlighted on the active window.
A is a menu that will pop up when the user slides the mouse off to the right of a popped up
A is any Unix command that is running in an window. Client programs may be existing programs, as might be found in or new -aware applications written specifically to take advantage of the windowing environment.
The is the computer that the client program is running on. It is often the same as the machine, but it does not need to be. is a coordinate system used to measure pixels on the display. The top left corner of the display is at (0,0), with increasing to the right, and increasing down.
A window is if it is entirely visible.
The is a location on the window, measured in the prevailing window coordinate system, that may serve as a reference location or origin for many of the graphics operations.
A is a window that has turned on the event and is willing to receive messages from other client programs.
A client program's is the window the program was started in. The client program may create and destroy alternate windows, but not its If the user destroys a client program's the connection to is severed, and the client program receives a signal.
The -host is the computer that is running on.
The is a small bitmap or that tracks the movement of the mouse on the display. Normally the is a small arrow pointing north west.
A window is when it is partially or totally covered by another window.
A menu is called a when sliding off to the right of a selected item causes another menu or to pop up.
is a coordinate system for windows where a single unit represents one thousandth of the way across (or down) the window.
A is a chunk of memory, allocated by for use by a client program, that may hold a bitmap image that is not on the display.
The is a buffer maintained by of arbitrary size that is accessible by all client programs.
A is a window that is to receive a message from another window.
A is the part of the window in which character text and the functions that operate on characters work. The may be the entire window (the default) or a rectangular subregion within the window.
The is a thin black border around every window that separates the window from the rest of the display. The border is included in the size of the window in display coordinates, but the window coordinate systems exclude the border.
A contains the values for one or more aspects of the window's state. A may be saved on a stack, and then restored at some later time.
A is a unique number assigned to every window that may be used as an identifier when sending a message to the window. have two parts, the first part is the process number of the client program that was started when the window was created, the second part is the window's window number, or zero for a main window.

page Sample Client Program
This program, called closes, or iconifies a window. Its not a terribly useful application in its own right, but it does exercise several of the library calls. When starts up, it makes the window smaller, moves it toward the top of the display, then writes the word "closed" in it. If the window is covered by another window, it changes the word "closed" to "hidden", then flashes its window every 15 seconds as long as the window is covered. If the window is then uncovered, the word "hidden" gets changed back to "closed". Activating the window causes to restore the window's original shape and contents, then exit. /* iconify a MGR window */ #include <mgr/mgr.h> #include <signal.h> #define TIME 15 /* time interval for reminder */ #define CONTEXT P_POSITION | P_WINDOW | P_FLAGS | P_EVENT | P_CURSOR static char line[80]; /* event input buffer */ int main() { int clean(), timer(); /* interrupt routines */ int x,y; /* window position on display */ char *msg = "closed"; /* closed window "icon" */ /* setup the window environment */ m_setup(M_FLUSH); /* setup i/o, turn on flushing */ m_push(CONTEXT); /* save current window context */ m_setmode(M_NOWRAP); /* don't auto-wrap at right margin */ m_ttyset(); /* set up tty modes */ /* catch the appropriate signals */ signal(SIGTERM,clean); /* in case we get terminated */ signal(SIGALRM,timer); /* for the reminder service */ /* iconify the window */ get_size(&x,&y,0,0); /* fetch window coordinates */ m_sizeall(x,10,strlen(msg),1);/* move and resize window */ m_clear(); /* clear the window */ m_printstr(msg); /* print message in the window */ /* catch events */ m_setevent(ACTIVATE, "A\n"); /* window is now the active window */ m_setevent(COVERED, "C\n"); /* covered by another window */ m_setevent(UNCOVERED,"U\n"); /* completely visible */ m_setevent(REDRAW, "R\n"); /* redraw requested */ m_clearmode(M_ACTIVATE); /* bury the window */ /* wait for an event */ while(m_gets(line) != NULL) /* read a line from MGR */ switch (*line) { case 'A': /* window is activated */ clean(); /* clean up and exit */ break; case 'C': /* window is covered */ m_clear(); m_printstr("hidden"); alarm(TIME); /* turn on reminder */ break; case 'R': /* system 'redraw' */ case 'U': /* window is uncovered */ m_clear(); m_printstr(msg); alarm(0); /* turn off reminder */ break; case 'T': /* send reminder */ m_setmode(M_WOB); /* highlight window */ m_bell(); /* ring the bell */ sleep(1); alarm(TIME); /* reset reminder timer */ m_clearmode(M_WOB); /* reset window highlighting */ break; } } clean() /* clean up and exit */ { m_ttyreset(); /* reset tty modes */ m_popall(); /* restore window context */ exit(0); } timer() /* called at reminder timeout */ { m_sendme("T\n"); /* send timeout message */ }

page Macros and Functions by Category
The routines marked with a dagger (†) are functions, the other routines are macros. The page number on which the macro or function is defined is printed in bold face after the name.