.\"{{{  m_font
.Fh m_font n
.Fs m_font 6 "Change to a new font"
Change to font
.Fi n .
The line positioning is adjusted to keep
the baseline of the new and old fonts the same.
Font numbers are small integers
(currently no more than 15).
Font 0 (zero) always refers to the built-in or
.I default
font.
The actual fonts associated with the font numbers may be set in the \*M
.I startup
file, or changed by clients on the fly
(see
.Fr m_loadfont
).
.Fe
.\"}}}
.\"{{{  m_fracdown
.Fh m_fracdown numer denom
.Fs m_fracdown 3 "Cursor down a fraction of a char height"
Move the character cursor down a distance of
.Fi numer / denom
times the height of characters in the current font,
rounded to a whole number of pixels.
The function
.Fr m_down
 is a special case of
.Fr m_fracdown
 where
.Fi denom
is ten.
.Fe
.\"}}}
.\"{{{  m_fracleft
.Fh m_fracleft numer denom
.Fs m_fracleft 3 "Cursor left a fraction of a char width"
Move the character cursor left a distance of
.Fi numer / denom
times the width of characters in the current font,
rounded to a whole number of pixels.
The function
.Fr m_left
 is a special case of
.Fr m_fracleft
 where
.Fi denom
is ten.
.Fe
.\"}}}
.\"{{{  m_fracright
.Fh m_fracright numer denom
.Fs m_fracright 3 "Cursor right a fraction of a char width"
Move the character cursor right a distance of
.Fi numer / denom
times the width of characters in the current font,
rounded to a whole number of pixels.
The function
.Fr m_right
 is a special case of
.Fr m_fracright
 where
.Fi denom
is ten.
.Fe
.\"}}}
.\"{{{  m_fracup
.Fh m_fracup numer denom
.Fs m_fracup 3 "Cursor up a fraction of a char height"
Move the character cursor up a distance of
.Fi numer / denom
times the height of characters in the current font,
rounded to a whole number of pixels.
The function
.Fr m_up
 is a special case of
.Fr m_fracup
 where
.Fi denom
is ten.
.Fe
.\"}}}
.\"{{{  m_func
.Fh m_func mode
.Fs m_func 4 "Set the bit-blt and graphics drawing mode"
.Fs m_func 5 "Set the bit-blt function"
Set the drawing mode.
This specifies the drawing mode in force for all
.I graphics
and
.I bit-blt
operations.
The integer
.Fi mode
is one of 16 possible boolean combinations of
the
.I source
and
.I destination
bit patterns.
Combinations of bit patterns for which
there is no
.I source
bitmap, such as
.Fr m_bitwrite
 or
.Fr m_line
 use the modes shown in the middle column of the following table.
Several common
.Fi mode s
are specified for the bit patterns in which the source
bitmap is relevant.
.TS
center box;
c s s
c | c | c
l | l | l.
Names for \fBbit-blt\fP modes
_
source	no source	comments
=
BIT_SRC	BIT_INV
BIT_OR	BIT_SET	default
BIT_NOR	BIT_DST
BIT_XOR	BIT_CLR
BIT_AND
BIT_NAND
.TE
Alternately,
.Fi mode
may be derived with a boolean combination of
.Fi BIT_SRC
and
.Fi  BIT_DST,
thus
.Fi BIT_OR
is equivalent to
.Fi BUILDOP( BIT_SRC " \(br "  BIT_DST, BLACK, WHITE ).
The default graphics mode in newly created windows is
.Fi BIT_OR
\&.
.Fe
.\"}}}
.\"{{{  m_getchar
.Fh m_getchar
.Fs m_getchar 2 "Read a character from \*M"
The macro
.Fr m_getchar
 is equivalent to the
