Example #1
0
FBCALL void fb_ConsoleGetXY( int *col, int *row )
{
    int x, y;

    if (__fb_con.inited) {
        BG_LOCK();
        fb_hRecheckConsoleSize( );

#ifdef HOST_LINUX
        if( fb_hTermQuery( SEQ_QUERY_CURSOR, &y, &x ) == FALSE )
#endif
        {
            x = __fb_con.cur_x;
            y = __fb_con.cur_y;
        }

        BG_UNLOCK();
    } else {
        x = 1;
        y = 1;
    }

    if (col)
        *col = x;
    if (row)
        *row = y;
}
Example #2
0
FBCALL void fb_ConsoleGetSize( int *cols, int *rows )
{
	if( !__fb_con.inited ) {
		if( cols ) *cols = 80;
		if( rows ) *rows = 24;
		return;
	}

	BG_LOCK( );
	fb_hRecheckConsoleSize( TRUE );
	BG_UNLOCK( );

	if( cols ) *cols = __fb_con.w;
	if( rows ) *rows = __fb_con.h;
}
Example #3
0
void fb_ConsolePrintBufferWstrEx( const FB_WCHAR *buffer, size_t chars, int mask )
{
	size_t avail, avail_len;
	char *temp;

	if( !__fb_con.inited )
	{
		/* !!!FIXME!!! is this ok or should it be converted to UTF-8 too? */
		fwrite( buffer, sizeof( FB_WCHAR ), chars, stdout );
		fflush( stdout );
		return;
	}

	temp = alloca( chars * 4 + 1 );

	BG_LOCK( );
	fb_hRecheckConsoleSize( );
	BG_UNLOCK( );

	/* ToDo: handle scrolling for internal characters/attributes buffer? */
	avail = (__fb_con.w * __fb_con.h) - (((__fb_con.cur_y - 1) * __fb_con.w) + __fb_con.cur_x - 1);
	avail_len = chars;
	if (avail < avail_len)
		avail_len = avail;

	/* !!!FIXME!!! to support unicode the char_buffer would have to be a wchar_t,
				   slowing down non-unicode printing.. */
	fb_wstr_ConvToA( temp, buffer, avail_len );

	memcpy( __fb_con.char_buffer + ((__fb_con.cur_y - 1) * __fb_con.w) + __fb_con.cur_x - 1,
	        temp,
	        avail_len );

	memset( __fb_con.attr_buffer + ((__fb_con.cur_y - 1) * __fb_con.w) + __fb_con.cur_x - 1,
	        __fb_con.fg_color | (__fb_con.bg_color << 4),
	        avail_len );

	/* convert wchar_t to UTF-8 */
	int bytes;

	fb_WCharToUTF( FB_FILE_ENCOD_UTF8, buffer, chars, temp, &bytes );
	/* add null-term */
	temp[bytes] = '\0';

	fputs( ENTER_UTF8, stdout );

	fputs( temp, stdout );

	fputs( EXIT_UTF8, stdout );

	/* update x and y coordinates.. */
	for( ; chars; chars--, buffer++ )
	{
		++__fb_con.cur_x;
		if( (*buffer == _LC('\n')) || (__fb_con.cur_x >= __fb_con.w) )
		{
			__fb_con.cur_x = 1;
			++__fb_con.cur_y;
			if( __fb_con.cur_y > __fb_con.h )
				__fb_con.cur_y = __fb_con.h;
		}
	}

	fflush( stdout );
}