|
@@ -20,7 +20,7 @@ enum dirs {
|
|
|
D /* down */
|
|
D /* down */
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-static size_t delay = 500;
|
|
|
|
|
|
|
+static size_t delay = 150;
|
|
|
|
|
|
|
|
/* result window */
|
|
/* result window */
|
|
|
static WINDOW * winR;
|
|
static WINDOW * winR;
|
|
@@ -31,14 +31,19 @@ static void worm(WINDOW *win, int x, int y, char c0, char repl)
|
|
|
static int ax, ay;
|
|
static int ax, ay;
|
|
|
static char ac = '*';
|
|
static char ac = '*';
|
|
|
|
|
|
|
|
- wattron(win, A_REVERSE | A_BOLD);
|
|
|
|
|
- mvwprintw(win, y + 1, x + 1, "%c", c0);
|
|
|
|
|
- wattroff(win, A_REVERSE | A_BOLD);
|
|
|
|
|
- if (ac != '*')
|
|
|
|
|
- mvwprintw(win, ay + 1, ax + 1, "%c", ac);
|
|
|
|
|
|
|
+ wattron(win, A_REVERSE);
|
|
|
|
|
+ mvwaddch(win, y + 1, x + 1, c0);
|
|
|
|
|
+ wattroff(win, A_REVERSE);
|
|
|
|
|
+ if (ac != '*') {
|
|
|
|
|
+ if (ac != '.')
|
|
|
|
|
+ wattron(win, COLOR_PAIR(1));
|
|
|
|
|
+ mvwaddch(win, ay, ax, ac);
|
|
|
|
|
+ if (ac != ' ')
|
|
|
|
|
+ wattroff(win, COLOR_PAIR(1));
|
|
|
|
|
+ }
|
|
|
wrefresh(win);
|
|
wrefresh(win);
|
|
|
- ax = x;
|
|
|
|
|
- ay = y;
|
|
|
|
|
|
|
+ ax = x + 1;
|
|
|
|
|
+ ay = y + 1;
|
|
|
ac = repl;
|
|
ac = repl;
|
|
|
usleep(delay * 1000);
|
|
usleep(delay * 1000);
|
|
|
}
|
|
}
|
|
@@ -52,7 +57,7 @@ static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array co
|
|
|
int x = 0, y = 0;
|
|
int x = 0, y = 0;
|
|
|
char c0 = '<';
|
|
char c0 = '<';
|
|
|
|
|
|
|
|
- WINDOW * win = newwin(14, 18, 1, 40);
|
|
|
|
|
|
|
+ WINDOW * win = newwin(12, 17, 1, 49);
|
|
|
|
|
|
|
|
curs_set(0);
|
|
curs_set(0);
|
|
|
box(win, 0, 0);
|
|
box(win, 0, 0);
|
|
@@ -64,9 +69,13 @@ static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array co
|
|
|
while((c = src->items[y][x]) != ' ') {
|
|
while((c = src->items[y][x]) != ' ') {
|
|
|
/* store */
|
|
/* store */
|
|
|
if (c != '*') {
|
|
if (c != '*') {
|
|
|
- r[n++] = c;
|
|
|
|
|
worm(win, x, y, c0, c);
|
|
worm(win, x, y, c0, c);
|
|
|
- mvwprintw(winR, 1, 1, "%s", r);
|
|
|
|
|
|
|
+ if (n > 0)
|
|
|
|
|
+ mvwaddch(winR, 1, n , r[n - 1]);
|
|
|
|
|
+ r[n++] = c;
|
|
|
|
|
+ wattron (winR, COLOR_PAIR(2));
|
|
|
|
|
+ mvwaddch(winR, 1, n, c);
|
|
|
|
|
+ wattroff(winR, COLOR_PAIR(2));
|
|
|
wrefresh(winR);
|
|
wrefresh(winR);
|
|
|
} else
|
|
} else
|
|
|
worm(win, x, y, c0, '.');
|
|
worm(win, x, y, c0, '.');
|
|
@@ -100,8 +109,12 @@ static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array co
|
|
|
/* ouch */
|
|
/* ouch */
|
|
|
if (tx > 14 || tx < 0 || ty <0 || ty > 9)
|
|
if (tx > 14 || tx < 0 || ty <0 || ty > 9)
|
|
|
break;
|
|
break;
|
|
|
- if ((c = src->items[ty][tx]) == ' ')
|
|
|
|
|
|
|
+ if ((c = src->items[ty][tx]) == ' ') {
|
|
|
|
|
+ wattron(win,COLOR_PAIR(3));
|
|
|
|
|
+ mvwaddch(win, ty + 1, tx + 1, c);
|
|
|
|
|
+ wattroff(win, COLOR_PAIR(3));
|
|
|
break;
|
|
break;
|
|
|
|
|
+ }
|
|
|
/* valid next */
|
|
/* valid next */
|
|
|
x = tx;
|
|
x = tx;
|
|
|
y = ty;
|
|
y = ty;
|
|
@@ -161,6 +174,10 @@ static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array co
|
|
|
|
|
|
|
|
end:
|
|
end:
|
|
|
worm(win, x , y , ' ', ' ');
|
|
worm(win, x , y , ' ', ' ');
|
|
|
|
|
+ if (n > 1) {
|
|
|
|
|
+ mvwaddch(winR, 1, n, r[n -1]);
|
|
|
|
|
+ wrefresh(winR);
|
|
|
|
|
+ }
|
|
|
delwin(win);
|
|
delwin(win);
|
|
|
return r;
|
|
return r;
|
|
|
}
|
|
}
|
|
@@ -168,7 +185,7 @@ end:
|
|
|
/* puzzle display */
|
|
/* puzzle display */
|
|
|
static void print_it(truc_array src)
|
|
static void print_it(truc_array src)
|
|
|
{
|
|
{
|
|
|
- WINDOW * win = newwin(14, 18, 1, 1);
|
|
|
|
|
|
|
+ WINDOW * win = newwin(12, 17, 1, 1);
|
|
|
box(win, 0, 0);
|
|
box(win, 0, 0);
|
|
|
for (size_t j= 0; j < 10; ++j) {
|
|
for (size_t j= 0; j < 10; ++j) {
|
|
|
mvwprintw(win, j + 1, 1, "%s", src.items[j]);
|
|
mvwprintw(win, j + 1, 1, "%s", src.items[j]);
|
|
@@ -214,12 +231,15 @@ int main(int argc, char *argv[])
|
|
|
initscr();
|
|
initscr();
|
|
|
nonl();
|
|
nonl();
|
|
|
noecho();
|
|
noecho();
|
|
|
- winR = newwin(3, 65, 20, 1);
|
|
|
|
|
|
|
+ winR = newwin(3, 65, 13, 1);
|
|
|
box(winR, 0, 0);
|
|
box(winR, 0, 0);
|
|
|
wrefresh(winR);
|
|
wrefresh(winR);
|
|
|
|
|
|
|
|
|
|
+ start_color();
|
|
|
|
|
+ init_pair(1, COLOR_RED, COLOR_BLACK);
|
|
|
|
|
+ init_pair(2, COLOR_BLACK, COLOR_MAGENTA);
|
|
|
|
|
+ init_pair(3, COLOR_BLUE, COLOR_BLUE);
|
|
|
print_it(a);
|
|
print_it(a);
|
|
|
-
|
|
|
|
|
r = get_it(&a);
|
|
r = get_it(&a);
|
|
|
dallocx(r, 0);
|
|
dallocx(r, 0);
|
|
|
delwin(winR);
|
|
delwin(winR);
|