From 6c58525bf7665386fc72f1c5b1a217764c19f775 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 10 Nov 2007 15:49:21 +0100 Subject: [PATCH] madtty only need to control colors, let the caller deal with ncurses. Signed-off-by: Pierre Habouzit --- demo/boxshell.c | 12 +++++++++++- madtty/madtty.c | 18 ++++++------------ madtty/madtty.h | 3 ++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/demo/boxshell.c b/demo/boxshell.c index 505f6b9..806a1ff 100644 --- a/demo/boxshell.c +++ b/demo/boxshell.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,16 @@ int main(void) signal(SIGCHLD, handler); signal(SIGWINCH, handler); - madtty_initialize(); + setlocale(LC_ALL, ""); + initscr(); + start_color(); + noecho(); + raw(); + nodelay(stdscr, TRUE); + keypad(stdscr, TRUE); + curs_set(0); + ESCDELAY=50; + madtty_init_colors(); getmaxyx(stdscr, screen_h, screen_w); /* create a window with a frame */ diff --git a/madtty/madtty.c b/madtty/madtty.c index ce21d32..5b51618 100644 --- a/madtty/madtty.c +++ b/madtty/madtty.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -962,18 +961,8 @@ void madtty_keypress(madtty_t *t, int keycode) } } -void madtty_initialize(void) +void madtty_init_colors(void) { - setlocale(LC_ALL, ""); - initscr(); - start_color(); - noecho(); - raw(); - nodelay(stdscr, TRUE); - keypad(stdscr, TRUE); - curs_set(0); - ESCDELAY=50; - if (COLORS > 8) { use_default_colors(); assume_default_colors(-1, -1); @@ -992,3 +981,8 @@ void madtty_initialize(void) } } } + +int madtty_color_pair(int fg, int bg) +{ + return has_default ? (fg + 1) * 16 + bg + 1 : (7 - fg) * 8 + bg; +} diff --git a/madtty/madtty.h b/madtty/madtty.h index cd9e7d4..d36ddfb 100644 --- a/madtty/madtty.h +++ b/madtty/madtty.h @@ -30,7 +30,8 @@ #include #include -void madtty_initialize(void); +void madtty_init_colors(void); +int madtty_color_pair(int fg, int bg); typedef struct madtty_t madtty_t; -- 2.20.1