mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-14 09:28:59 +00:00
ctk-curses: add some comments for clarity
This commit is contained in:
parent
9372a153dd
commit
45662ac1ef
@ -78,6 +78,7 @@ static unsigned char ctk_color_map[8] = {
|
|||||||
COLOR_WHITE
|
COLOR_WHITE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static unsigned char map_color(unsigned char color)
|
static unsigned char map_color(unsigned char color)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -85,17 +86,18 @@ static unsigned char map_color(unsigned char color)
|
|||||||
c |= ctk_color_map[(color >> 4) & 0x07] << 4;
|
c |= ctk_color_map[(color >> 4) & 0x07] << 4;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
ctrlhandler(int sig)
|
ctrlhandler(int sig)
|
||||||
{
|
{
|
||||||
|
/* make sure we call console_exit() to leave the terminal in a clean state */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
console_init(void)
|
console_init(void)
|
||||||
{
|
{
|
||||||
|
/* mouse support is ncurses-specific */
|
||||||
#ifdef NCURSES_MOUSE_VERSION
|
#ifdef NCURSES_MOUSE_VERSION
|
||||||
mmask_t oldmask;
|
mmask_t oldmask;
|
||||||
#endif
|
#endif
|
||||||
@ -112,6 +114,10 @@ console_init(void)
|
|||||||
/* will display an error and exit if the term can't be initialized */
|
/* will display an error and exit if the term can't be initialized */
|
||||||
/*setupterm((char *)0, STDOUT_FILENO, (int *)0); */
|
/*setupterm((char *)0, STDOUT_FILENO, (int *)0); */
|
||||||
|
|
||||||
|
/* references:
|
||||||
|
* http://linux.die.net/man/3/ncurses
|
||||||
|
* http://linux.die.net/HOWTO/NCURSES-Programming-HOWTO/index.html
|
||||||
|
*/
|
||||||
initscr();
|
initscr();
|
||||||
start_color();
|
start_color();
|
||||||
cbreak();
|
cbreak();
|
||||||
@ -148,6 +154,7 @@ console_init(void)
|
|||||||
/* don't block on read, just timeout 1ms */
|
/* don't block on read, just timeout 1ms */
|
||||||
timeout(1);
|
timeout(1);
|
||||||
|
|
||||||
|
/* make sure we return the terminal in a clean state */
|
||||||
signal(SIGINT, ctrlhandler);
|
signal(SIGINT, ctrlhandler);
|
||||||
atexit(console_exit);
|
atexit(console_exit);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user