Worms -- OOP Redo  2016-01
Worms-Redo Project as a learning vehicle.
ncurses.cpp
Go to the documentation of this file.
1 
2 /* ncurses */
3 
4 #include <ncurses.h>
5 
6 void endCurses()
7 {
8  if (!isendwin())
9  endwin();
10 }
11 
13 {
14  initscr(); // ncurses init
15  cbreak(); // unbuffered getChar
16  noecho(); // no echoing of keys pressed
17  // intrflush(stdscr, 0); // TBD
18  nodelay(stdscr, TRUE); // get a char *if* available
19  atexit(endCurses);
20  start_color();
21  use_default_colors();
22  init_pair(1, COLOR_RED, -1);
23  init_pair(2, COLOR_GREEN, -1);
24  init_pair(3, COLOR_BLUE, -1);
25  getmaxyx(stdscr, asogRows, asogCols);
26  if (asogCols > MAXcol) asogCols = MAXcol;
27  if (asogRows > MAXrow) asogRows = MAXrow;
28  asogRows -= 6; // 6 lines for msgs, asogRows needs to be > 0
29 }
30 
32 {
33  nodelay(stdscr, FALSE); // wait until a char is typed
34  int c = getChar();
35  nodelay(stdscr, TRUE);
36  return c;
37 }
38 
39 // ncurses code ends here
int asogRows
Definition: display.cpp:18
#define MAXrow
Definition: display.cpp:14
#define MAXcol
Definition: display.cpp:15
int asogCols
Definition: display.cpp:18
void endCurses()
Definition: ncurses.cpp:6
#define getChar()
Definition: worms.h:28
void startCurses()
Definition: ncurses.cpp:12
int getOneChar()
Definition: ncurses.cpp:31