Add a CMakeLists.txt to each exercise directory, included from cmat/CMakeLists.txt, so every exercise and solution becomes a buildable target. GUI exercises link the curses-based DOS_Unix implementations on Unix-like systems; the Windows-specific DOS variants are not compiled. Exercises without a portable path or with missing dependencies (Boost) are reported as not available at configure time. Targets are excluded from the default build and built by name, e.g. `cmake --build build --target Ex11`, so intentionally buggy exercises such as Ex21 do not break the default build. Also fix two portability issues: rename Ex11bug/pole.h to Pole.h for case-sensitive filesystems and drop the extra Light:: qualification in SolutionEx71A/Light.h. Document build commands and layout in AGENTS.md. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#include "CursesObj.h"
|
|
#include "curses.h"
|
|
|
|
CursesObj::CursesObj() {
|
|
// Colours 0 to 7 are defined by curses. But we need grey as well
|
|
// Define a suitable constant here (and create the colour later)
|
|
const int COLOR_GREY = 8;
|
|
|
|
initscr(); /* initialize the curses library */
|
|
nonl(); /* tell curses not to do NL->CR/NL on output */
|
|
cbreak(); /* take input chars one at a time, no wait for \n */
|
|
nodelay(stdscr, FALSE);
|
|
noecho(); /* echo input - in color */
|
|
curs_set(0);
|
|
intrflush(stdscr, FALSE);
|
|
|
|
if (has_colors()) {
|
|
start_color();
|
|
|
|
/*
|
|
* Simple color assignment, often all we need. Color pair 0 cannot
|
|
* be redefined. This example uses the same value for the color
|
|
* pair as for the foreground color, though of course that is not
|
|
* necessary:
|
|
*/
|
|
init_pair(1, COLOR_RED, COLOR_BLACK);
|
|
init_pair(2, COLOR_GREEN, COLOR_BLACK);
|
|
init_pair(3, COLOR_YELLOW, COLOR_BLACK);
|
|
init_pair(4, COLOR_BLUE, COLOR_BLACK);
|
|
init_pair(5, COLOR_CYAN, COLOR_BLACK);
|
|
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
|
|
init_pair(7, COLOR_WHITE, COLOR_BLACK);
|
|
|
|
// Create 'grey' and then use it as foreground colour
|
|
init_color(8, 1, 333, 333);
|
|
|
|
init_pair(8, COLOR_GREY, COLOR_BLACK);
|
|
}
|
|
}
|
|
|
|
CursesObj::~CursesObj() {
|
|
clear();
|
|
refresh();
|
|
endwin();
|
|
}
|
|
|
|
CursesObj &CursesObj::Instance() {
|
|
static CursesObj instance;
|
|
|
|
return instance;
|
|
}
|