curses and line graphics

Dave Lee dave at dptechno.UUCP
Thu Jul 26 02:44:26 AEST 1990


In article <426 at sigma21.oz> peter at sigma21.oz (Peter Farrell) writes:
>
>I wrote my own box routine. It uses the ACS_ defined characters. This
>time the trivial test prog sends the 'enacs' string up front and
>everything in the window is displayed using the graphics set.
>
>Frustration. Does anyone know how to draw boxes within curses windows?
>

The following will draw boxes within curses enviroment 
This works well for all versions of curses I have used.


------------------------ CUT HERE ---------------------------------------

#include <curses.h>
static int initbox = 0;
static int     UL,UR,LL,LR,HOR,VER;

extern char *TermType ; /* From other file -- only for kludge  */

static InitBox()
{
#ifdef ACS_ULCORNER
        UL = ACS_ULCORNER;
        UR = ACS_URCORNER;
        LL = ACS_LLCORNER;
        LR = ACS_LRCORNER;
        HOR = ACS_HLINE ;
        VER = ACS_VLINE ;
#else
	/* KLUDGE FOR SYSTEMS WITHOUT ACS_xxxx */
	/* MAY ADD OTHER KLUDGES FOR SPECIFIC TERMINALS HERE */
	/* EXAMPLE :  */
        if(strcmp( TermType  , "wy50" ) == 0  ){
                UL = 'R' | A_ALTCHARSET ;
                LL = 'Q' | A_ALTCHARSET ;
                UR = 'S' | A_ALTCHARSET ;
                LR = 'U' | A_ALTCHARSET ;
                HOR = 'Z' | A_ALTCHARSET ;
                VER = 'V' | A_ALTCHARSET ;
        } else {	
		UL = '+'  ;
		UR = '+'  ;
		LL = '+'  ;
		LR = '+'  ;
		HOR = '-'  ;
		VER = '|' ;
	} 

#endif
        initbox = 1;
}


/*** Box window "w" starting with upper left at x,y 
	for width,height size */

Box( w ,x,y,width,height)
WINDOW *w;
{
        int i;
        if( ! initbox ) InitBox();
        wmove( w , y , x );
        waddch( w , UL );
        for( i = 0 ; i < width-2 ; i++ )
                waddch( w , HOR );
        waddch( w , UR );
        for( i = 1 ; i < height ; i++ ){
                mvwaddch( w ,i+y,x, VER );
                mvwaddch( w , i + y , x + width - 1 , VER );
        }
        wmove( w , y + height - 1 , x );
        waddch( w , LL );
        for( i = 0 ; i < width-2 ; i++ )
                waddch( w , HOR );
        waddch( w , LR );
}

----------------- CUT HERE ------------------------------

-- 
Dave Lee
uunet!dptechno!dave



More information about the Comp.unix.i386 mailing list