Signed-off-by: Pierre Habouzit <madcoder@debian.org>
#include <ncurses.h>
#include <fcntl.h>
+#include <locale.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
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 */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <locale.h>
#include <pty.h>
#include <signal.h>
#include <stdio.h>
}
}
-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);
}
}
}
+
+int madtty_color_pair(int fg, int bg)
+{
+ return has_default ? (fg + 1) * 16 + bg + 1 : (7 - fg) * 8 + bg;
+}
#include <unistd.h>
#include <wchar.h>
-void madtty_initialize(void);
+void madtty_init_colors(void);
+int madtty_color_pair(int fg, int bg);
typedef struct madtty_t madtty_t;