]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/hanoi.c
ncurses 5.0
[ncurses.git] / test / hanoi.c
index 00e3b77dbb8d8f1103f49358901e45305d8c468a..3ee64b0a0d1453017e05f9271e55fe7c91e053e6 100644 (file)
@@ -14,7 +14,7 @@
  *
  *     Date: 05.Nov.90
  *
- * $Id: hanoi.c,v 1.14 1997/05/06 23:07:55 tom Exp $
+ * $Id: hanoi.c,v 1.16 1999/10/23 15:01:01 tom Exp $
  */
 
 #include <test.priv.h>
@@ -118,8 +118,10 @@ unsigned char AutoFlag = 0;
                fprintf(stderr, "Min screen length 24 lines\n");
                return EXIT_FAILURE;
        }
-       if(AutoFlag)
+       if(AutoFlag) {
+               curs_set(0);
                leaveok(stdscr, TRUE);  /* Attempt to remove cursor */
+       }
        InitTiles(NTiles);
        DisplayTiles();
        if(AutoFlag) {
@@ -148,7 +150,6 @@ unsigned char AutoFlag = 0;
                        }
                }
        }
-       curs_set(1);
        endwin();
        return EXIT_SUCCESS;
 }
@@ -191,7 +192,7 @@ InitTiles(int NTiles)
 static void
 DisplayTiles(void)
 {
-       int Line, Peg, SlotNo;
+       int Line, peg, SlotNo;
        char TileBuf[BUFSIZ];
 
        erase();
@@ -212,16 +213,16 @@ DisplayTiles(void)
        attrset(A_NORMAL);
 
        /* Draw tiles */
-       for(Peg=0; Peg<NPEGS; Peg++) {
-               for(SlotNo=0; SlotNo<Pegs[Peg].Count; SlotNo++) {
-                       memset(TileBuf, ' ', Pegs[Peg].Length[SlotNo]);
-                       TileBuf[Pegs[Peg].Length[SlotNo]] = '\0';
+       for(peg=0; peg<NPEGS; peg++) {
+               for(SlotNo=0; SlotNo<Pegs[peg].Count; SlotNo++) {
+                       memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]);
+                       TileBuf[Pegs[peg].Length[SlotNo]] = '\0';
                        if (has_colors())
-                               attrset(COLOR_PAIR(LENTOIND(Pegs[Peg].Length[SlotNo])));
+                               attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo])));
                        else
                                attrset(A_REVERSE);
                        mvaddstr(BASELINE-(SlotNo+1),
-                               (int)(PegPos[Peg] - Pegs[Peg].Length[SlotNo]/2),
+                               (int)(PegPos[peg] - Pegs[peg].Length[SlotNo]/2),
                                TileBuf);
                }
        }