44 #include "ctk-curses.h"
52 #define MKPAIR(bg, fg) (bg << 3 | fg)
54 static unsigned char width;
55 static unsigned char height;
57 static unsigned char color;
58 static unsigned char reversed;
61 static unsigned char keys_in, keys_out;
62 static unsigned char available;
64 static unsigned short xpos;
65 static unsigned short ypos;
66 static unsigned char button;
69 static unsigned char ctk_color_map[8] = {
82 map_color(
unsigned char color)
86 c = ctk_color_map[color & 0x0f];
87 c |= ctk_color_map[(color >> 4) & 0x07] << 4;
102 #ifdef NCURSES_MOUSE_VERSION
105 static unsigned char done;
125 intrflush(stdscr,
FALSE);
126 keypad(stdscr,
TRUE);
128 #ifdef NCURSES_MOUSE_VERSION
130 mousemask(ALL_MOUSE_EVENTS, &oldmask);
133 screensize(&width, &height);
136 for(fg = 0; fg < 8; fg++) {
137 for(bg = 0; bg < 8; bg++) {
138 init_pair(MKPAIR(bg, fg), fg, bg);
143 putp(
"\033]0;Contiki\a");
149 signal(SIGINT, ctrlhandler);
150 atexit(console_exit);
156 static unsigned char done;
173 unsigned char new_width;
174 unsigned char new_height;
176 screensize(&new_width, &new_height);
178 if(new_width != width || new_height != height) {
194 bg = (color & 0xF0) >> 4;
196 attrs = COLOR_PAIR(MKPAIR(bg, fg));
210 return (
unsigned char)x;
220 return (
unsigned char)y;
230 bgcolor(
unsigned char c)
233 color = ((c << 4) | (color & 0xF0));
239 bordercolor(
unsigned char c)
246 screensize(
unsigned char *x,
unsigned char *y)
250 getmaxyx(stdscr, my, mx);
251 *x = (
unsigned char)mx;
252 *y = (
unsigned char)my;
256 revers(
unsigned char c)
263 console_cputc(
char c)
289 console_cputs(
char *str)
296 cclear(
unsigned char length)
303 chline(
unsigned char length)
305 hline(ACS_HLINE, length);
310 cvline(
unsigned char length)
312 vline(ACS_VLINE, length);
316 gotoxy(
unsigned char x,
unsigned char y)
322 cclearxy(
unsigned char x,
unsigned char y,
unsigned char length)
329 chlinexy(
unsigned char x,
unsigned char y,
unsigned char length)
336 cvlinexy(
unsigned char x,
unsigned char y,
unsigned char length)
343 cputsxy(
unsigned char x,
unsigned char y,
char *str)
350 cputcxy(
unsigned char x,
unsigned char y,
char c)
357 textcolor(
unsigned char c)
359 color = map_color(c);
364 console_readkey(
int k)
371 #ifdef NCURSES_MOUSE_VERSION
376 if(getmouse(&event) == OK) {
379 button =
event.bstate & BUTTON1_PRESSED
380 ||
event.bstate & BUTTON1_CLICKED
381 ||
event.bstate & BUTTON1_DOUBLE_CLICKED;
402 key = CTK_CONF_MENU_KEY;
417 key = CTK_CONF_WIDGETUP_KEY;
421 key = CTK_CONF_WIDGETDOWN_KEY;
426 key = CTK_CONF_WINDOWSWITCH_KEY;
457 k = keys[keys_out++];
490 ctk_mouse_xtoc(
unsigned short x)
496 ctk_mouse_ytoc(
unsigned short y)
502 ctk_mouse_button(
void)
char ctk_arch_key_t
The keyboard character type of the system.
unsigned char ctk_arch_keyavail(void)
Check if there is a keypress in the keyboard input queue.
#define TRUE
An alias for one, used for clarity.
ctk_arch_key_t ctk_arch_getkey(void)
Get a keypress from the keyboard input queue.
#define FALSE
An alias for zero, used for clarity.