From 28ce3e07bdc939af5f03398fceddea53b08447a7 Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Fri, 3 Jun 2011 03:09:14 -0300 Subject: [PATCH] Removed stupid curses files. --- Makefile | 2 -- src/curses.c | 31 ------------------------------- src/curses.h | 8 -------- src/game.c | 7 ++++--- src/keyboard.c | 6 +++--- src/ttysolitaire.c | 26 +++++++++++++++++++------- tests/curses_test.c | 7 ------- tests/ttysolitaire_test.c | 1 - tests/ttysolitaire_test.h | 1 - 9 files changed, 26 insertions(+), 63 deletions(-) delete mode 100644 src/curses.c delete mode 100644 src/curses.h delete mode 100644 tests/curses_test.c diff --git a/Makefile b/Makefile index 0b1578b..951b9ca 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,6 @@ SRC_OBJECTS = ${SRC_DIR}/common.o \ ${SRC_DIR}/card.o \ ${SRC_DIR}/stack.o \ ${SRC_DIR}/deck.o \ - ${SRC_DIR}/curses.o \ ${SRC_DIR}/cursor.o \ ${SRC_DIR}/keyboard.o \ ${SRC_DIR}/display.o \ @@ -23,7 +22,6 @@ TESTS_OBJECTS = ${TESTS_DIR}/frame_test.o \ ${TESTS_DIR}/card_test.o \ ${TESTS_DIR}/stack_test.o \ ${TESTS_DIR}/deck_test.o \ - ${TESTS_DIR}/curses_test.o \ ${TESTS_DIR}/cursor_test.o \ ${TESTS_DIR}/keyboard_test.o \ ${TESTS_DIR}/display_test.o \ diff --git a/src/curses.c b/src/curses.c deleted file mode 100644 index e6fa2af..0000000 --- a/src/curses.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include -#include "curses.h" - -void initialize_curses() { - setlocale(LC_ALL, "en_US.utf-8"); /* Support unicode characters. */ - initscr(); - raw(); /* Disable line buffers. */ - noecho(); - keypad(stdscr, TRUE); /* Enable arrow keys. */ - start_color(); /* I want colors. */ - curs_set(FALSE); /* Invisible cursor. */ - set_escdelay(0); - assume_default_colors(COLOR_WHITE, COLOR_GREEN); - - init_pair(1, COLOR_BLACK, COLOR_WHITE); - init_pair(2, COLOR_RED, COLOR_WHITE); - init_pair(3, COLOR_WHITE, COLOR_BLUE); - init_pair(4, COLOR_WHITE, COLOR_GREEN); -} - -void end_curses() { - endwin(); - puts("Game finished."); -} - -void clear_screen() { - clear(); - refresh(); -} diff --git a/src/curses.h b/src/curses.h deleted file mode 100644 index 1d35c18..0000000 --- a/src/curses.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef TTY_SOLITAIRE_CURSES_H -#define TTY_SOLITAIRE_CURSES_H - -void initialize_curses(); -void end_curses(); -void clear_screen(); - -#endif diff --git a/src/game.c b/src/game.c index b4e2d71..9cd1eaf 100644 --- a/src/game.c +++ b/src/game.c @@ -21,7 +21,7 @@ static int foundation_begin_x(int x) { case 2: return(FOUNDATION_2_BEGIN_X); break; case 3: return(FOUNDATION_3_BEGIN_X); break; default: - end_curses(); + endwin(); end_game(); assert(false && "invalid stack"); } @@ -37,7 +37,7 @@ static int maneuvre_begin_x(int x) { case 5: return(MANEUVRE_5_BEGIN_X); break; case 6: return(MANEUVRE_6_BEGIN_X); break; default: - end_curses(); + endwin(); end_game(); assert(false && "maneuvre_begin_x called x < 0 || x > 6"); } @@ -167,7 +167,8 @@ void greet_player() { } void initialize_game() { - clear_screen(); + clear(); + refresh(); allocate_cursor(&cursor); initialize_cursor(cursor); diff --git a/src/keyboard.c b/src/keyboard.c index 3661216..2193efd 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -19,7 +19,7 @@ static struct stack **cursor_stack(struct cursor *cursor) { case CURSOR_FOUNDATION_3_X: return(&(deck->foundation[3])); case CURSOR_INVALID_SPOT_X: return(NULL); default: - end_curses(); + endwin(); end_game(); assert(false && "invalid stack"); } @@ -33,7 +33,7 @@ static struct stack **cursor_stack(struct cursor *cursor) { case CURSOR_MANEUVRE_5_X: return(&(deck->maneuvre[5])); case CURSOR_MANEUVRE_6_X: return(&(deck->maneuvre[6])); default: - end_curses(); + endwin(); end_game(); assert(false && "invalid stack"); } @@ -121,7 +121,7 @@ static void handle_card_movement(struct cursor *cursor) { return; case 'q': case 'Q': - end_curses(); + endwin(); end_game(); exit(0); } diff --git a/src/ttysolitaire.c b/src/ttysolitaire.c index 59f1d65..ec06a60 100644 --- a/src/ttysolitaire.c +++ b/src/ttysolitaire.c @@ -1,9 +1,8 @@ -#include #include +#include #include "game.h" #include "keyboard.h" -#include "curses.h" const char *program_name; @@ -11,7 +10,20 @@ int main(int argc, const char *argv[]) { program_name = *argv; int key; - initialize_curses(); + setlocale(LC_ALL, "en_US.utf-8"); /* Support unicode characters. */ + initscr(); + raw(); /* Disable line buffers. */ + noecho(); + keypad(stdscr, TRUE); /* Enable arrow keys. */ + start_color(); /* I want colors. */ + curs_set(FALSE); /* Invisible cursor. */ + set_escdelay(0); + assume_default_colors(COLOR_WHITE, COLOR_GREEN); + init_pair(1, COLOR_BLACK, COLOR_WHITE); + init_pair(2, COLOR_RED, COLOR_WHITE); + init_pair(3, COLOR_WHITE, COLOR_BLUE); + init_pair(4, COLOR_WHITE, COLOR_GREEN); + greet_player(); while (key != KEY_SPACEBAR) { @@ -21,16 +33,16 @@ int main(int argc, const char *argv[]) { break; case 'q': case 'Q': - end_curses(); - exit(0); + endwin(); + return(0); } } while (1) { if ((key = getch()) == 'q' || key == 'Q') { - end_curses(); + endwin(); end_game(); - exit(0); + return(0); } else { handle_keyboard_event(key); } diff --git a/tests/curses_test.c b/tests/curses_test.c deleted file mode 100644 index b4470a9..0000000 --- a/tests/curses_test.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include -#include "../src/curses.h" - -void test_curses() { - assert(true); -} diff --git a/tests/ttysolitaire_test.c b/tests/ttysolitaire_test.c index 5ad018d..17b1836 100644 --- a/tests/ttysolitaire_test.c +++ b/tests/ttysolitaire_test.c @@ -13,7 +13,6 @@ int main(int argc, const char *argv[]) { test_game(); test_keyboard(); test_stack(); - test_curses(); test_test_helper(); return(0); diff --git a/tests/ttysolitaire_test.h b/tests/ttysolitaire_test.h index 67fce1b..231a7b4 100644 --- a/tests/ttysolitaire_test.h +++ b/tests/ttysolitaire_test.h @@ -9,7 +9,6 @@ void test_frame(); void test_game(); void test_keyboard(); void test_stack(); -void test_curses(); void test_test_helper(); #endif