Compare commits
No commits in common. "37624e487833793b4fc6869500a968a74a810f81" and "2e179eb78063929cb4b3e3310a0ee5166a58e0d5" have entirely different histories.
37624e4878
...
2e179eb780
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
|||||||
# Compiler and flags
|
# Compiler and flags
|
||||||
CPPC = g++
|
CPPC = g++
|
||||||
CPPC_FLAGS = -std=c++23 -s -O3 -Wall -Wextra -Wno-write-strings -lncurses -lmenu -lform
|
CPPC_FLAGS = -std=c++23 -s -O3 -Wall -Wextra -Wno-write-strings -lncurses -lmenu
|
||||||
DEBUG_FLAGS = -ggdb -std=c++23 -Wall -Wextra -Wno-write-strings -lncurses -lmenu -lform
|
DEBUG_FLAGS = -ggdb -std=c++23 -Wall -Wextra -Wno-write-strings -lncurses -lmenu
|
||||||
|
|
||||||
|
|
||||||
SRC_PATH := src
|
SRC_PATH := src
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "gameske_funkce.h"
|
#include "gameske_funkce.h"
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -93,32 +92,3 @@ void print_in_middle(WINDOW* win, int starty, int startx, int width,
|
|||||||
wattroff(win, color);
|
wattroff(win, color);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void spawncmd() {
|
|
||||||
// Use a fixed-size array instead of dynamic allocation
|
|
||||||
char cmd[100] = {0}; // Initialize to prevent undefined behavior
|
|
||||||
|
|
||||||
// Create command window with error checking
|
|
||||||
WINDOW* cmd_win = newwin(3, 40, LINES - 3, 0);
|
|
||||||
if (cmd_win == NULL) {
|
|
||||||
// Handle window creation failure
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
keypad(cmd_win, TRUE);
|
|
||||||
box(cmd_win, 0, 0);
|
|
||||||
mvwprintw(cmd_win, 1, 1, "Command: ");
|
|
||||||
wrefresh(cmd_win);
|
|
||||||
|
|
||||||
// Use correct size (99 to leave room for null terminator)
|
|
||||||
wgetnstr(cmd_win, cmd, 99);
|
|
||||||
|
|
||||||
mvprintw(LINES - 2, 0, "You Entered: %s", cmd);
|
|
||||||
refresh(); // Refresh the standard screen
|
|
||||||
|
|
||||||
// Consider using a more interactive approach than sleep
|
|
||||||
napms(5000); // ncurses alternative to sleep
|
|
||||||
|
|
||||||
// Clean up resources
|
|
||||||
delwin(cmd_win);
|
|
||||||
}
|
|
||||||
|
@ -7,5 +7,3 @@ size_t spawn_menu(uint16_t begin_y, uint16_t begin_x, const char** choices,
|
|||||||
|
|
||||||
void print_in_middle(WINDOW* win, int starty, int startx, int width,
|
void print_in_middle(WINDOW* win, int starty, int startx, int width,
|
||||||
char* string, chtype color);
|
char* string, chtype color);
|
||||||
|
|
||||||
void spawncmd();
|
|
@ -69,11 +69,10 @@ void menu() {
|
|||||||
menu_driver(my_menu, REQ_UP_ITEM);
|
menu_driver(my_menu, REQ_UP_ITEM);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
mvprintw(LINES - 1, 0, "%lu",
|
||||||
|
spawn_menu(15, 45, choices2, ARRAY_SIZE(choices2)));
|
||||||
refresh();
|
refresh();
|
||||||
break;
|
break;
|
||||||
case ':':
|
|
||||||
spawncmd();
|
|
||||||
}
|
}
|
||||||
wrefresh(my_menu_win);
|
wrefresh(my_menu_win);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user