Пример #1
0
void
term_color( unsigned color ) {
	unsigned f, b, c;

	if ( (color & 0xff00) == t.color ) return;
	if ( !(color & 0x8000) ) return;
	if ( t.is_mono ) {
		t.color = 0x0700;
		return;
		}
	else
		t.color = color & 0xff00;
	if ( !ct->_cc ) {
		color >>= 8;	/* Only interested in upper 8 bits	*/
		c = color & 0x0077;
		f = c & 0x07;
		b = c >> 4;
		c = f * 10 + b;
		if( *set_color_pair ) 
			__putp( __tparm( set_color_pair, c ) );
		else {
			__putp( __tparm( set_foreground, f ) );
			__putp( __tparm( set_background, b ) );
			}
		}
Пример #2
0
/* Repeat character c, n times. "a" indicates alternate character set.
 * x is the first column that we should be printing on. (used for a little
 * optimization)
 */
static void TI_REPEAT_CHAR( char c, int n, int a, ORD x )
/*******************************************************/
{
    bool        blank;
    int         len;
    char        *cparm_right;

    if(n==0)return;

    blank= OptimizeTerminfo && (TI_FillColourSet) && c==' ' && !a;

    if( blank
        && x==(UIData->width-n)
        && _capable_of( clr_eol )
        && (len=strlen(clr_eol))>0
        && n>len ){
            __putp( clr_eol );
    } else if( blank
        && x==0
        && _capable_of( clr_bol )
        && _capable_of( parm_right_cursor )
        && n>(len=(strlen( cparm_right=UNIX_TPARM2( parm_right_cursor, n ))+strlen(clr_bol)))
        && len>0 ){
            __putp( cparm_right );
            __putp( clr_bol );
    } else {
        if(a){
            TI_ACS_ON();
        }

        if( n>=TI_repeat_cutoff && _capable_of( repeat_char ) ) {
            __putp( UNIX_TPARM3( repeat_char, c, n ) );
        } else {
            for(; n>0; n--){
                fputc( c, UIConFile );
            }
        }

        if(a){
            TI_ACS_OFF();
        }
    }
}
Пример #3
0
static void TI_SETATTR( void )
/****************************/
{
    // we have to reset attributes as some terminals can't turn off
    // attributes with "set_attribues"
    __putp( exit_attribute_mode );

    if( _capable_of( set_attributes ) ) {
        char    *x;

        // Arguments to tparm
        // standout
        // underline
        // reverse
        // blink
        // half intensity
        // bold
        // invisible
        // protected
        // alt. char set
        x = UNIX_TPARM( set_attributes, 0, \
                        TIAULine, TIARev, \
                        TIABlink, 0, TIABold, \
                        0, 0, TIAACS );
        __putp( x );

        UIDebugPrintf0( "\n[******]" );
        UIDebugPrintf1( "%s", set_attributes );
        UIDebugPrintf1( "%s", x );
        UIDebugPrintf0( "[~~~~~~]\n" );
    } else {
/*
        fprintf(stderr, "Doing attributes %s %s %s %s %s\n", \
                TIAULine ? "Underline" : "", \
                TIARev ? "Reverse" : "", \
                TIABlink ? "Blink" : "", \
                TIABold ? "Bold" : "", \
                TIAACS ? "Alternate CS" : "");
*/

        // Believe it or not, some terminals don't have the set_attributes
        // code in the database, so we have to simulate it occasionally
        if( TIAULine && _capable_of( enter_underline_mode ) )
                __putp( enter_underline_mode );

        if( TIARev && _capable_of( enter_reverse_mode ) )
                __putp( enter_reverse_mode );

        if( TIABlink && _capable_of( enter_blink_mode ))
                __putp( enter_blink_mode );

        if( TIABold && _capable_of( enter_bold_mode ))
                __putp( enter_bold_mode );

        if( TIAACS && _capable_of( enter_alt_charset_mode ))
                __putp( enter_alt_charset_mode );
    }
}
Пример #4
0
// move in the optimal way from (OldCol,OldRow) to (c,r)
void TI_CURSOR_MOVE( register int c, register int r )
/**********************************************************/
{
    unsigned            newLen;
    int                 i;
    unsigned            len_cursor_address;
    unsigned            len_cursor_home;
    int                 row;
    int                 col;

    struct {
        int     r,c;
    }                   len= { 0, 0 };

    struct {
        enum {
            none,
            absolute,
            rel_parm_plus,
            relative_plus,
            rel_parm_minus,
            relative_minus
        }       r,c;
    }                   method= { none, none };

    // Return if we're in the right place
    if( OldCol == c && OldRow == r ) {
        return;
    }

    // Just use cursor_address if we're not supposed to optimize.
    // If cursor_address isn't supported then use cursor_home,
    // cursor_down and cursor_left.
    if( !OptimizeTerminfo ) {
        if( _capable_of( cursor_address ) ) {
            __putp( UNIX_TPARM3( cursor_address, r, c ) );
        } else if(    _capable_of( cursor_home )
                   && _capable_of( cursor_down )
                   && _capable_of( cursor_right )
                 ) {
            __putp( cursor_home );
            for( row = 0; row < r; row++ ) {
                __putp( cursor_down );
            }
            for( col = 0; col < c; col++ ) {
                __putp( cursor_right );
            }
        }
        OldRow= r;
        OldCol= c;
        return;


    }

    // If we're not supposed to optimize or if the term is
    // not capable of cursor_address:
    // if OldRow or OldCol <0 then the old position is invalid
    if( OldCol>=0 && OldRow>=0 ){
        if( OldRow!=r ){
            method.r= absolute;
            setLenParm( len.r, row_address, r )

            if( OldRow<r ) {
                setLenParm( newLen, parm_down_cursor, r-OldRow )
                pickMethod( r, rel_parm_plus );

                if( _capable_of( cursor_down ) ) {
                    newLen= (r-OldRow)*strlen( cursor_down );
                } else {
                    newLen= 0;
                }
                pickMethod( r, relative_plus );
            } else {
                setLenParm( newLen, parm_up_cursor, OldRow-r )
                pickMethod( r, rel_parm_minus );

                if( _capable_of( cursor_up ) ) {
                    newLen= (OldRow-r)*strlen( cursor_up );
                } else {
                    newLen= 0;
                }
                pickMethod( r, relative_minus );
            }
        }
        if( OldCol!=c ){
            method.c= absolute;
            setLenParm( len.c, column_address, c )

            if( OldCol<c ) {
                setLenParm( newLen, parm_right_cursor, c-OldCol )
                pickMethod( c, rel_parm_plus );

                if( _capable_of( cursor_right ) ) {
                    newLen= (c-OldCol)*strlen( cursor_right );
                } else {
                    newLen= 0;
                }
                pickMethod( c, relative_plus );
            } else {
                setLenParm( newLen, parm_left_cursor, OldCol-c )
                pickMethod( c, rel_parm_minus );

                if( _capable_of( cursor_left ) ) {
                    newLen= (OldCol-c)*strlen( cursor_left );
                } else {
                    newLen= 0;
                }
                pickMethod( c, relative_minus );
            }
        }