+static void
+set_color(WINDOW *win, chtype color)
+{
+ if (has_colors()) {
+ static bool *pairs;
+ int n = (color + 1);
+ if (pairs == 0)
+ pairs = (bool *)calloc(COLORS+1, sizeof(bool));
+ if (!pairs[n]) {
+ init_pair(n, color, my_bg);
+ pairs[n] = TRUE;
+ }
+ wattroff(win, A_COLOR);
+ wattron(win, COLOR_PAIR(n));
+ }
+}
+
+static void
+unset_color(WINDOW *win)
+{
+ if (has_colors())
+ wattrset(win, COLOR_PAIR(0));
+}
+
+static void
+look_out(int msecs)
+{
+ napms(msecs);
+ if (getch() != ERR) {
+ beep();
+ done(0);
+ }
+}
+