1 Commits

Author SHA1 Message Date
80a9d4d8ec fixed unusual terminal state after quitting 2025-06-30 11:06:57 +03:00
3 changed files with 8 additions and 17 deletions

View File

@@ -39,7 +39,7 @@ $(shell mkdir -p $(RLS_DIR))
$(shell mkdir -p $(BUILD_DIR)) $(shell mkdir -p $(BUILD_DIR))
# phony rules # phony rules
.PHONY = all debug release clean install uninstall .PHONY := all debug release clean install uninstall
all: release all: release

View File

@@ -37,7 +37,7 @@ $(shell if not exist $(RLS_DIR) mkdir $(RLS_DIR))
$(shell if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)) $(shell if not exist $(BUILD_DIR) mkdir $(BUILD_DIR))
# phony rules # phony rules
.PHONY = all debug release clean libraries_debug libraries_release both .PHONY := all debug release clean libraries_debug libraries_release both
all: release all: release

View File

@@ -44,11 +44,10 @@ void startGame(Board &board)
{ {
usleep((1000 / MAX_TIME) * 1000); usleep((1000 / MAX_TIME) * 1000);
#ifndef _WIN32 #ifndef _WIN32
if ((w.ws_row < boardSize.x + 3) || (w.ws_col < boardSize.y + 2)) if((w.ws_row < boardSize.x + 3 )||( w.ws_col < boardSize.y + 2)) {
{ mvprintw(w.ws_col/2, w.ws_row/2, "Your terminal is too small:");
mvprintw(w.ws_col / 2, w.ws_row / 2, "Your terminal is too small:"); mvprintw(w.ws_col / 2 + 1, w.ws_row/2, "Current size: %dx%d", w.ws_row, w.ws_col);
mvprintw(w.ws_col / 2 + 1, w.ws_row / 2, "Current size: %dx%d", w.ws_row, w.ws_col); mvprintw(w.ws_col / 2 + 2, w.ws_row/2, "Min size: %dx%d", boardSize.x + 3, boardSize.y + 2);
mvprintw(w.ws_col / 2 + 2, w.ws_row / 2, "Min size: %dx%d", boardSize.x + 3, boardSize.y + 2);
refresh(); refresh();
continue; continue;
} }
@@ -283,9 +282,7 @@ void startGame(Board &board)
{ {
Board newBoard(boardSize.x, boardSize.y, board.getMineCount()); Board newBoard(boardSize.x, boardSize.y, board.getMineCount());
startGame(newBoard); startGame(newBoard);
} } else if(c == 'q') {
else if (c == 'q')
{
echo(); echo();
cbreak(); cbreak();
endwin(); endwin();
@@ -315,9 +312,7 @@ void startGame(Board &board)
{ {
Board newBoard(boardSize.x, boardSize.y, board.getMineCount()); Board newBoard(boardSize.x, boardSize.y, board.getMineCount());
startGame(newBoard); startGame(newBoard);
} } else if(c == 'q') {
else if (c == 'q')
{
echo(); echo();
cbreak(); cbreak();
endwin(); endwin();
@@ -329,18 +324,14 @@ void startGame(Board &board)
int main() int main()
{ {
#ifndef _WIN32
signal(SIGWINCH, handleSIGWINCH); signal(SIGWINCH, handleSIGWINCH);
#endif
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
initscr(); initscr();
noecho(); noecho();
cbreak(); cbreak();
keypad(stdscr, TRUE); keypad(stdscr, TRUE);
nodelay(stdscr, TRUE); nodelay(stdscr, TRUE);
#ifndef _WIN32
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
#endif
start_color(); start_color();
init_pair(1, COLOR_BLUE, COLOR_BLACK); init_pair(1, COLOR_BLUE, COLOR_BLACK);