]> skyeroc.xyz Git - dgamelaunch/commitdiff
If using ncurses, use color to hilight games with too big terminals in watching menu.
authorPasi Kallinen <paxed@alt.org>
Sat, 8 May 2010 17:46:47 +0000 (17:46 +0000)
committerPasi Kallinen <paxed@alt.org>
Sat, 8 May 2010 17:46:47 +0000 (17:46 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@563 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

configure.ac
dgamelaunch.c
dgamelaunch.h

index e09d6d4989b8963263ec338441494a4379bd2f78..b0eafdcf3917d6e09c25449be70ee9fdc48c8b99 100644 (file)
@@ -70,8 +70,17 @@ fi
 AC_SUBST(MKDEP)
 AC_SUBST(MKDEP_DIRECT)
 
+AC_SEARCH_LIBS(use_default_colors, [ncurses],
+[
+   AC_MSG_RESULT([Using ncurses and color.])
+   AC_DEFINE(USE_NCURSES_COLOR,1,[Use ncurses and color])
+],
+[
+   AC_MSG_RESULT([Not using ncurses, not using color.])
+])
+
 AC_PROG_INSTALL
-AC_SEARCH_LIBS(initscr, [curses ncurses], [], [
+AC_SEARCH_LIBS(initscr, [ncurses curses], [], [
    AC_MSG_ERROR([Cannot find curses or ncurses devel libs.])
 ])
 
index 4c3fb26ab5190458ae2fddaf237dcf002c379599..385c044c7b6813e00b739d51c4141ee32544aefa 100644 (file)
@@ -713,12 +713,17 @@ inprogressmenu (int gameid)
 
          for (di = 0; di < ARRAY_SIZE(watchcols); di++) {
              char tmpbuf[80];
+             int hilite = 0;
              switch (watchcols[di].dat) {
              default: break;
              case 0: tmpbuf[0] = selectorchars[i]; tmpbuf[1] = '\0'; break;
              case 1: snprintf(tmpbuf, 80, "%s", games[i + offset]->name); break;
              case 2: snprintf(tmpbuf, 80, "%s", myconfig[games[i + offset]->gamenum]->shortname); break;
-             case 3: snprintf(tmpbuf, 80, "%s", gametype); break;
+             case 3:
+                 snprintf(tmpbuf, 80, "%s", gametype);
+                 if ((games[i+offset]->ws_col > COLS || games[i+offset]->ws_row > LINES))
+                     hilite = CLR_RED;
+                 break;
              case 4: snprintf(tmpbuf, 80, "%s %s", games[i + offset]->date, games[i + offset]->time); break;
              case 5: snprintf(tmpbuf, 80, "%s", idletime); break;
 #ifdef USE_SHMEM
@@ -726,7 +731,12 @@ inprogressmenu (int gameid)
 #endif
              }
              tmpbuf[79] = '\0';
+             if (hilite) attron(hilite);
              mvprintw(top_banner_hei + 1 + i, watchcols[di].x, watchcols[di].fmt, tmpbuf);
+             if (hilite) {
+                 attron(CLR_NORMAL);
+                 hilite = 0;
+             }
          }
 
          if (i + offset == selected) attroff(selected_attr);
@@ -1293,6 +1303,12 @@ initcurses ()
   nonl ();
   intrflush (stdscr, FALSE);
   keypad (stdscr, TRUE);
+#ifdef USE_NCURSES_COLOR
+  start_color();
+  use_default_colors();
+  init_pair(1, -1, -1);
+  init_pair(2, COLOR_RED, -1);
+#endif
 }
 
 /* ************************************************************* */
index 2aa6acb2e34bf5a88d83565adfdb4454e6051125..c8f31335e55178818c33fd37800149e859be5a62 100644 (file)
 #define DGL_PASSWDLEN 20 /* max. length of passwords */
 #define DGL_MAILMSGLEN 80 /* max. length of mail message */
 
+#ifdef USE_NCURSES_COLOR
+# define CLR_NORMAL  COLOR_PAIR(1)   | A_NORMAL
+# define CLR_RED     COLOR_PAIR(2)   | A_NORMAL
+#else
+# define CLR_NORMAL  0
+# define CLR_RED     0
+#endif
+
 typedef enum
 {
     DGLTIME_DGLSTART = 0,      /* when someone telnets in */