Example #1
0
static void fb_key_in(void *p, unsigned char *ev_, int size)
{
	struct event *ev = (struct event *)(void *)ev_;
	if (size != sizeof(struct event)) return;
	if (ev->ev == EV_ABORT) terminate_loop = 1;
	if (ev->ev != EV_KBD) return;
	if ((ev->y & KBD_ALT) && ev->x >= '0' && ev->x <= '9') {
		switch_virtual_device((ev->x - '1' + 10) % 10);
		return;
	}
	if (!current_virtual_device) return;
	if (!ev->y && ev->x == KBD_F5) fb_mouse_move(-3, 0);
	else if (!ev->y && ev->x == KBD_F6) fb_mouse_move(0, 3);
	else if (!ev->y && ev->x == KBD_F7) fb_mouse_move(0, -3);
	else if (!ev->y && ev->x == KBD_F8) fb_mouse_move(3, 0);
	else
	{
		if (fb_driver.codepage!=utf8_table&&(ev->x)>=128&&(ev->x)<=255)
			if ((ev->x=cp2u(ev->x,fb_driver.codepage)) == -1) return;
		if (current_virtual_device->keyboard_handler) current_virtual_device->keyboard_handler(current_virtual_device, ev->x, ev->y);
	}
}
Example #2
0
File: x.c Project: lince/ginga-srpp
static inline int trans_key(unsigned char * str, int table)
{
	if (table==utf8_table){int a; GET_UTF_8(str,a);return a;}
	if (*str<128)return *str;
	return cp2u(*str,table);
}
Example #3
0
	/** Following should match the screen_char.color field. */
	unsigned char color[SCREEN_COLOR_SIZE];
};

#if defined(CONFIG_TRUE_COLOR)
#define INIT_SCREEN_STATE 	{ 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }
#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
#define INIT_SCREEN_STATE 	{ 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF } }
#else
#define INIT_SCREEN_STATE 	{ 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF } }
#endif

#ifdef CONFIG_TRUE_COLOR
static inline int
compare_color_true(unsigned char *a, unsigned char *b)
{
	return !memcmp(a, b, 6);
}

static inline int
compare_bg_color_true(unsigned char *a, unsigned char *b)
{
	return (a[3] == b[3] && a[4] == b[4] && a[5] == b[5]);
}

static inline int
compare_fg_color_true(unsigned char *a, unsigned char *b)
{
	return (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
}

static inline void
copy_color_true(unsigned char *a, unsigned char *b)
{
	memcpy(a, b, 6);
}

static inline int
background_is_black(unsigned char *a)
{
	static unsigned char b[6] = {0, 0, 0, 0, 0, 0};

	return compare_bg_color_true(a, b);
}
#endif

#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
static inline int
compare_color_256(unsigned char *a, unsigned char *b)
{
	return (a[0] == b[0] && a[1] == b[1]);
}

static inline int
compare_bg_color_256(unsigned char *a, unsigned char *b)
{
	return (a[1] == b[1]);
}

static inline int
compare_fg_color_256(unsigned char *a, unsigned char *b)
{
	return (a[0] == b[0]);
}

static inline void
copy_color_256(unsigned char *a, unsigned char *b)
{
	a[0] = b[0];
	a[1] = b[1];
}
#endif

static inline int
compare_color_16(unsigned char *a, unsigned char *b)
{
	return (a[0] == b[0]);
}

static inline int
compare_bg_color_16(unsigned char *a, unsigned char *b)
{
	return (TERM_COLOR_BACKGROUND_16(a) == TERM_COLOR_BACKGROUND_16(b));
}

static inline int
compare_fg_color_16(unsigned char *a, unsigned char *b)
{
	return (TERM_COLOR_FOREGROUND_16(a) == TERM_COLOR_FOREGROUND_16(b));
}

static inline void
copy_color_16(unsigned char *a, unsigned char *b)
{
	a[0] = b[0];
}

#ifdef CONFIG_UTF8
static inline void
add_char_data(struct string *screen, struct screen_driver *driver,
	      unicode_val_T data, unsigned char border)
#else  /* !CONFIG_UTF8 */
static inline void
add_char_data(struct string *screen, struct screen_driver *driver,
	      unsigned char data, unsigned char border)
#endif /* !CONFIG_UTF8 */
{
	/* charset  use_utf8_io  border  data              add_to_string
	 * -------  -----------  ------  ----------------  ----------------
	 * unibyte  0            0       terminal unibyte  terminal unibyte
	 * unibyte  0            1       enum border_char  border unibyte
	 * unibyte  1            0       terminal unibyte  UTF-8
	 * unibyte  1            1       enum border_char  UTF-8
	 * UTF-8    1            0       UTF-32 (*)        UTF-8
	 * UTF-8    1            1       enum border_char  UTF-8
	 *
	 * (*) For "UTF-32" above, data can also be UCS_NO_CHAR,
	 * in which case this function must not alter *screen.
	 */

	if (border && driver->opt.frame && data >= 176 && data < 224)
		data = driver->opt.frame[data - 176];

#ifdef CONFIG_UTF8
	if (driver->opt.utf8_cp) {
		if (border) {
			data = cp2u(driver->opt.charsets[1],
				    (unsigned char) data);
		}
		if (data == UCS_NO_CHAR)
			return;
#ifdef CONFIG_COMBINE
		if (data >= UCS_BEGIN_COMBINED && data <= last_combined) {
			unicode_val_T *text = combined[data - UCS_BEGIN_COMBINED];

			if (driver->opt.combine) {
				/* XTerm */
				while (*text != UCS_END_COMBINED) {
					add_to_string(screen, encode_utf8(*text));
					text++;
				}
				return;
			} else {
				/* Others */
				data = *text;
			}
		}
#endif /* CONFIG_COMBINE */
		if (!isscreensafe_ucs(data))
			data = UCS_SPACE;
		add_to_string(screen, encode_utf8(data));
	} else
#endif /* CONFIG_UTF8 */
	if (use_utf8_io(driver)) {
		int charset = driver->opt.charsets[!!border];

		if (border || isscreensafe(data))
			add_to_string(screen, cp2utf8(charset, data));
		else /* UCS_SPACE <= 0x7F and so fits in one UTF-8 byte */
			add_char_to_string(screen, UCS_SPACE);
	} else {
		if (border || isscreensafe(data))
			add_char_to_string(screen, (unsigned char)data);
		else
			add_char_to_string(screen, ' ');
	}
}