LPUTCHAR(3L)

NAME
lputchar - 630 MTG local putchar function

SYNOPSIS
void lputchar (c)
char c;

DESCRIPTION
Lputchar is syntactically equivalent to the UNIX standard I/O putchar function. It can be called by downloaded application programs who want to display characters within their window on the 630 MTG screen. Where (within the applications window) characters are displayed can be affected with the moveto(3L) function. Lputchar calls the moveto routine to update the current screen point after it displays the charcter c.

How characters are eventually displayed on a user's terminal when using the UNIX putchar function is affected by the UNIX host stty(1) settings and the user's terminal characteristics. Since lputchar displays directly onto the 630 MTG screen, assumptions were made about desired stty settings. In general, lputchar does as little processing on the output stream as practical. If more extensive processing of control characters is needed, it can be accomplished as shown in the example program below.

The following are the only control characters processed by lputchar. All other characters will be displayed as ASCII characters:

\r  Carriage Return. Move the current point to the left edge of the window.

\n  Newline. Move the current point down one line and to the left edge of the window. Scroll the window if necessary.

\t  Horizontal tab. Tab characters are expanded to spaces with tab stops at every eighth space.

EXAMPLE

If an application program wanted to, for example, process bells and backspaces rather than display the ASCII bell and backspace characters, it could define a function mylputchar as follows:

    #include <dmd.h>
    #include <font.h>
    void lputchar();
    void moveto();
    void ringbell();
    Point sPtCurrent();
    mylputchar(c)
    char c;
    {
    	Point curpos;
    	switch( c ) {
    	case '\007':
    		ringbell();
    		break;
    	case '\b':
    		/* get the current position
    		** if( not already at the left edge of the
    		**	window ) {
    	 	** 	move back one character position
    		** 	lputchar a space to erase the last
    		** 	character and move back again
    		** }
    		*/
    		curpos = sPtCurrent();
    		if(curpos.x - FONTWIDTH(largefont)
    		    >= Drect.origin.x) {
    			curpos.x -= FONTWIDTH(largefont);
    			moveto(curpos);
    			lputchar(' ');
    			moveto(curpos);
    		}
    		break;
    	default:
    		lputchar(c);
    		break;
    	}
    }

SEE ALSO
bputchar(3L), moveto(3L), printf(3L), structures(3R).
stty(1) in the UNIX System V User's Reference Manual.
putc(3S) in the UNIX System V Programmer's Reference Manual.