.I stdio
routine
.I getchar() ,
except the character is retrieved from \*M via the file pointer
.I m_termin
instead of
.I stdin.
.Fe
.\"}}}
.\"{{{  m_getinfo
.Fh m_getinfo mode
.Fs m_getinfo 7 "Ask \*M for information"
This function requests \*M to return information back to the client program.
.Fi Mode
specifies one of (currently) 15 different requests.
Responses are always terminated with a 
.I "new line"
for single line responses, and with a pair of
.I "new lines"
for multi-line
responses.
Consequently, clients can request and process information requests
using normal line mode processing.
If the
.Fi mode
requested is unsupported,
the response is empty except for the terminating newline.
The following list of information requests is understood.
.RS
'\"	.IP \fBG_ALLFONT\fP 0.5i	Size information for all fonts.
'\"	.br
'\"	The
'\"	.I width
'\"	and
'\"	.I height
'\"	in pixels for a character in each font is listed in a space
'\"	separated list.
'\"	The first pair of numbers is the character size of font
'\"	.B 0 ,
'\"	the next pair for font
'\"	.B 1 ,
'\"	and so on.
'\"	The first request for
'\"	.Fi G_ALLFONT
'\"	can be expensive, as it requires reading each font
'\"	from the disk that has not yet been used.
.IP \fBG_ALLMINE\fP 0.5i
.br
Window status for own windows only.
.br
Information about each window that may be written to by the client program
is returned, one line of information per window, as a 
list of space separated items.
The format of the information is the same as that
obtained from the \fBG_ALL\fP request below,
but only a subset of the windows is described.
.IP \fBG_ALL\fP 0.5i
.br
Status of all windows.
.br
Information about all windows
is returned, one line of information per window, as a
list of space separated items.
The first two items give the location of the top left
corner of the window in
.I display
coordinates.
The second two items give the 
.I height
and
.I width
of the window, 
also in
.I display
coordinates.
The next field contains the last two characters of the
.I pseudo tty
associated with each window.
Normally the 
.I pseudo tty
is the same for each window controlled by the same client.
The next field contains the 
.I "window id" ,
which is 0 (zero)
for a primary window, 
and the value returned by the call to 
.Fr m_makewindow
 for alternate windows.
