madtty only need to control colors, let the caller deal with ncurses.
[apps/madtty.git] / madtty / madtty.c
index ce21d32..5b51618 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <locale.h>
 #include <pty.h>
 #include <signal.h>
 #include <stdio.h>
@@ -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;
+}