diff --git a/lib/display.c b/lib/display.c index f12308f..564e000 100644 --- a/lib/display.c +++ b/lib/display.c @@ -1,9 +1,18 @@ #include #include #include +#include #include "card.h" #include "display.h" +void init_curses() { + setlocale(LC_ALL, ""); /* supporting unicode characters */ + initscr(); /* initialize the terminal in curses mode */ + raw(); /* disable line buffers */ + noecho(); /* character echo is unnecessary */ + keypad(stdscr, TRUE); /* enable F and arrow keys */ +} + char *card_suit(enum suit suit) { char *card_suit; diff --git a/src/tty-solitaire.c b/src/tty-solitaire.c index aa91789..170903b 100644 --- a/src/tty-solitaire.c +++ b/src/tty-solitaire.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "common.h" #include "../lib/card.h" @@ -9,11 +8,7 @@ int main(int argc, const char *argv[]) { char message[] = "Welcome to tty-solitaire."; int row_number, column_number; - setlocale(LC_ALL, ""); /* supporting unicode characters */ - initscr(); /* initialize the terminal in curses mode */ - raw(); /* disable line buffers */ - noecho(); /* character echo is unnecessary */ - keypad(stdscr, TRUE); /* enable F and arrow keys */ + init_curses(); getmaxyx(stdscr, row_number, column_number); mvprintw(row_number / 2 - 1,