The seventh field contains the visual status of the window,
which is either 
.SM
.I C_EXPOSED
.LG
('e')
if the window is completely visible,
or
.SM
.I C_OBSCURED
.LG
('o')
if the window is partly or completely obscured.
The final field is the window setid.
Windows can be uniquely identified by a pair
of window id and window setids.
The window information for each window is printed in order from
.I front
to 
.I back.
Thus the first line returned is currently the
.I active
window.
A sample line might look something like:
.TS
center box;
c.
492 2 652 570 p6 0 o 9
.TE
Which indicates that the window at
.Fr "" 492 2
is
.Fi 652
pixels
.I wide
and
.Fi 570
pixels
.I high,
has a controlling
.I pseudo tty
of
.I /dev/tty\fBp6\fP,
is a main window with a setid number of
.Fi 9,
and is at least partially obscured.
.IP \fBG_NOTIFY\fP 0.5i
.br
List windows with notify strings.
.br
Information about each window which has a NOTIFY string set
is returned as four fields terminated by a newline.
Each window report is formed by concatenating the window process id,
a period, the alternate window number, a space,
the length of the NOTIFY string, a space,
and the NOTIFY string itself.
Line processing can be complicated by NOTIFY strings which contain newlines.
.IP \fBG_COORDS\fP 0.5i
.br
Window coordinates.
.br
A single line is returned containing the location and size of the
window in 
.I display
coordinates.
The first pair of numbers is the position of the top left
corner of the window,
the second pair of numbers is the window's
.I width
and
.I height
in pixels.
.IP \fBG_CURSOR\fP 0.5i
.br
A single line is returned containing the position of the
.I character
and the
.I graphics
cursors and the type of the character cursor.
The first pair of numbers is the current
.I column
and
.I row
in character coordinates
and the second pair of numbers is the
current
.I graphics location
in window coordinates.
The graphics cursor location is reported in either
.I absolute
or
.I relative
window coordinates,
depending upon the window coordinate mode setting.
The fifth number encodes the cursor type.
.IP \fBG_FONT\fP 0.5i
.br
A single line is returned which contains current font information.
The first pair of numbers is the character
.I width
and
.I height,
in pixels.
The next number is the
.I "font number"
as would be used in a call to
.Fi m_font ,
and the final field is the ascii name of the font,
or
.I default
if there is no name.
.IP \fBG_ID\fP 0.5i
.br
Alternate window number.
.br
A single line is returned containing the window's alternate window
id ( 0 for the main window), 
followed by the number of windows controlled by the client 
program.
.IP \fBG_MOUSE\fP 0.5i
.br
Mouse coordinates.
.br
The mouse position, in 
.I display 
coordinates are returned, followed by the most recent button transition,
which is one of
.Fi 1 , -1 , 2 , -2 .
The numbers
.Fi 1
and
.Fi 2
represent buttons
.I one
and
.I two
on the mouse, respectively,
counting from right to left.
The third mouse button is reserved for system use and is not accessible to
client programs.
A negative value means the button was released;
a positive value indicates the button is still depressed.
.IP \fBG_MOUSE2\fP 0.5i
.br
Scaled mouse coordinates.
.br
The mouse coordinates, in 
.I window 
coordinates are returned, followed by the most recent button transition,
which is one of
.Fi 1 , -1 , 2 , -2 .
The numbers
.Fi 1
and
.Fi 2
represent buttons
.I one
and
.I two
respectively.
A negative value means the button was last released;
a positive value indicates the button is still depressed.
If the 
mouse is above
or to the left of the window,
a negative coordinate value is returned.
In addition if the window is in
.I relative
coordinate mode, coordinate values between
0 and 999 will be reported only if the mouse is within the window.
.IP \fBG_STATUS\fP 0.5i
.br
A line is returned containing a single character,
either
.SM
.I C_EXPOSED
.LG
('e'),
.SM
.I C_OBSCURED
.LG
('o'),
or
.SM
.I C_ACTIVE
('a')
.LG
depending upon whether the window is
exposed but not the
.I active
window,
partially or totally obscured,
or exposed and the
.I active
window.
.IP \fBG_SYSTEM\fP 0.5i
.br
A single line containing constant global system information is returned.
There are currently five fields:
.RS
.IP 1) 3
The 
.I hostname
of the machine \*M is running on,
as returned by 
.I gethostname() .
.IP 2) 3
The width of the display in pixels.
.IP 3) 3
The height of the display
in pixels.
.IP 4) 3
The size of the window borders in pixels.
.IP 5) 3
The depth of the display in bits.
Currently, the depth must be one or eight.
.RE
.IP \fBG_TERMCAP\fP 0.5i
.br
A single line is returned which contains a 
.I \s-2TERMCAP\s+2
entry for \*M.
The 
.I \s-2TERMCAP\s+2
entry is always the same, except for
.I lines
and
.I columns 
entries (li# and co#),
which vary to reflect the current window size,
and the am entry reflecting the state of the
.SM
.Fi M_NOWRAP
.LG
flag.
.IP \fBG_TEXT\fP 0.5i
.br
A single line containing four integers is returned
with the current text region size.
The first pair of numbers is the top left corner of the text region,
in
.I window
coordinates, the second pair of numbers is the
.I width
and
.I height
of the text region.
If no text region is defined, implying the entire window is the text
region, all four numbers are returned as 0 (zero).
.IP \fBG_WINSIZE\fP 0.5i
.br
A single line is returned containing the current number of 
.I columns
and
.I rows
in the 
.I "text region" .
If no text region is defined, 
the number of 
.I columns
and
.I rows
for the entire window is returned.
.IP \fBG_FLAGS\fP 0.5i
.br
A single line is returned containing a hexadecimal number representing
the current window mode bits.
For color \*M four additional fields are returned which indicate the
current text foreground and background color,
and the graphics foreground and background color.
For the first, or mode field, each mode is represented by a bit in the word.
Many of the modes may be
.I set
or
.I cleared
with
.Fr m_setmode
 or
.Fr m_clearmode
\&.
See the discussion of
.Fr m_setmode
 for a detailed discussion of these flags.
The meaningful mode bits are:
.RS
.IP 0x000001 10
The window is completely exposed.
.IP 0x000004 10
It is possible to use the system
.I cut
function in this window.
This mode is restored by clearing the window.
See
.Fr m_clear
\&.
.IP 0x000008 10
The window is
.I white
text on a
.I black
background.
.IP 0x000010 10
The window is in standout mode.
Individual characters are printed in reverse.
.IP 0x000020 10
The window has died.
If a client sees this flag, the window is about to go away.
.IP 0x000040 10
Expose the window upon shell output.
The window will be automatically activated 
when the next character arrives for output on the window.
.IP 0x000080 10
Permit a partially or totally obscured window to update.
.IP 0x000100 10
Do not kill the window when the original process started in it dies.
This flag may only be set from the startup file.
.IP 0x000200 10
.I Vi
mode is turned on.
Pushing the right mouse button sends the characters:
.TS
center box;
c.
\fBrow\fP H \fBcolumn\fP \(br
.TE
where
.Fi row
and
.Fi column
specifies the character location the mouse is sitting on.
This has the effect of aligning 
.I vi 's
notion of the current character position with the mouse,
if no wrapped lines appear above this position on the screen.
.IP 0x000800 10
Keyboard input is refused when the window is active.
.IP 0x001000 10
Auto wrap mode is turned off with the bit equal to one, on when zero.
When on, the character cursor automatically wraps to the
beginning of the next row when it reaches the right margin of the text region.
.IP 0x002000 10
Overstrike mode is turned on.
Characters are written to the window using the the current drawing mode,
as set by
.Fr m_func
\&.
.IP 0x004000 10
The window is in
.I absolute
window coordinate mode.
.IP 0x010000 10
The system
.I cut
function snarfs complete lines only.
.IP 0x020000 10
The system
.I cut
function changes spaces to tabs whenever possible.
Tabs are assumed to be every 8 spaces.
.IP 0x040000 10
The system
.I cut
function will attempt to snarf text even if errors occur.
.RE
.RE
.Fe
.\"}}}
.\"{{{  m_gets
.Fh m_gets buff
.Fs m_gets 2 "Read a line from \*M"
A line of characters is read from \*M and placed into the array
.Fi buff
\&.
The macro 
.Fr m_gets
 returns
.SM
.I NULL
.LG
if the connection to \*M is severed.
The macro 
.Fr m_gets
 is equivalent to the stdio
.I fgets()
call
except input is retrieved from \*M
\&.
The buffersize is obtained from
.I sizeof(buff)
\&, consequently,
.Fi buff
must be the name of an array.
.Fe
.\"}}}
.\"{{{  m_go
.Fh m_go x y
.Fs m_go 4 "Move the graphics point"
Move the
.I "graphics point"
to the window position
.Fr "" x y
 in the current window coordinates.
.Fe
.Fh m_gotext
.Fs m_gotext 4 "Align the graphics point with the character cursor"
The graphics point is moved to the bottom left corner of the
current character cursor location.
.Fe
.\"}}}
.\"{{{  m_halfwin
.Fh m_halfwin X Y Dwidth Dheight
.Fs m_halfwin 11 "Create a window with no process connected to it"
A window is created at 
.Fi X , Y
of size
.Fi Dwidth
by
.Fi Dheight 
with no process connected to it.
\*M returns the name of the file, a
.I pseudo-tty ,
that must be opened in order to
talk to the new window.
A process which opens that 
.I pseudo-tty
becomes a client program, communicating with \*M and the new
window in the usual fashion.
For a single process managing multiple windows, use
.Fr m_newwin
\&.
The advantage of this way is that \*M can not detect the death of
the process and automatically destroy the window.
.Fe
.\"}}}
.\"{{{  m_halfwinft
.Fh m_halfwinft X Y Dwidth Dheight font
.Fs m_halfwinft 11 "Create a window with no process connected to it"
A window is created just as with
.Fr m_halfwin
, except that font number
.Fi font
is the initial font used in the new window.
.Fe
.\"}}}
.\"{{{  m_highlight
.Fh m_highlight X Y Dwidth Dheight
.Fs m_highlight 13 "Highlight a portion of the display"
\*M flashes the rectangular portion of the display starting at
.Fi X , Y
of size
.Fi Dwidth
by
.Fi Dheight .
This is an experimental capability and may be removed in the future.
.Fe
.\"}}}
.\"{{{  m_incr
.Fh m_incr n
.Fs m_incr 3 "Adjust the character cursor position"
The current character position is adjusted to the left or 
right
.Fi n
units
in 
.I window
coordinates.
The argument
.Fi n
may be signed to indicate movement to the left (if negative) or to the
right (if positive or unsigned).
This is useful for client programs dealing with proportionally
spaced text.
.Fe
.\"}}}
.\"{{{  m_left
.Fh m_left n
.Fs m_left 3 "Move character cursor left by tenths of a character width"
Move the character cursor left 
.Fi n
tenths of a character width.
See also
.Fr m_down
, 
.Fr m_right
, and
.Fr m_up
\&.
.Fe
.\"}}}
.\"{{{  m_line
.Fh m_line x1 y1 x2 y2
.Fs m_line 4 "Draw a line"
Draw a line in the current window from the coordinate
.Fr ""  x1 y1
 to the coordinate
.Fr "" x2 y2
\&.
The line is either set,
cleared or inverted as determined by the last call to
.Fr m_func
\&.
.Fe
.\"}}}
.\"{{{  m_linecolor
.Fh m_linecolor mode color
.Fs m_linecolor 14 "Set the graphics mode and color"
The drawing mode and color is set for all graphics and bit-blt operations.
The integer
.Fi mode
sets the drawing mode, in the manner of 
.Fr m_func
\&.
The integer
.Fi color
is the index into the color lookup table for the drawing color.
This command is equivalent to
.Fr m_func
 on a monochrome display.
See also 
.Fr m_bcolor
 and
.Fr m_fcolor
for the colors used in text operations.
The
.Fr m_linecolor
 call is deprecated in favor of using
.Fr m_func
 and
.Fr m_fgbgcolor
\&.
.Fe
.\"}}}
.\"{{{  m_lineto
.Fh m_lineto to x1 y1 x2 y2
.Fs m_lineto 4 "Draw a line on a scratchpad bitmap"
Draw a line 
on the scratchpad bitmap
.Fi to
from the coordinate
.Fr ""  x1 y1
 to the coordinate
.Fr "" x2 y2
\&.
The line is either set,
cleared or inverted as determined by the last call to
.Fr m_func
\&.
.Fe
.\"}}}
.\"{{{  m_linkmenu
.Fh m_linkmenu parent item child mode
.Fs m_linkmenu 8 "Link two menus together"
The menus
.Fi parent
and
.Fi child 
are linked together.
When menu
.Fi parent
is popped up and item number
.Fi item
(starting from zero)
is highlighted, sliding off to the right of the
.Fi parent
menu causes the
.Fi child
menu to pop up.
When an item is chosen, \*M sends the
concatenation of the action strings associated with each of the
popped-up menus,
from left to right (i.e.
.Fi parent
to 
.Fi child  ).
An arbitrary tree of menus
may be created by linking successive menus together in this
manner.
It is up to the application to indicate on the parent
menu item that sliding to the right will pop up a child menu.
Typically "\fB\(->\fP" is used.
.sp
The
.Fi mode
argument,
if not zero,
changes the menu options
for the
.Fi parent
menu.
The flag settings,
which may be
.I or -ed
together (except for
.SM
.Fi MF_CLEAR
.LG
) are:
.RS
.IP \fBMF_SNIP\fP 0.5i
.br
By default, when an item in a
.I child
menu is selected,
the values associated with the highlighted items for all of the ancestor menus
are concatenated to the
.I child 's
item value.
When
.SM
.Fi MF_SNIP
.LG
is enabled, only the string associated with the child menu is returned.
.IP \fBMF_PAGE\fP 0.5i
.br
Normally, whenever a menu is popped-up, the previously
chosen item is initially highlighted.
If
.SM
.Fi MF_PAGE
.LG
is enabled, this behavior is extended to paged menus.
\*M automatically pages through a set of paged
menus to highlight the currently selected item.
.IP \fBMF_AUTO\fP 0.5i
.br
\*M will automatically slide to the right and pop up
a child menu
to highlight the previously selected item.
.IP \fBMF_CLEAR\fP 0.5i
.br
Clears the mode
.SM
.Fi MF_SNIP ,
.Fi MF_PAGE ,
.LG
and
.SM
.Fi MF_AUTO .
.LG
.RE
See also
.Fr m_loadmenu
,
.Fr m_selectmenu
, and
.Fr m_unlinkmenu
\&.
.Fe
.\"}}}
.\"{{{  m_loadfont
.Fh m_loadfont n name
.Fs m_loadfont 6 "Download a font"
The \*M font whose pathname is
.Fi name
is downloaded into
\*M, replacing the font currently located at position
.Fi n .
Any subsequent calls to
.Fr m_font
will select the newly downloaded font.
The font that used to be at position
.Fi n
remains available to windows that are already using it, 
but is unavailable for future use.
The format of \*M font files is described in
.I "include/mgr/font.h".
.Fe
.Fh m_menubar x y menu item
.Fs m_menubar 8 "Highlight a menu item (extended menu operation)"
.Fe
.Fh m_menuerase menu
.Fs m_menuerase 8 "Remove a menu (extended menu operation)"
.Fe
.Fh m_menuitem menu item
.Fs m_menuitem 8 "Pre-select a menu item"
.Fe
.Fh m_menushow x y menu
.Fs m_menushow 8 "Display a menu (extended menu operation)
.Fe
.\"}}}
.\"{{{  m_loadmenu
.Fh m_loadmenu n string
.Fs m_loadmenu 8 "Down load a menu"
The text
.Fi string
is downloaded into menu position
.Fi n .
The first character of
.Fi string
is the 
.I "menu delimiter"
character.
All of the menu item strings are concatenated,
followed by all of their action strings.
The 
.I "menu delimiter"
character separates all of the items and actions
and terminates the list.
Menus are downloaded at once, as a single entity.
The macro
.Fr m_selectmenu
 is used to have the menu pop-up when a mouse button is pushed.
.Fe
.\"}}}
.\"{{{  m_move
.Fh m_move column row
.Fs m_move 3 "Move the character cursor"
The character cursor is moved to character location
.Fi column , row
, where
.Fr "" 0 0
 is the top left character position on the window, or on
the current text region if one is specified
(see
.Fr m_textregion
).
.Fe
.\"}}}
.\"{{{  m_movecursor
.Fh m_movecursor x y
.Fs m_movecursor 3 "Move the character cursor to an arbitrary coordinate location"
Move the character cursor to the position
.Fr "" x y
 in window coordinates.
This permits characters to be placed at arbitrary pixel locations,
not just on character boundaries.
Use
.Fr m_move
to move to a
.Fi row
and
.Fi column
position.
.Fe
.\"}}}
.\"{{{  m_movemouse
.Fh m_movemouse X Y
.Fs m_movemouse 6 "Move the mouse position"
Move the mouse to position
.Fr "" X Y
 in
.I display
coordinates.
Excessive use of this macro is anti-social.
.Fe
.\"}}}
.\"{{{  m_moveprint
.Fh m_moveprint x y string
.Fs m_moveprint 3 "Print a string at a given location"
Print
.Fi string
at the window coordinate
.Fr "" x y
\&.
This macro is equivalent to calling
.Fr m_movecursor
 followed by
.Fr m_printstr
\&.
.Fe
.\"}}}
.\"{{{  m_movewindow
.Fh m_movewindow X Y
.Fs m_movewindow 6 "Move a window"
Move the window to the display location
.Fr "" X Y 
 in 
.I display
coordinates.
If the new position is too close to the edge of the display for the window
to fit entirely at the requested location,
the right edge or bottom of the window is truncated at the boundary of the
display.
.Fe
.\"}}}
.\"{{{  m_newwin
.Fh m_newwin X Y Dwide Dhigh
.Fs m_newwin 11 "Make a new window"
An alternate window is created with the size and location indicated.
The arguments
.Fi X
and
.Fi Y
specify the upper left corner of the window,
.Fi Dwide
and
.Fi Dhigh
the size.
If the window is to be to fit at the requested location,
its size is truncated appropriately.
\*M will return a window number if the creation is successful, or
a 
.I newline
if the window could not be created.
The newly created window is made the
.I active 
window.
The macro
.Fr m_selectwin
 is used to enable writing on the newly created window.
.Fe
.\"}}}
