Correct the prompt-setting.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 5 Feb 2005 23:24:02 +0000 (23:24 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 5 Feb 2005 23:24:02 +0000 (23:24 +0000)
battle.c
io.c
moving.c
reports.c
sst.c
sst.h

index df1314839df4fe18ce90622869bbe0974f857c86..0f760d9bb73b74e324abdb1a17c3db4fdad65017 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -186,9 +186,9 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
        deltax /= bigger;
        deltay /= bigger;
         if (game.damage[DSRSENS]==0 || condit==IHDOCKED) 
-           setwnd(SRSCAN_WINDOW);
+           setwnd(srscan_window);
        else 
-           setwnd(LOWER_WINDOW);
+           setwnd(message_window);
        /* Loop to move a single torpedo */
        for (l=1; l <= 15; l++) {
                x += deltax;
@@ -202,7 +202,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
                wait = 1;
                if (iquad==IHDOT) continue;
                /* hit something */
-               setwnd(LOWER_WINDOW);
+               setwnd(message_window);
                switch(iquad) {
                        case IHE: /* Hit our ship */
                        case IHF:
@@ -397,8 +397,8 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
                }
                break;
        }
-        if(curwnd!=LOWER_WINDOW) {
-           setwnd(LOWER_WINDOW);
+        if(curwnd!=message_window) {
+           setwnd(message_window);
        }
        if (shoved) {
                game.quad[jx][jy]=iquad;
diff --git a/io.c b/io.c
index 54b109bde0a7e3224eaeedcd1ac8e9cb2ee89547..6899ab02a2a1cdea8deaf87ae4a8b8029dab4c62 100644 (file)
--- a/io.c
+++ b/io.c
@@ -32,6 +32,7 @@ static void outro(void)
 void iostart(int usecurses) 
 {
     if ((curses = usecurses)) {
+
        if (atexit(outro)){
            fprintf(stderr,"Unable to register outro(), exiting...\n");
            exit(1);
@@ -43,14 +44,30 @@ void iostart(int usecurses)
        (void)saveterm();
        (void)nonl();
        (void)cbreak();
+#ifdef FOO
+       {
+       int background = COLOR_WHITE;
+       start_color();
+       init_pair(COLOR_BLACK, COLOR_BLACK, background);
+       init_pair(COLOR_GREEN, COLOR_GREEN, background);
+       init_pair(COLOR_RED, COLOR_RED, background);
+       init_pair(COLOR_CYAN, COLOR_CYAN, background);
+       init_pair(COLOR_WHITE, COLOR_WHITE, background);
+       init_pair(COLOR_MAGENTA, COLOR_MAGENTA, background);
+       init_pair(COLOR_BLUE, COLOR_BLUE, background);
+       init_pair(COLOR_YELLOW, COLOR_YELLOW, background);
+       }
+#endif /* A_COLOR */
        //(void)noecho();
-       FULLSCREEN_WINDOW = stdscr;
-       SRSCAN_WINDOW     = newwin(12, 25, 0,       0);
+       fullscreen_window = stdscr;
+       srscan_window     = newwin(12, 25, 0,       0);
        REPORT_WINDOW     = newwin(10, 0,  1,       25);
-       LRSCAN_WINDOW     = newwin(10, 0,  0,       64); 
-       LOWER_WINDOW      = newwin(0,  0,  12,      0);
-       BOTTOM_WINDOW     = newwin(1,  0,  LINES-1, 0); 
-       scrollok(LOWER_WINDOW, TRUE);
+       lrscan_window     = newwin(10, 0,  0,       64); 
+       message_window      = newwin(0,  0,  12,      0);
+       prompt_window     = newwin(1,  0,  LINES-1, 0); 
+       scrollok(message_window, TRUE);
+       setwnd(fullscreen_window);
+       textcolor(DEFAULT);
     }
 }
 
@@ -81,13 +98,13 @@ void pause_game(int i)
     }
     if (curses) {
        drawmaps(0);
-       setwnd(BOTTOM_WINDOW);
-       wclear(BOTTOM_WINDOW);
-       waddstr(BOTTOM_WINDOW, prompt);
-       wgetnstr(BOTTOM_WINDOW, buf, sizeof(buf));
-       wclear(BOTTOM_WINDOW);
-       wrefresh(BOTTOM_WINDOW);
-       setwnd(LOWER_WINDOW);
+       setwnd(prompt_window);
+       wclear(prompt_window);
+       waddstr(prompt_window, prompt);
+       wgetnstr(prompt_window, buf, sizeof(buf));
+       wclear(prompt_window);
+       wrefresh(prompt_window);
+       setwnd(message_window);
     } else {
        putchar('\n');
        proutn(prompt);
@@ -185,7 +202,7 @@ void setwnd(WINDOW *wnd)
 {
     if (curses) {
      curwnd=wnd;
-     curs_set(wnd == FULLSCREEN_WINDOW || wnd == LOWER_WINDOW);
+     curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
     }
 }
 
@@ -212,14 +229,68 @@ void textcolor (int color)
 {
     if (curses) {
        wattroff(curwnd, A_REVERSE);
-       // FIXME
-   }
+#ifdef FOO
+       switch(color) {
+       case DEFAULT: 
+           wattrset(curwnd, 0);
+           break;
+       case BLACK: 
+           wattron(curwnd, COLOR_PAIR(BLACK));
+           break;
+       case BLUE: 
+           wattron(curwnd, COLOR_PAIR(BLUE));
+           break;
+       case GREEN: 
+           wattron(curwnd, COLOR_PAIR(GREEN));
+           break;
+       case CYAN: 
+           wattron(curwnd, COLOR_PAIR(CYAN));
+           break;
+       case RED: 
+           wattron(curwnd, COLOR_PAIR(RED));
+           break;
+       case MAGENTA: 
+           wattron(curwnd, COLOR_PAIR(MAGENTA));
+           break;
+       case BROWN: 
+           wattron(curwnd, COLOR_PAIR(YELLOW));
+           break;
+       case LIGHTGRAY: 
+           wattron(curwnd, COLOR_PAIR(WHITE));
+           break;
+       case DARKGRAY: 
+           wattron(curwnd, COLOR_PAIR(BLACK) | A_BOLD);
+           break;
+       case LIGHTBLUE: 
+           wattron(curwnd, COLOR_PAIR(BLUE) | A_BOLD);
+           break;
+       case LIGHTGREEN: 
+           wattron(curwnd, COLOR_PAIR(GREEN) | A_BOLD);
+           break;
+       case LIGHTCYAN: 
+           wattron(curwnd, COLOR_PAIR(CYAN) | A_BOLD);
+           break;
+       case LIGHTRED: 
+           wattron(curwnd, COLOR_PAIR(RED) | A_BOLD);
+           break;
+       case LIGHTMAGENTA: 
+           wattron(curwnd, COLOR_PAIR(MAGENTA) | A_BOLD);
+           break;
+       case YELLOW: 
+           wattron(curwnd, COLOR_PAIR(YELLOW) | A_BOLD);
+           break;
+       case WHITE:
+           wattron(curwnd, COLOR_PAIR(WHITE) | A_BOLD);
+           break;
+       }
+#endif /* FOO */
+    }
 }
 
 void highvideo (void)
 {
     if (curses) {
-       attron(A_REVERSE);
+       wattron(curwnd, A_REVERSE);
     }
 }
  
@@ -237,7 +308,7 @@ void drawmaps(short l)
        if (l == 1) 
            sensor();
        if (l != 2) {
-           setwnd(SRSCAN_WINDOW);
+           setwnd(srscan_window);
            wmove(curwnd, 0, 0);
            enqueue("no");
            srscan(SCAN_FULL);
@@ -245,9 +316,9 @@ void drawmaps(short l)
            wclear(REPORT_WINDOW);
            wmove(REPORT_WINDOW, 0, 0);
            srscan(SCAN_NO_LEFTSIDE);
-           setwnd(LRSCAN_WINDOW);
-           wclear(LRSCAN_WINDOW);
-           wmove(LRSCAN_WINDOW, 0, 0);
+           setwnd(lrscan_window);
+           wclear(lrscan_window);
+           wmove(lrscan_window, 0, 0);
            enqueue("l");
            lrscan();
        }
@@ -258,20 +329,20 @@ void boom(int ii, int jj)
 /* enemy fall down, go boom */ 
 {
     if (curses) {
-       setwnd(SRSCAN_WINDOW);
+       setwnd(srscan_window);
        drawmaps(2);
-       wmove(SRSCAN_WINDOW, ii*2+3, jj+2);
-       wattron(SRSCAN_WINDOW, A_REVERSE);
-       waddch(SRSCAN_WINDOW, game.quad[ii][jj]);
-       wrefresh(SRSCAN_WINDOW);
+       wmove(srscan_window, ii*2+3, jj+2);
+       wattron(srscan_window, A_REVERSE);
+       waddch(srscan_window, game.quad[ii][jj]);
+       wrefresh(srscan_window);
        sound(500);
        delay(1000);
        nosound();
-       wmove(SRSCAN_WINDOW, ii*2+3, jj+2);
-       wattroff(SRSCAN_WINDOW, A_REVERSE);
-       waddch(SRSCAN_WINDOW, game.quad[ii][jj]);
-       wrefresh(SRSCAN_WINDOW);
-       setwnd(LOWER_WINDOW);
+       wmove(srscan_window, ii*2+3, jj+2);
+       wattroff(srscan_window, A_REVERSE);
+       waddch(srscan_window, game.quad[ii][jj]);
+       wrefresh(srscan_window);
+       setwnd(message_window);
        delay(500);
     }
 } 
@@ -281,7 +352,7 @@ void warble(void)
 {
     if (curses) {
        drawmaps(1);
-       setwnd(LOWER_WINDOW);
+       setwnd(message_window);
        sound(50);
        delay(1000);
        nosound();
@@ -335,8 +406,8 @@ void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, i
 void makechart(void) 
 {
     if (curses) {
-       setwnd(LOWER_WINDOW);
-       wclear(LOWER_WINDOW);
+       setwnd(message_window);
+       wclear(message_window);
        chart(0);
     }
 }
index 1797e1ef7e820e5e788325a2aa8935b6c949c1f7..887977afc6fbca9be2088b9acec2922bceb52ff1 100644 (file)
--- a/moving.c
+++ b/moving.c
@@ -986,16 +986,16 @@ void help(void) {
                 textcolor(RED);
                prout("fails.");
                 delay(500);
-                textcolor(LIGHTGRAY);
+                textcolor(DEFAULT);
        }
        if (l > 3) {
                finish(FMATERIALIZE);
                return;
        }
        game.quad[ix][iy]=ship;
-       textcolor(WHITE);
+       textcolor(GREEN);
        prout("succeeds.");
-       textcolor(LIGHTGRAY);
+       textcolor(DEFAULT);
        dock(0);
        skip(1);
        prout("Lt. Uhura-  \"Captain, we made it!\"");
index 54c73d98ad2131478eafffe32c5fd26203f8c3b1..98721c6961240a63ad99221c23ac362f024a5880 100644 (file)
--- a/reports.c
+++ b/reports.c
@@ -268,8 +268,8 @@ int srscan(int l) {
                                                 case IHRED: textcolor(RED); break;
                                                 case IHGREEN: textcolor(GREEN); break;
                                                 case IHYELLOW: textcolor(YELLOW); break;
-                                                case IHDOCKED: textcolor(LIGHTGRAY); break;
-                                                case IHDEAD: textcolor(WHITE);
+                                                case IHDOCKED: textcolor(CYAN); break;
+                                                case IHDEAD: textcolor(BROWN);
                                         }
                                         if (game.quad[i][j] != ship) 
                                            highvideo();
@@ -277,7 +277,7 @@ int srscan(int l) {
                                    if (game.quad[i][j] & DAMAGED) 
                                       highvideo();
                                    proutn("%c ",game.quad[i][j] & ~DAMAGED);
-                                   textcolor(LIGHTGRAY);
+                                   textcolor(DEFAULT);
                                 }
                                else
                                        proutn("- ");
diff --git a/sst.c b/sst.c
index dc26b35442556fcf1b04a2747ec573f8d1f8c2f7..55cdaead12af6c9fa5035a9305c4d25a18fdc2c6 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -199,11 +199,11 @@ static void helpme(void) {
        key = scan();
        while (TRUE) {
                if (key == IHEOL) {
-                        setwnd(BOTTOM_WINDOW);
+                        setwnd(prompt_window);
                         proutn("Help on what command? ");
                        key = scan();
                }
-                setwnd(LOWER_WINDOW);
+                setwnd(message_window);
                if (key == IHEOL) return;
                for (i = 0; i < NUMCOMMANDS; i++) {
                    if (strcasecmp(commands[i].name, citem)==0) {
@@ -271,7 +271,7 @@ void enqueue(char *s) {
 static void makemoves(void) {
        int i, hitme;
         clrscr();
-        setwnd(LOWER_WINDOW);
+        setwnd(message_window);
        while (TRUE) { /* command loop */
                 drawmaps(1);
                 while (TRUE)  { /* get a command */
@@ -280,7 +280,7 @@ static void makemoves(void) {
                        Time = 0.0;
                        i = -1;
                        chew();
-                        setwnd(BOTTOM_WINDOW);
+                        setwnd(prompt_window);
                         clrscr();
                        proutn("COMMAND> ");
                         if (scan() == IHEOL) {
@@ -289,7 +289,7 @@ static void makemoves(void) {
                         }
                         ididit=0;
                         clrscr();
-                        setwnd(LOWER_WINDOW);
+                        setwnd(message_window);
                         clrscr();
                        for (i=0; i < ABANDON; i++)
                            if (isit(commands[i].name)) {
@@ -492,7 +492,7 @@ int main(int argc, char **argv) {
                strcat(line, " ");
        }
        while (TRUE) { /* Play a game */
-               setwnd(FULLSCREEN_WINDOW);
+               setwnd(fullscreen_window);
                clrscr();
                prelim();
                setup(line[0] == '\0');
@@ -618,9 +618,9 @@ int scan(void) {
                }
                cgetline(line, sizeof(line));
                 fflush(stdin);
-                if (curwnd==BOTTOM_WINDOW){
+                if (curwnd==prompt_window){
                    clrscr();
-                   setwnd(LOWER_WINDOW);
+                   setwnd(message_window);
                    clrscr();
                 }
                linep = line;
diff --git a/sst.h b/sst.h
index cf44c7374f8b11a662be414528cb2ec60c0e1cde..8a1f44d10872e13de952fb73a3f787c16ecfc8c0 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -451,12 +451,12 @@ void enqueue(char *s);
 #define SCAN_STATUS            3
 #define SCAN_NO_LEFTSIDE       4
 
-WINDOW *FULLSCREEN_WINDOW;
-WINDOW *SRSCAN_WINDOW;
+WINDOW *fullscreen_window;
+WINDOW *srscan_window;
 WINDOW *REPORT_WINDOW;
-WINDOW *LRSCAN_WINDOW;
-WINDOW *LOWER_WINDOW;
-WINDOW *BOTTOM_WINDOW;
+WINDOW *lrscan_window;
+WINDOW *message_window;
+WINDOW *prompt_window;
 
 extern void clreol(void);
 extern void clrscr(void);
@@ -464,6 +464,7 @@ extern void textcolor(int color);
 extern void highvideo(void);
 
 enum COLORS {
+   DEFAULT,
    BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
    DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
 };