Ejemplo n.º 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;
}
Ejemplo n.º 2
0
int fb_hConsoleGfxMode
	(
		void (*gfx_exit)(void),
		void (*save)(void),
		void (*restore)(void),
		void (*key_handler)(int, int, int, int)
	)
{
	BG_LOCK();

	fb_hStartBgThread( );

	__fb_con.gfx_exit = gfx_exit;
	if (gfx_exit) {
		__fb_ctx.hooks.multikeyproc = NULL;
		__fb_ctx.hooks.inkeyproc = NULL;
		__fb_ctx.hooks.getkeyproc = NULL;
		__fb_ctx.hooks.keyhitproc = NULL;
		__fb_ctx.hooks.sleepproc = NULL;
		gfx_save = save;
		gfx_restore = restore;
		gfx_key_handler = key_handler;
		if (keyboard_init()) {
			BG_UNLOCK();
			return -1;
		}
		ioctl(key_fd, KDSETMODE, KD_GRAPHICS);
	} else {
		if (key_fd >= 0) {
			ioctl(key_fd, KDSETMODE, KD_TEXT);
			keyboard_exit();
			fb_hTermOut(SEQ_EXIT_GFX_MODE, 0, 0);
		}
	}

	BG_UNLOCK();

	return 0;
}
Ejemplo n.º 3
0
static int keyboard_console_getch(void)
{
	int key = -1;

	BG_LOCK();

	if (key_head != key_tail) {
		key = key_buffer[key_head];
		key_head = (key_head + 1) & (KEY_BUFFER_SIZE - 1);
	}

	BG_UNLOCK();

	return key;
}
Ejemplo n.º 4
0
int fb_ConsoleMultikey(int scancode)
{
	int res;

	if (!__fb_con.inited)
		return FB_FALSE;

	BG_LOCK();

	fb_hStartBgThread( );

	if ((!__fb_con.keyboard_handler) && (!keyboard_init())) {
		/* Let the handler execute at least once to fill in states */
		BG_UNLOCK();
		usleep(50000);
		BG_LOCK();
	}

	res = key_state[scancode & 0x7F] ? FB_TRUE : FB_FALSE;

	BG_UNLOCK();

	return res;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
int fb_ConsoleWidth( int cols, int rows )
{
	int cur = (__fb_con.inited ? (__fb_con.w | (__fb_con.h << 16)) : (80 | (25 << 16)));

	if ((cols > 0) || (rows > 0)) {
		BG_LOCK();

		if (cols <= 0)
			cols = __fb_con.w;
		if (rows <= 0)
			rows = __fb_con.h;
		fb_hTermOut(SEQ_WINDOW_SIZE, rows, cols);

		BG_UNLOCK();

		fb_ConsoleClear( 0 );
	}

	return cur;
}
Ejemplo n.º 7
0
FBCALL void fb_ConsoleGetXY( int *col, int *row )
{
	int x = __fb_con.cur_x, y = __fb_con.cur_y;

	if (__fb_con.inited) {
		/* Note we read reply from stdin, NOT from __fb_con.f_in */
		BG_LOCK();

#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();
	}
	if (col)
		*col = x;
	if (row)
		*row = y;
}
Ejemplo n.º 8
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 );
}