From 413256523cf2f89884e38542c8b17cba95b6d87b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 8 May 2010 17:46:47 +0000 Subject: [PATCH] If using ncurses, use color to hilight games with too big terminals in watching menu. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@563 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- configure.ac | 11 ++++++++++- dgamelaunch.c | 18 +++++++++++++++++- dgamelaunch.h | 8 ++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index e09d6d4..b0eafdc 100644 --- a/configure.ac +++ b/configure.ac @@ -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.]) ]) diff --git a/dgamelaunch.c b/dgamelaunch.c index 4c3fb26..385c044 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -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 } /* ************************************************************* */ diff --git a/dgamelaunch.h b/dgamelaunch.h index 2aa6acb..c8f3133 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -23,6 +23,14 @@ #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 */