cursor->marked.

This commit is contained in:
Murilo Pereira 2011-05-31 02:42:10 -03:00
parent 137bb109d6
commit 79f5a34a06
3 changed files with 17 additions and 1 deletions

View File

@ -22,6 +22,7 @@ void initialize_cursor(struct cursor *cursor) {
cursor->window = newwin(0, 0, cursor->y, cursor->x);
cursor->x = CURSOR_BEGIN_X;
cursor->y = CURSOR_BEGIN_Y;
cursor->marked = false;
}
void free_cursor(struct cursor *cursor) {
@ -31,6 +32,14 @@ void free_cursor(struct cursor *cursor) {
free(cursor);
}
void mark_cursor(struct cursor *cursor) {
cursor->marked = true;
}
void unmark_cursor(struct cursor *cursor) {
cursor->marked = false;
}
void move_cursor(struct cursor *cursor, enum movement movement) {
switch (movement) {
case LEFT:

View File

@ -28,6 +28,7 @@ struct cursor {
WINDOW *window;
int x;
int y;
bool marked;
};
enum movement { LEFT, DOWN, UP, RIGHT };
@ -37,6 +38,8 @@ extern struct deck *deck;
void allocate_cursor(struct cursor **);
void initialize_cursor(struct cursor *);
void free_cursor(struct cursor *);
void mark_cursor(struct cursor *);
void unmark_cursor(struct cursor *);
void move_cursor(struct cursor *, enum movement);
#endif

View File

@ -144,7 +144,11 @@ void draw_deck(struct deck *deck) {
}
void draw_cursor(struct cursor *cursor) {
mvwaddch(cursor->window, cursor->y, cursor->x, '*');
if (cursor->marked) {
mvwaddch(cursor->window, cursor->y, cursor->x, '@');
} else {
mvwaddch(cursor->window, cursor->y, cursor->x, '*');
}
wrefresh(cursor->window);
}